Skip to content

Conversation

gregorybrzeski
Copy link
Contributor

Extended the information returned for ASN queries by adding network information to the already returned AutonomousSystemNumber and AutonomousSystemOrganization. Network information is calculated based on the database tree information.

MaxMind GeoLite documentation lists the network as core information in the GeoLite2 ASN database.
source: https://dev.maxmind.com/geoip/docs/databases/asn/

Change supports queries for IPv4 and IPv6 addresses.

Changes implemented:

  • calculate network in CIDR notation based on IP address and mask calculated from database tree
  • created new function getOffsetWithPrefix() that in turn is used by rewritten getOffset() to be compatible with current code
  • used getOffsetWithPrefix() in ASNReader
  • added appropriate tests
  • used only current dependencies

Inspired by MaxMind nodejs module: GeoIP2-Node

Let me know what you think.

@IncSW IncSW merged commit 34a5209 into IncSW:master Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants