Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions msticpy/context/geoip.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,15 @@ def lookup_ip(
geo_match = self._get_geomatch_non_public(ip_type)
elif self._reader:
try:
geo_match = self._reader.city(ip_input).raw # type: ignore
except (AddressNotFoundError, AttributeError, ValueError):
geo_match_object = self._reader.city(ip_input)
if hasattr(geo_match_object, "raw"):
geo_match = geo_match_object.raw # type: ignore
elif hasattr(geo_match_object, "to_dict"):
geo_match = geo_match_object.to_dict()
else:
geo_match = None
except (AddressNotFoundError, AttributeError, ValueError) as err:
logger.warning("Error looking up IP %s - %s", ip_input, err)
continue
if geo_match:
output_raw.append(geo_match)
Expand Down
2 changes: 1 addition & 1 deletion msticpy/context/ip_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _get_asns_dict() -> dict[str, str]:
asns_soup = BeautifulSoup(asns_resp.content, features="lxml")
asns_dict = {
str(asn.next_element)
.strip(): str(asn.next_element.next_element)
.strip(): str(asn.next_element.next_element if asn.next_element else "")
.strip()
for asn in asns_soup.find_all("a")
}
Expand Down