Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log files fill up with AddressNotFoundException on private IPv6 addresses #74

Closed
rdev5 opened this issue Jul 28, 2016 · 1 comment
Closed

Comments

@rdev5
Copy link

rdev5 commented Jul 28, 2016

Affects: Torann/laravel-geoip#55

Error: The address ::1 is not in the database.

I haven't seen any from 127.0.0.1 (IPv4), but GeoIP2 fills up logs very quickly with the above error and stack trace when the error is thrown (discovered by rap2hpoutre/laravel-log-viewer) at https://github.com/maxmind/GeoIP2-php/blob/master/src/Database/Reader.php#L220-L224

Consider adding the following (or a similar implementation) to skip database check if the IP is private:

function is_private_IP($ip) {
    return filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE |  FILTER_FLAG_NO_RES_RANGE);
}

Source: https://arjunphp.com/check-if-an-ip-address-is-private-with-php/

@oschwald
Copy link
Member

oschwald commented Jul 28, 2016

This API throws exceptions on private IPs and other IPs not in the database, as documented. This is the intended behavior. If you do not want this behavior, please consider using MaxMind\Db\Reader directly instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants