Closed
Description
What version of Go are you using (go version
)?
$ go version go version go1.12.7 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GOARCH="amd64" GOBIN="" GOCACHE="/Users/moloch/Library/Caches/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/moloch/go" GOPROXY="" GORACE="" GOROOT="/usr/local/opt/go/libexec" GOTMPDIR="" GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64" GCCGO="gccgo" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/n3/b920qr2s0wj9h9z0hyj678vr0000gn/T/go-build549888698=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
Attempting to cross-compile a Windows binary from MacOS that does DNS-over-TCP, to do this I implemented a custom dialer that uses TCP (code excerpt is below). The dialer is ignored and the program still performs DNS resolution over UDP (verified with Wireshark), and does not return any errors. Setting preferGo
to true
or false
does not appear to have any affect. Note that while I'm compiling on my Mac (version/env info above) the code is running on Windows.
func dnsTCPLookup(resolverIP string, domain string) (string, error) {
tcpResolver := net.Resolver{
PreferGo: true,
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
log.Printf("CUSTOM DIALER CALLED\n")
dialer := net.Dialer{}
return dialer.DialContext(ctx, "tcp", fmt.Sprintf("%s:53", resolverIP))
},
}
log.Printf("[dns] lookup -> %s", domain)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
txts, err := tcpResolver.LookupTXT(ctx, domain)
if err != nil || len(txts) == 0 {
log.Printf("[!] failure -> %s", domain)
return "", err
}
return strings.Join(txts, ""), nil
}
CUSTOM DIALER CALLED
is not log'd.
What did you expect to see?
Go attempt to establish a connection using the provided TCP Dialer, log.Printf statement, or an error.
What did you see instead?
DNS resolution over UDP, no errors.