1
0
mirror of https://github.com/danog/dns.git synced 2024-12-03 09:57:56 +01:00

Remove ext/filter dependency in IP type check

This commit is contained in:
Daniel Lowrey 2015-02-17 15:34:12 -05:00
parent 1d7627f7ca
commit 46d1981ff5

View File

@ -71,12 +71,12 @@ class HostsFile {
} }
$parts = preg_split('/\s+/', $line); $parts = preg_split('/\s+/', $line);
if (filter_var($parts[0], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false) { if (!($ip = @inet_pton($parts[0]))) {
$key = AddressModes::INET4_ADDR; continue;
} else if (filter_var($parts[0], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { } elseif (isset($ip[4])) {
$key = AddressModes::INET6_ADDR; $key = AddressModes::INET6_ADDR;
} else { } else {
continue; $key = AddressModes::INET4_ADDR;
} }
for ($i = 1, $l = count($parts); $i < $l; $i++) { for ($i = 1, $l = count($parts); $i < $l; $i++) {