Skip to content

Commit

Permalink
fixed country geoloc display
Browse files Browse the repository at this point in the history
  • Loading branch information
jvehent committed Nov 7, 2011
1 parent e59bfaf commit a89972f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions postscreen_stats.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ def action_filter(self,filter):
or ip_list[client].actions["BARE NEWLINE"] > 0 or ip_list[client].actions["BARE NEWLINE"] > 0
or ip_list[client].actions["NON-SMTP COMMAND"] > 0)): or ip_list[client].actions["NON-SMTP COMMAND"] > 0)):
blocked_countries[ip_list[client].geoloc["country_name"]] += 1 blocked_countries[ip_list[client].geoloc["country_name"]] += 1
clients["blocked clients"] += 1


# calculate the average reconnection delay # calculate the average reconnection delay
if clients["reconnections"] > 0: if clients["reconnections"] > 0:
Expand Down Expand Up @@ -398,10 +399,11 @@ def action_filter(self,filter):
print str(Decimal(comeback['>24h'])/dec_cameback * 100).ljust(8) + "|" print str(Decimal(comeback['>24h'])/dec_cameback * 100).ljust(8) + "|"


if GEOLOC > 0: if GEOLOC > 0:
print "\n=== Top 20 Blocked Countries ===" print "\n=== Top 20 Countries of Blocked Clients ==="
from operator import itemgetter from operator import itemgetter
sorted_countries = blocked_countries.items() sorted_countries = blocked_countries.items()
sorted_countries.sort(key = itemgetter(1), reverse=True) sorted_countries.sort(key = itemgetter(1), reverse=True)
for i in range(20): for i in range(20):
print sorted_countries[i] if i < len(sorted_countries):

country,clients = sorted_countries[i]
print clients, country

0 comments on commit a89972f

Please sign in to comment.