This changeset improves parsing of the /etc/resolv.conf file by skipping invalid nameserver entries and also ignoring any IPv6 zone IDs (scope IDs). This is now more in line with how glibc also completely ignores invalid entries and also only provides somewhat limited support for IPv6 zone IDs.
Prior to these changes, having a completely valid /etc/resolv.conf with a nameserver ::0%lo0 entry would throw an InvalidArgumentException because both the UdpTransportExecutor and TcpTransportExecutor consider this to be an invalid IP address. To make matters worse, this also happens if this is only a secondary DNS server address that's not even in active use, so it will not even try to primary DNS server in this case.
After applying these changes, it will now use ::0 (without the zone ID / scope ID). This isn't exactly perfect, but it's a major improvement over the previous situation. Altogether, this is a rather rare situation and using routable IPv6 is usually preferable.
If you're curious, PHP provides only very limited support for IPv6 addresses with scope IDs. Once this situation improves, we could potentially add full support for scope IDs.
- https://github.com/php/php-src/search?q=sin6_scope_id
- https://man7.org/linux/man-pages/man7/ipv6.7.html
- https://unix.stackexchange.com/questions/174767/ipv6-zone-id-in-etc-hosts
- https://bugs.php.net/bug.php?id=65808
Supersedes / closes #181 (thanks @remicollet for the original suggestion!)
Refs #75 and #76 for similar logic when parsing /etc/hosts