tfo_unix.go 592 B

12345678910111213141516171819202122232425
  1. //go:build unix
  2. package dialer
  3. import (
  4. "context"
  5. "net"
  6. "github.com/metacubex/tfo-go"
  7. )
  8. const DisableTFO = false
  9. func dialTFO(ctx context.Context, netDialer net.Dialer, network, address string) (net.Conn, error) {
  10. ctx, cancel := context.WithTimeout(context.Background(), DefaultTCPTimeout)
  11. dialer := tfo.Dialer{Dialer: netDialer, DisableTFO: false}
  12. return &tfoConn{
  13. dialed: make(chan bool, 1),
  14. cancel: cancel,
  15. ctx: ctx,
  16. dialFn: func(ctx context.Context, earlyData []byte) (net.Conn, error) {
  17. return dialer.DialContext(ctx, network, address, earlyData)
  18. },
  19. }, nil
  20. }