maxmind / GeoIP2-php

PHP API for GeoIP2 webservice client and database reader
https://maxmind.github.io/GeoIP2-php/
Apache License 2.0
2.34k stars 279 forks source link

ASN model should return the network block #99

Closed Huji closed 4 years ago

Huji commented 7 years ago

Currently, the ASN model returns only two values: autonomous_system_number and autonomous_system_organization. It should, however, return the network value (aka the IP subnet) as well. Some ASOs have multiple subnets, and it is needed to know which IP belongs to which one of those subnets.

Huji commented 7 years ago

For instance, when you call $reader->asn( '8.8.8.8' ); you currently get results like this:

GeoIp2\Model\Asn Object
(
    [autonomousSystemNumber:protected] => 15169
    [autonomousSystemOrganization:protected] => Google Inc.
    [ipAddress:protected] => 8.8.8.8
    [raw:protected] => Array
        (
            [autonomous_system_number] => 15169
            [autonomous_system_organization] => Google Inc.
            [ip_address] => 8.8.8.8
        )

)

But desired results are like this:

GeoIp2\Model\Asn Object
(
    [autonomousSystemNumber:protected] => 15169
    [autonomousSystemOrganization:protected] => Google Inc.
    [ipAddress:protected] => 8.8.8.8
    [network:protected] => 8.8.8.0/24
    [raw:protected] => Array
        (
            [autonomous_system_number] => 15169
            [autonomous_system_organization] => Google Inc.
            [ip_address] => 8.8.8.8
            [network] => 8.8.8.0/24
        )

)
oschwald commented 7 years ago

I would suggest that you direct this to support@maxmind.com as this would likely be changed at the database level rather than the library level.

Huji commented 7 years ago

Email sent. Will report back once I receive a response.

For the record, I am not familiar with the MMDB format, but in the CSV format the network variable is already available as the first column in the ASN file.

oschwald commented 4 years ago

138 resolves this.