From d4d6e70cb901a5e7acfd2dae8127fb0005d02565 Mon Sep 17 00:00:00 2001 From: Julien Pecqueur Date: Tue, 5 Sep 2017 10:29:03 +0200 Subject: [PATCH] fix: unknown IP shouldn't crash --- fail2ban-report | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fail2ban-report b/fail2ban-report index 33fc894..ad0c848 100755 --- a/fail2ban-report +++ b/fail2ban-report @@ -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: - response = reader.country(ip) - country = response.country.name + try: + response = reader.country(ip) + country = response.country.name + except: + country = "n/c" if country in d.keys(): d[country] += 1 else: