mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 06:24:23 +01:00
Update geoip.py (#1896)
Added error handling in case `IP_ADDR_LOOKUP.get(addr)` fails.
This commit is contained in:
@@ -8,8 +8,8 @@ IP_ADDR_LOOKUP = maxminddb.open_database(
|
||||
|
||||
|
||||
def lookup_ip_address(addr):
|
||||
response = IP_ADDR_LOOKUP.get(addr)
|
||||
try:
|
||||
response = IP_ADDR_LOOKUP.get(addr)
|
||||
return response["country"]["iso_code"]
|
||||
except KeyError:
|
||||
except (KeyError, ValueError):
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user