Add top visitors and reverse dns plugins
This commit is contained in:
		
							
								
								
									
										27
									
								
								plugins/post_analysis/reverse_dns.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								plugins/post_analysis/reverse_dns.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| import socket | ||||
| from iwla import IWLA | ||||
|  | ||||
| PLUGIN_CLASS = 'HTTP' | ||||
| API_VERSION = 1 | ||||
|  | ||||
| def get_plugins_infos(): | ||||
|     infos = { | ||||
|         'class' : PLUGIN_CLASS, | ||||
|         'min_version' : API_VERSION, | ||||
|         'max_version' : -1 | ||||
|     } | ||||
|     return infos | ||||
|  | ||||
| def load(): | ||||
|     socket.setdefaulttimeout(0.5) | ||||
|     return True | ||||
|  | ||||
| def hook(iwla): | ||||
|     hits = iwla.getValidVisitors() | ||||
|     for (k, hit) in hits.items(): | ||||
|         try: | ||||
|             name, _, _ = socket.gethostbyaddr(k) | ||||
|             hit['remote_addr'] = name | ||||
|         except: | ||||
|             pass | ||||
|  | ||||
							
								
								
									
										23
									
								
								plugins/post_analysis/top_visitors.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								plugins/post_analysis/top_visitors.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| from iwla import IWLA | ||||
|  | ||||
| PLUGIN_CLASS = 'HTTP' | ||||
| API_VERSION = 1 | ||||
|  | ||||
| def get_plugins_infos(): | ||||
|     infos = { | ||||
|         'class' : PLUGIN_CLASS, | ||||
|         'min_version' : API_VERSION, | ||||
|         'max_version' : -1 | ||||
|     } | ||||
|     return infos | ||||
|  | ||||
| def load(): | ||||
|     return True | ||||
|  | ||||
| def hook(iwla): | ||||
|     hits = iwla.getValidVisitors() | ||||
|     stats = iwla.getMonthStats() | ||||
|     top_bandwidth = [(k,hits[k]['bandwidth']) for (k,v) in hits.items()] | ||||
|     top_bandwidth = sorted(top_bandwidth, key=lambda t: t[1], reverse=True) | ||||
|     stats['top_visitors'] = [hits[h[0]] for h in top_bandwidth[:10]] | ||||
|  | ||||
		Reference in New Issue
	
	Block a user