Projects STRLCPY tun2socks Commits b809f894
🤬
  • Revert: udp-rlybuf option

    As a low-level networking tool, tun2socks should be able to handle UDP packets of all possible sizes. This reverts commit fb9ca959095eb53c21bafd09676d58a32aca1eed.
  • Loading...
  • xjasonlyu committed 1 year ago
    b809f894
    1 parent b8ff1859
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    Dockerfile
    skipped 21 lines
    22 22  ENV MTU=9000
    23 23  ENV RESTAPI=
    24 24  ENV UDP_TIMEOUT=
    25  -ENV UDP_RLYBUF=
    26 25  ENV TCP_SNDBUF=
    27 26  ENV TCP_RCVBUF=
    28 27  ENV TCP_AUTO_TUNING=
    skipped 6 lines
  • ■ ■ ■ ■ ■ ■
    engine/engine.go
    skipped 132 lines
    133 133   }
    134 134   tunnel.SetUDPTimeout(k.UDPTimeout)
    135 135   }
    136  - 
    137  - if k.UDPRelayBufferSize != "" {
    138  - size, err := units.RAMInBytes(k.UDPRelayBufferSize)
    139  - if err != nil {
    140  - return err
    141  - }
    142  - tunnel.SetUDPRelayBufferSize(int(size))
    143  - }
    144 136   return nil
    145 137  }
    146 138   
    skipped 98 lines
  • ■ ■ ■ ■ ■
    engine/key.go
    skipped 13 lines
    14 14   TCPSendBufferSize string `yaml:"tcp-send-buffer-size"`
    15 15   TCPReceiveBufferSize string `yaml:"tcp-receive-buffer-size"`
    16 16   TCPWaitTimeout time.Duration `yaml:"tcp-wait-timeout"`
    17  - UDPRelayBufferSize string `yaml:"udp-relay-buffer-size"`
    18 17   UDPTimeout time.Duration `yaml:"udp-timeout"`
    19 18   TUNPreUp string `yaml:"tun-pre-up"`
    20 19   TUNPostUp string `yaml:"tun-post-up"`
    skipped 2 lines
  • ■ ■ ■ ■ ■
    main.go
    skipped 34 lines
    35 35   flag.StringVar(&key.RestAPI, "restapi", "", "HTTP statistic server listen address")
    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  - flag.StringVar(&key.UDPRelayBufferSize, "udp-rlybuf", "", "Set UDP relay buffer size for tunnel")
    39 38   flag.BoolVar(&key.TCPModerateReceiveBuffer, "tcp-auto-tuning", false, "Enable TCP receive buffer auto-tuning")
    40 39   flag.DurationVar(&key.TCPWaitTimeout, "tcp-wait-timeout", 0, "Set timeout before closing each TCP connection")
    41 40   flag.StringVar(&key.TUNPreUp, "tun-pre-up", "", "Execute a command before TUN device setup")
    skipped 34 lines
  • ■ ■ ■ ■ ■
    tunnel/udp.go
    skipped 14 lines
    15 15   "github.com/xjasonlyu/tun2socks/v2/tunnel/statistic"
    16 16  )
    17 17   
    18  -var (
    19  - // _udpSessionTimeout is the default timeout for each UDP session.
    20  - _udpSessionTimeout = 60 * time.Second
    21  - 
    22  - // _udpRelayBufferSize is the default size for UDP packets relay.
    23  - _udpRelayBufferSize = 16 << 10
    24  -)
     18 +// _udpSessionTimeout is the default timeout for each UDP session.
     19 +var _udpSessionTimeout = 60 * time.Second
    25 20   
    26 21  func SetUDPTimeout(t time.Duration) {
    27 22   _udpSessionTimeout = t
    28  -}
    29  - 
    30  -func SetUDPRelayBufferSize(size int) {
    31  - _udpRelayBufferSize = size
    32 23  }
    33 24   
    34 25  // TODO: Port Restricted NAT support.
    skipped 58 lines
    93 84  }
    94 85   
    95 86  func copyPacketBuffer(dst net.PacketConn, src net.PacketConn, to net.Addr, timeout time.Duration) error {
    96  - buf := pool.Get(_udpRelayBufferSize)
     87 + buf := pool.Get(pool.MaxSegmentSize)
    97 88   defer pool.Put(buf)
    98 89   
    99 90   for {
    skipped 44 lines
Please wait...
Page is in error, reload to recover