net: Resolver doesn't use provided Dial function in all cases #60712
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
The
net.Resolver
accepts an optionalDial
function that says the following:I created a script that logs
Dial
calls when using the pure Go resolver: https://go.dev/play/p/0O_ARZyK2eGIf I run this script locally, I see something like this:
However, if I run the script with strace, I see that Go is making additional connections some other way:
There's is one hardcoded call to
net.DialUDP
here which appears to be the source of the additional connections.What did you expect to see?
I expect to see the
Dial
function used for all connections made by the pure Go resolver.What did you see instead?
I see that the
Dial
function is only used in some cases.Additional context
CL 500576 fixes the issue by using
net.Resolver.Dial
in all cases.For context, this change is important for targets with limited networking capabilities (e.g.
GOOS=wasip1
). It means that users can provide their ownDial
function to make use of the pure Go resolver. At the moment the hardcodednet.DialUDP
call makes the pure Go resolver off limits for these targets.There was some concern in the CL about whether making this change for all targets would break code in the wild. I'm submitting it as a bug report so we can discuss here instead.
cc
GOOS=wasip1
maintainers: @achille-roussel @johanbrandhorst @Pryzcc those that commented on CL 500576: @mateusz834 @ianlancetaylor
The text was updated successfully, but these errors were encountered: