mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2024-12-30 02:37:01 +00:00
Change: udp timeout = time.Duration
This commit is contained in:
+13
-11
@@ -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"`
|
||||
}
|
||||
|
||||
@@ -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)")
|
||||
|
||||
+2
-2
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user