fix: unknown IP shouldn't crash

This commit is contained in:
Julien Pecqueur 2017-09-05 10:29:03 +02:00
parent 420af736c6
commit d4d6e70cb9

View file

@ -40,8 +40,11 @@ def get_nb_ban_by_country(data, f_country):
reader = geoip2.database.Reader(f_country)
d = {}
for ip, date in data:
try:
response = reader.country(ip)
country = response.country.name
except:
country = "n/c"
if country in d.keys():
d[country] += 1
else: