Skip to content

#62 - ASN is still empty when databases have values#68

Open
nhi-vanye wants to merge 2 commits intoIronholds:masterfrom
BadonHill:master
Open

#62 - ASN is still empty when databases have values#68
nhi-vanye wants to merge 2 commits intoIronholds:masterfrom
BadonHill:master

Conversation

@nhi-vanye
Copy link
Copy Markdown

Fixed lookup of "trait" records" (i.e. ASN, ASO, Connection etc)

Also added "user_type" which is the type (i.e. Hosting, Corporate)

This has only been testes with a full commercial binary MMDB database from db-ip.com.

> ip <- "43.131.30.179"
> geo <- rgeolocate::maxmind(
      ip,
      geoip_file,
      fields = c(
          "continent_name",
          "country_code",
          "country_name",
          "region_name",
          "city_name",
          "latitude",
          "longitude",
          "timezone",
          "postcode",
          "isp",
          "organization",
          "asn",
          "aso",
          "connection",
          "user_type"
      )
 )
> geo
  continent_name country_code country_name region_name         city_name latitude
1         Europe           DE      Germany       Hesse Frankfurt am Main  50.1109
  longitude      timezone postcode              isp organization    asn
1   8.68213 Europe/Berlin    60313 Aceville Pte.ltd         <NA> 132203
                                                aso connection user_type
1 Shenzhen Tencent Computer Systems Company Limited  Corporate   hosting

This has only been tested with a icommercial MMDB from DB-IP.com
Fixed accessing the extended attributes (i.e. ASN)

IntegerVector maxmind_bindings::asn(MMDB_s *data, CharacterVector ip_addresses){
return mmdb_getint32(data, ip_addresses, "autonomous_system_number", NULL);
return mmdb_getint32(data, ip_addresses, "traits", "autonomous_system_number", NULL);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these changes would work with the MaxMind GeoIP2 ISP, ASN, or Connection-Type databases. They do not use the nested traits map.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original bug was for a "MaxMind Enterprise" database - which was also using the "traits" map.

How would you like issues between different layouts handled? I don't have access to other sources...

I've solved my issue, so I'm okay if its only a partial fix as I'm unlikely to use different database vendors...But making it clean for others would be good...

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are test databases for the types MaxMind provides.

Yeah, I am not exactly sure what the best fix is given what this code looks like. I guess one option is to check both locations. Another would be to check the database type and do the right thing based on that.

The official MaxMind libraries generally return a structured objects with separate lookup methods for the different database types or as nested maps for the lower-level APIs.

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