Skip to content

Conversation

@clue
Copy link
Member

@clue clue commented Nov 26, 2021

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.

Supersedes / closes #181 (thanks @remicollet for the original suggestion!)
Refs #75 and #76 for similar logic when parsing /etc/hosts

@clue clue added this to the v1.9.0 milestone Nov 26, 2021
@clue clue mentioned this pull request Nov 26, 2021
@clue clue requested a review from WyriHaximus November 26, 2021 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants