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
Localhost is special #6955
Localhost is special #6955
Conversation
That's some serious dedication to avoid writing a single line in the chroot Back on this PR. The RFC says more than what you quoted:
If you want to follow the RFC the localhost check must be performed first and not as a last-resort when the resolution failed. About the code:
Returning a v4/v6 combo when unsure ( You now may be tempted to return a v4 address only, but that'd make the implementation non-rfc compliant (and pandas sad). |
I do not have permissions to modify that file; wearing my packager hat, the alternative is marking zig's test suite as incorrect and somehow disabling the test.
Good question; I thought about this and decided the least objectionable decision would be to only avoid returning a null result. If you'd like me to move it up before the
I believed that the trailing
The easy option is to return both: if a user attempts ipv4 and gets Test failure seems unrelated with |
That should be the very first check if you want to adhere to the RFC.
Well the trailing dot makes it an absolute domain name but it's still localhost. Curl is smart enough to do the right thing, Firefox new address bar does a google search (eww), I think chromium handles this just fine.
Well if the DNS resolver API is kept an implementation detail and we control the flags passed to Adding an assertion is enough to prevent accidental breakages. |
// types. | ||
|
||
// Check for equal to "localhost" or ends in ".localhost" | ||
if (mem.endsWith(u8, name, "localhost") and (name.len == "localhost".len or name[name.len - "localhost".len] == '.')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the check be non case-sensitive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other functions (e.g. linuxLookupNameFromHosts
) are also case sensitive: I think case normalisation is meant to happen before linuxLookupName
is called.
An interesting use case, however, someone could still support this behavior without overloading the EDIT: after thinking on this more, saying that this would be "overloading" the localhost domain isn't correct. Your proposed use case still adhere's to the spec, which I didn't realize till just now. So this is a valid point that we would be limiting a machine's ability to customize the "system-wide" behavior of "localhost" in a single location like |
f6a4858
to
3716273
Compare
* std: always return loopback address when looking up localhost * std: also return Ipv6 loopback * std: remove commented out obsolete code
cherry-picked into 0.7.x => d15a0ec |
The PR is still wrong, but let's merge it anyway! One less item in the backlog, who cares about RFCs? |
It improves the status quo. It doesn't have to be perfect. |
what a fucking joke |
be kind to each other |
RFC 6761 Section 6.3:
Fixes #6898