github.com/database64128/tfo-go/v2@v2.2.0/tfo_bsd+windows.go (about) 1 //go:build darwin || freebsd || windows 2 3 package tfo 4 5 import ( 6 "context" 7 "net" 8 ) 9 10 func (d *Dialer) dialTFO(ctx context.Context, network, address string, b []byte) (*net.TCPConn, error) { 11 if d.Fallback && runtimeDialTFOSupport.load() == dialTFOSupportNone { 12 return d.dialAndWriteTCPConn(ctx, network, address, b) 13 } 14 return d.dialTFOFromSocket(ctx, network, address, b) 15 } 16 17 func dialTCPAddr(network string, laddr, raddr *net.TCPAddr, b []byte) (*net.TCPConn, error) { 18 var d Dialer 19 d.SetMultipathTCP(false) // Align with [net.DialTCP]. 20 c, err := d.dialSingle(context.Background(), network, laddr, raddr, b, nil) 21 if err != nil { 22 return nil, &net.OpError{Op: "dial", Net: network, Source: laddr, Addr: raddr, Err: err} 23 } 24 c.SetKeepAlive(true) 25 c.SetKeepAlivePeriod(defaultTCPKeepAlive) 26 return c, nil 27 }