Open oakad opened 4 months ago
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
That's not proof that IPv6 is disabled, only that dig
defaults to an A
(IPv4) query.
It is, I assure you. However, there's a caveat: we have a Cisco VPN which insists on advertising an additional resolver; the said resolver is able to resolve AAAA record ("Request A records, Request AAAA records"). Basically, I've got this config:
DNS configuration
resolver #1 search domain[0] : heh nameserver[0] : heh nameserver[1] : heh flags : Request A records, Request AAAA records reach : 0x00000002 (Reachable) order : 1
DNS configuration (for scoped queries) resolver #1 nameserver[0] : heh nameserver[1] : heh if_index : 15 (en0) flags : Scoped, Request A records reach : 0x00000002 (Reachable)
resolver #2 search domain[0] : heh nameserver[0] : heh nameserver[1] : heh if_index : 23 (utun4) flags : Scoped, Request A records, Request AAAA records reach : 0x00000002 (Reachable) order : 1
Still, go should not pick the AAAA address. Or, at least, it should not do so unconditionally, because I don't think our setup is uniquely broken. :-)
From the output it is clear that the cgo resolver is being used, so out of our scope.
https://danp.net/posts/macos-dns-change-in-go-1-20/
This had started happening relatively recently and I believe it is caused by changes above.
Can you try forcing the go resolver and see if it helps in your case? GODEBUG=netdns=go
How do I enable both this feature and dns debug so we can see it is used for real?
GODEBUG=netdns=go+2
Tough luck:
% go get nhooyr.io/websocket go package net: confVal.netCgo = false netGo = true go package net: GODEBUG setting forcing use of Go's resolver go package net: hostLookupOrder(proxy.golang.org) = files,dns go: module nhooyr.io/websocket: Get "https://proxy.golang.org/nhooyr.io/websocket/@v/list": write tcp [fe80::bed0:74ff:fe64:598e%utun4]:57052->[2a00:1450:4003:80c::2011]:443: write: socket is not connected
For reference, curl does this:
% curl -v https://proxy.golang.org/nhooyr.io/websocket/@v/list
What if you pass --ipv6 to curl?
In theory go's network stack should also be doing fast fallback / dual stack ipv4 and ipv6
So the tittle is incorrect, it resolves correctly, but it fails to connect to the server when ipv6 is unavail, right?
curl gets stuck when forced to use ipv6. It may be that despite underlying adapter has ipv6 disabled, the Cisco vpn client pretends it's got an ipv6 address on the utun interface. Yet it causes no issues anywhere, everything works fine apart from go.
% curl -v --ipv6 https://proxy.golang.org/nhooyr.io/websocket/@v/list
The address is of course correct, it's the action of resolving the AAAA and sticking to it rather than resolving A is incorrect. :-)
From the discussion so far, it sounds like:
getsockopt(fd, SOL_SOCKET, SO_ERROR)
in net/fd_unix.go and gets syscall.EISCONN, which makes it return from Dial.Normally, when IPv6 addresses can't be used, the connect never succeeds (fails or times out). In your case, it appears that the connect is succeeding but then the connection breaks very quickly after that, perhaps on the first write.
Do you know of anything strange about your Mac's network or IPv6 configuration? Or some firewall that is actively breaking IPv6 connections?
For example on my Mac:
% host proxy.golang.org
proxy.golang.org has address 142.250.65.177
proxy.golang.org has IPv6 address 2607:f8b0:4006:80e::2011
proxy.golang.org mail is handled by 40 alt4.gmr-smtp-in.l.google.com.
proxy.golang.org mail is handled by 10 alt1.gmr-smtp-in.l.google.com.
proxy.golang.org mail is handled by 5 gmr-smtp-in.l.google.com.
proxy.golang.org mail is handled by 30 alt3.gmr-smtp-in.l.google.com.
proxy.golang.org mail is handled by 20 alt2.gmr-smtp-in.l.google.com.
% sudo route add -inet6 2607:f8b0:4006:80e::2011 ::1
add host 2607:f8b0:4006:80e::2011: gateway ::1
% go mod download -json rsc.io/markdown@latest
{
"Path": "rsc.io/markdown",
"Version": "v0.0.0-20240617154923-1f2ef1438fed",
"Query": "latest",
"Info": "/Users/rsc/pkg/mod/cache/download/rsc.io/markdown/@v/v0.0.0-20240617154923-1f2ef1438fed.info",
"GoMod": "/Users/rsc/pkg/mod/cache/download/rsc.io/markdown/@v/v0.0.0-20240617154923-1f2ef1438fed.mod",
"Zip": "/Users/rsc/pkg/mod/cache/download/rsc.io/markdown/@v/v0.0.0-20240617154923-1f2ef1438fed.zip",
"Dir": "/Users/rsc/pkg/mod/rsc.io/markdown@v0.0.0-20240617154923-1f2ef1438fed",
"Sum": "h1:savaUwUp0YCIxdaF9EFOMB3j+TQnoLop+cNp2KPC9jk=",
"GoModSum": "h1:rzOcjAz36Xzvwf6iaJSYXkmNbvu5XHelis1egIN0Cys="
}
% curl -v --ipv6 https://proxy.golang.org
* Host proxy.golang.org:443 was resolved.
* IPv6: 2607:f8b0:4006:80e::2011
* IPv4: (none)
* Trying [2607:f8b0:4006:80e::2011]:443...
^C
% sudo route delete -inet6 2607:f8b0:4006:80e::2011
delete host 2607:f8b0:4006:80e::2011
% curl -v --ipv6 https://proxy.golang.org
* Host proxy.golang.org:443 was resolved.
* IPv6: 2607:f8b0:4006:80e::2011
* IPv4: (none)
* Trying [2607:f8b0:4006:80e::2011]:443...
* Immediate connect fail for 2607:f8b0:4006:80e::2011: No route to host
* Failed to connect to proxy.golang.org port 443 after 3 ms: Couldn't connect to server
* Closing connection
curl: (7) Failed to connect to proxy.golang.org port 443 after 3 ms: Couldn't connect to server
%
The problem only happens with VPN enabled, I mentioned it before. The VPN in question is Cisco secure client, aka AnyConnect. I'm working with people who manage the Cisco VPN for us to see if they can change anything on their side (AnyConnect is supposed to be server side controlled, so not much can be done on the client side).
@rsc I get the same issue when trying to install things using 1.22.6 on my MacBook while on our corporate VPN (which is also Cisco AnyConnect).
My testing reveals there are two underlying issues:
Increasing the dialer's FallbackDelay
(or making it negative) is enough to resolve the issue, but I have no control over what go install
is doing. Would it be possible to allow overriding the 300 ms default via some env var?
Go version
go version go1.22.4 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
Trying to fetch a random module (all break the same):
Machine has IPv6 disabled:
What did you see happen?
Go get is unable to fetch a module because it's using a wrong proxy address.
What did you expect to see?
Go get should be able to fetch a module.