Projects STRLCPY tun2socks Commits 20499c64
🤬
  • Revert: cli tcp-wait-timeout option

    This reverts commit 2c51a656858b264b6968e3591c4d227725df7d99.
  • Loading...
  • xjasonlyu committed 1 year ago
    20499c64
    1 parent ad522ebb
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    engine/engine.go
    skipped 122 lines
    123 123   log.Infof("[DIALER] set fwmark: %#x", k.Mark)
    124 124   }
    125 125   
    126  - if k.TCPWaitTimeout > 0 {
    127  - tunnel.SetTCPWaitTimeout(k.TCPWaitTimeout)
    128  - }
    129  - 
    130 126   if k.UDPTimeout > 0 {
    131 127   if k.UDPTimeout < time.Second {
    132 128   return errors.New("invalid udp timeout value")
    skipped 104 lines
  • ■ ■ ■ ■ ■
    engine/key.go
    skipped 12 lines
    13 13   TCPModerateReceiveBuffer bool `yaml:"tcp-moderate-receive-buffer"`
    14 14   TCPSendBufferSize string `yaml:"tcp-send-buffer-size"`
    15 15   TCPReceiveBufferSize string `yaml:"tcp-receive-buffer-size"`
    16  - TCPWaitTimeout time.Duration `yaml:"tcp-wait-timeout"`
    17  - UDPTimeout time.Duration `yaml:"udp-timeout"`
    18 16   TUNPreUp string `yaml:"tun-pre-up"`
    19 17   TUNPostUp string `yaml:"tun-post-up"`
     18 + UDPTimeout time.Duration `yaml:"udp-timeout"`
    20 19  }
    21 20   
  • ■ ■ ■ ■ ■
    main.go
    skipped 35 lines
    36 36   flag.StringVar(&key.TCPSendBufferSize, "tcp-sndbuf", "", "Set TCP send buffer size for netstack")
    37 37   flag.StringVar(&key.TCPReceiveBufferSize, "tcp-rcvbuf", "", "Set TCP receive buffer size for netstack")
    38 38   flag.BoolVar(&key.TCPModerateReceiveBuffer, "tcp-auto-tuning", false, "Enable TCP receive buffer auto-tuning")
    39  - flag.DurationVar(&key.TCPWaitTimeout, "tcp-wait-timeout", 0, "Set timeout before closing each TCP connection")
    40 39   flag.StringVar(&key.TUNPreUp, "tun-pre-up", "", "Execute a command before TUN device setup")
    41 40   flag.StringVar(&key.TUNPostUp, "tun-post-up", "", "Execute a command after TUN device setup")
    42 41   flag.BoolVar(&versionFlag, "version", false, "Show version and then quit")
    skipped 32 lines
  • ■ ■ ■ ■ ■ ■
    tunnel/tcp.go
    skipped 14 lines
    15 15   "github.com/xjasonlyu/tun2socks/v2/tunnel/statistic"
    16 16  )
    17 17   
    18  -// _tcpWaitTimeout is the default timeout to wait after closing each TCP connection.
    19  -var _tcpWaitTimeout = 5 * time.Second
    20  - 
    21  -func SetTCPWaitTimeout(t time.Duration) {
    22  - _tcpWaitTimeout = t
    23  -}
     18 +const (
     19 + // tcpWaitTimeout implements a TCP half-close timeout.
     20 + tcpWaitTimeout = 60 * time.Second
     21 +)
    24 22   
    25 23  func handleTCPConn(originConn adapter.TCPConn) {
    26 24   defer originConn.Close()
    skipped 35 lines
    62 60   if err := copyBuffer(remote, origin); err != nil {
    63 61   leftErr = errors.Join(leftErr, err)
    64 62   }
    65  - remote.SetReadDeadline(time.Now().Add(_tcpWaitTimeout))
     63 + remote.SetReadDeadline(time.Now().Add(tcpWaitTimeout))
    66 64   }()
    67 65   
    68 66   go func() {
    skipped 1 lines
    70 68   if err := copyBuffer(origin, remote); err != nil {
    71 69   rightErr = errors.Join(rightErr, err)
    72 70   }
    73  - origin.SetReadDeadline(time.Now().Add(_tcpWaitTimeout))
     71 + origin.SetReadDeadline(time.Now().Add(tcpWaitTimeout))
    74 72   }()
    75 73   
    76 74   wg.Wait()
    skipped 11 lines
Please wait...
Page is in error, reload to recover