antonioribeiro / firewall

Firewall package for Laravel applications
BSD 3-Clause "New" or "Revised" License
1.39k stars 163 forks source link

Getting Exception E_WARNING: inet_pton(): Unrecognized address <filepath> #113

Closed alariva closed 5 years ago

alariva commented 6 years ago

Hi, great tool here. :)

I'm getting the following exception reported every time my whitelist is evaluated:

E_WARNING: inet_pton(): Unrecognized address /path/to/whitelist.txt

Actual file path was changed for obvious reason.

Sample Evidence Screenshot

The whitelisted IPs seem to work ok, meaning that I can ask the status with $whitelisted = Firewall::isWhitelisted('10.17.12.1');

However, it looks like the exception is triggered before getting to the actual file contents. As far as I understand, this looks like usual behavior, so, would it be possible to avoid the continuous (false alarm) exception to be triggered?

My config/firewall.php is like:

// ...
'whitelist' => [
    storage_path().DIRECTORY_SEPARATOR."whitelist.txt",
],
// ...

And the whitelisted contents are all valid IPv4 entries. Actually, these are the contents.

Using L5.4 and package v2.1.0 Thanks very much!

alariva commented 6 years ago

As per my understanding, guarding that if $ip is an actual filepath, false could be returned straight away thus avoiding further pass of an aknowledged-invalid IP to inet_pton() later on.

https://github.com/antonioribeiro/firewall/blob/master/src/Support/IpAddress.php#L68