// actually be for circular dependency reasons.
DNSDone func(netIPs []interface{}, coalesced bool, err error)
- // ConnectStart is called before a Dial. In the case of
- // DualStack (Happy Eyeballs) dialing, this may be called
- // multiple times, from multiple goroutines.
+ // ConnectStart is called before a TCPAddr or UnixAddr
+ // Dial. In the case of DualStack (Happy Eyeballs) dialing,
+ // this may be called multiple times, from multiple
+ // goroutines.
ConnectStart func(network, addr string)
- // ConnectStart is called after a Dial with the results. It
- // may also be called multiple times, like ConnectStart.
+ // ConnectStart is called after a TCPAddr or UnixAddr Dial
+ // with the results. It may also be called multiple times,
+ // like ConnectStart.
ConnectDone func(network, addr string, err error)
}
return nil, firstErr
}
+// traceDialType reports whether ra is an address type for which
+// nettrace.Trace should trace.
+func traceDialType(ra Addr) bool {
+ switch ra.(type) {
+ case *TCPAddr, *UnixAddr:
+ return true
+ }
+ return false
+}
+
// dialSingle attempts to establish and returns a single connection to
// the destination address.
func dialSingle(ctx context.Context, dp *dialParam, ra Addr) (c Conn, err error) {
trace, _ := ctx.Value(nettrace.TraceKey{}).(*nettrace.Trace)
- if trace != nil {
+ if trace != nil && traceDialType(ra) {
raStr := ra.String()
if trace.ConnectStart != nil {
trace.ConnectStart(dp.network, raStr)
wantSub("Getting conn for dns-is-faked.golang:" + port)
wantSub("DNS start: {Host:dns-is-faked.golang}")
wantSub("DNS done: {Addrs:[{IP:" + ip + " Zone:}] Err:<nil> Coalesced:false}")
+ wantSub("Connecting to tcp " + ts.Listener.Addr().String())
wantSub("connected to tcp " + ts.Listener.Addr().String() + " = <nil>")
wantSub("Reused:false WasIdle:false IdleTime:0s")
wantSub("first response byte")
wantSub("WroteRequest: {Err:<nil>}")
wantSub("Wait100Continue")
wantSub("Got100Continue")
+ if strings.Contains(got, " to udp ") {
+ t.Errorf("should not see UDP (DNS) connections")
+ }
if t.Failed() {
t.Errorf("Output:\n%s", got)
}