mirror of
https://github.com/jpec/fail2ban-report.git
synced 2024-12-22 13:32:14 +01:00
fix: unknown IP shouldn't crash
This commit is contained in:
parent
420af736c6
commit
d4d6e70cb9
1 changed files with 5 additions and 2 deletions
|
@ -40,8 +40,11 @@ def get_nb_ban_by_country(data, f_country):
|
||||||
reader = geoip2.database.Reader(f_country)
|
reader = geoip2.database.Reader(f_country)
|
||||||
d = {}
|
d = {}
|
||||||
for ip, date in data:
|
for ip, date in data:
|
||||||
|
try:
|
||||||
response = reader.country(ip)
|
response = reader.country(ip)
|
||||||
country = response.country.name
|
country = response.country.name
|
||||||
|
except:
|
||||||
|
country = "n/c"
|
||||||
if country in d.keys():
|
if country in d.keys():
|
||||||
d[country] += 1
|
d[country] += 1
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue