Skip to content

Commit

Permalink
Merge pull request #1 from ebdavison/ebdavison-issue27
Browse files Browse the repository at this point in the history
fix for issue cyberdefenders#27
  • Loading branch information
jpbarraca authored Apr 24, 2023
2 parents dc0b3f0 + 25ae2f0 commit 240dce1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions mha/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit 240dce1

Please sign in to comment.