diff --git a/mha/server.py b/mha/server.py index 4177e3d..c35087d 100644 --- a/mha/server.py +++ b/mha/server.py @@ -34,12 +34,15 @@ def getCountryForIP(line): if ip: ip = ip[0] # take the 1st ip and ignore the rest if IP(ip).iptype() == 'PUBLIC': - r = reader.country(ip).country - if r.iso_code and r.name: - return { - 'iso_code': r.iso_code.lower(), - 'country_name': r.name - } + try: + r = reader.country(ip).country + if r.iso_code and r.name: + return { + 'iso_code': r.iso_code.lower(), + 'country_name': r.name + } + except: + pass return dict(country=getCountryForIP)