Skip to content

Commit

Permalink
Fix #326, catch a geoip2 database error in GraphQL
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroSteiner committed Oct 10, 2018
1 parent 42fc8d7 commit 1970ea2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion king_phisher/server/graphql/types/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import king_phisher.geoip as geoip
import king_phisher.ipaddress as ipaddress

import geoip2.errors
import graphene.types.utils
import graphql.language.ast

Expand Down Expand Up @@ -110,7 +111,10 @@ def from_ip_address(cls, ip_address):
ip_address = ipaddress.ip_address(ip_address)
if ip_address.is_private:
return
result = geoip.lookup(ip_address)
try:
result = geoip.lookup(ip_address)
except geoip2.errors.AddressNotFoundError:
result = None
if result is None:
return
return cls(**result)
Expand Down

0 comments on commit 1970ea2

Please sign in to comment.