Skip to content
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

proposal: net: add support for "let localhost be localhost" #22826

Open
mikioh opened this issue Nov 21, 2017 · 6 comments
Open

proposal: net: add support for "let localhost be localhost" #22826

mikioh opened this issue Nov 21, 2017 · 6 comments

Comments

@mikioh
Copy link
Contributor

mikioh commented Nov 21, 2017

The I-D https://tools.ietf.org/html/draft-ietf-dnsop-let-localhost-be-localhost became an IETF dnsop-wg draft. It would be better to support the feature once the I-D has been published as an RFC for the sake of convenience instead of saying "sorry, there's no direct relationship between the IPv4 loopback address prefix 127.0.0.0/8 or the IPv6 loopback address ::1 and the name localhost, that's just the convention", although the resolution for localhost still remains as a burden of applications from security perspective.

@bradfitz
Copy link
Contributor

Can you briefly describe the proposal, or do I need to read that URL?

Are you proposing that we hard-code DNS resolution of "localhost" to always mean 127.0.0.1 or ::1?

@mikioh
Copy link
Contributor Author

mikioh commented Nov 29, 2017

hard-code DNS resolution

Sort of. Simply, implementing mapping between the label localhost., and 127.0.0.0/8 and ::1 into the existing DNS stub resolver and a few tweaks such as routing ability check for 127.0.0.0/8 and ::1; routing instances may take any address in 127.0.0.0/8 as its loopback address.

@bradfitz
Copy link
Contributor

Could you send a CL?

I imagine once it's an official RFC we'll accept it. But it would be nice to see the CL earlier.

@mikioh
Copy link
Contributor Author

mikioh commented Nov 29, 2017

Will write a CL while watching Australian Open 2018, probably.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2017

This should be put on hold until it is actually approved and has an RFC number.

@mikioh
Copy link
Contributor Author

mikioh commented Feb 20, 2019

[Status report] Looks like the draft has been stalled, probably it's hard to make a consensus about pushing the draft to the next stage, IESG, perhaps because of the lack of a general solution to the problem domain. If you are waiting for the fix of this issue, it's better to find out another way. I'll keep this issue open for a while, but close at some point.

bradfitz added a commit to tailscale/tailscale that referenced this issue Nov 10, 2020
In tests, we force binding to localhost to avoid OS firewall warning
dialogs.

But for IPv6, we were trying (and failing) to bind to 127.0.0.1.

You'd think we'd just say "localhost", but that's apparently ill
defined. See
https://tools.ietf.org/html/draft-ietf-dnsop-let-localhost-be-localhost
and golang/go#22826. (It's bitten me in the past, but I can't
remember specific bugs.)

So use "::1" explicitly for "udp6", which makes the test quieter.
bradfitz added a commit to tailscale/tailscale that referenced this issue Nov 10, 2020
In tests, we force binding to localhost to avoid OS firewall warning
dialogs.

But for IPv6, we were trying (and failing) to bind to 127.0.0.1.

You'd think we'd just say "localhost", but that's apparently ill
defined. See
https://tools.ietf.org/html/draft-ietf-dnsop-let-localhost-be-localhost
and golang/go#22826. (It's bitten me in the past, but I can't
remember specific bugs.)

So use "::1" explicitly for "udp6", which makes the test quieter.

(cherry picked from commit 450cfed)
matthiasr added a commit to prometheus/statsd_exporter that referenced this issue Jul 8, 2022
This is the only way I could find to make the test pass on _my_
macOS machine:

```
Darwin mr-6.local 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64
```

I don't understand the problem here, and I am not sure what the
implications are; this probably breaks the test on IPv4-only machines if
those still exist.

Without this change, or even when using 127.0.0.1, nothing is received.

```
=== RUN   TestRelay_RelayLine
=== RUN   TestRelay_RelayLine/multiple_lines
    udp.go:85: At: /Users/mr/src/github.com/prometheus/statsd_exporter/pkg/relay/relay_test.go:68
    udp.go:115: Expected to find: "foo5:100|c|#tag1:bar,#tag2:baz\n"
    udp.go:116: But got: ""
--- FAIL: TestRelay_RelayLine (0.00s)
    --- FAIL: TestRelay_RelayLine/multiple_lines (0.00s)
FAIL
FAIL	github.com/prometheus/statsd_exporter/pkg/relay	1.809s
FAIL
```

Is there a better or more well understood solution?

Possibly related: `localhost` is [not well defined](golang/go#22826).

Signed-off-by: Matthias Rampke <matthias@prometheus.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants