Browse Source

Change: udp timeout = time.Duration

pull/133/head
xjasonlyu 3 years ago
parent
commit
31e19a0690
  1. 24
      engine/key.go
  2. 2
      main.go
  3. 4
      tunnel/udp.go

24
engine/key.go

@ -1,15 +1,17 @@
package engine
import "time"
type Key struct {
MTU int `yaml:"mtu"`
Mark int `yaml:"fwmark"`
UDPTimeout int `yaml:"udp-timeout"`
Proxy string `yaml:"proxy"`
RestAPI string `yaml:"restapi"`
Device string `yaml:"device"`
LogLevel string `yaml:"loglevel"`
Interface string `yaml:"interface"`
TCPModerateReceiveBuffer bool `yaml:"tcp-moderate-receive-buffer"`
TCPSendBufferSize string `yaml:"tcp-send-buffer-size"`
TCPReceiveBufferSize string `yaml:"tcp-receive-buffer-size"`
MTU int `yaml:"mtu"`
Mark int `yaml:"fwmark"`
Proxy string `yaml:"proxy"`
RestAPI string `yaml:"restapi"`
Device string `yaml:"device"`
LogLevel string `yaml:"loglevel"`
Interface string `yaml:"interface"`
TCPModerateReceiveBuffer bool `yaml:"tcp-moderate-receive-buffer"`
TCPSendBufferSize string `yaml:"tcp-send-buffer-size"`
TCPReceiveBufferSize string `yaml:"tcp-receive-buffer-size"`
UDPTimeout time.Duration `yaml:"udp-timeout"`
}

2
main.go

@ -26,7 +26,7 @@ var (
func init() {
flag.IntVar(&key.Mark, "fwmark", 0, "Set firewall MARK (Linux only)")
flag.IntVar(&key.MTU, "mtu", 0, "Set device maximum transmission unit (MTU)")
flag.IntVar(&key.UDPTimeout, "udp-timeout", 0, "Set timeout for each UDP session")
flag.DurationVar(&key.UDPTimeout, "udp-timeout", 0, "Set timeout for each UDP session")
flag.StringVar(&configFile, "config", "", "YAML format configuration file")
flag.StringVar(&key.Device, "device", "", "Use this device [driver://]name")
flag.StringVar(&key.Interface, "interface", "", "Use network INTERFACE (Linux/MacOS only)")

4
tunnel/udp.go

@ -17,8 +17,8 @@ import (
// _udpSessionTimeout is the default timeout for each UDP session.
var _udpSessionTimeout = 60 * time.Second
func SetUDPTimeout(v int) {
_udpSessionTimeout = time.Duration(v) * time.Second
func SetUDPTimeout(t time.Duration) {
_udpSessionTimeout = t
}
func newUDPTracker(conn net.PacketConn, metadata *M.Metadata) net.PacketConn {

Loading…
Cancel
Save