mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-06 01:07:03 +08:00
Feature: add an option to set udp timeout
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/xjasonlyu/tun2socks/log"
|
||||
"github.com/xjasonlyu/tun2socks/proxy"
|
||||
"github.com/xjasonlyu/tun2socks/stats"
|
||||
"github.com/xjasonlyu/tun2socks/tunnel"
|
||||
)
|
||||
|
||||
var _engine = &engine{}
|
||||
@@ -30,15 +31,16 @@ func Insert(k *Key) {
|
||||
}
|
||||
|
||||
type Key struct {
|
||||
MTU int
|
||||
Mark int
|
||||
Proxy string
|
||||
Stats string
|
||||
Token string
|
||||
Device string
|
||||
LogLevel string
|
||||
Interface string
|
||||
Version bool
|
||||
MTU int
|
||||
Mark int
|
||||
UDPTimeout int
|
||||
Proxy string
|
||||
Stats string
|
||||
Token string
|
||||
Device string
|
||||
LogLevel string
|
||||
Interface string
|
||||
Version bool
|
||||
}
|
||||
|
||||
type engine struct {
|
||||
@@ -64,6 +66,7 @@ func (e *engine) start() error {
|
||||
e.setMark,
|
||||
e.setInterface,
|
||||
e.setStats,
|
||||
e.setUDPTimeout,
|
||||
e.setProxy,
|
||||
e.setDevice,
|
||||
e.setStack,
|
||||
@@ -123,6 +126,13 @@ func (e *engine) setStats() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *engine) setUDPTimeout() error {
|
||||
if e.UDPTimeout > 0 {
|
||||
tunnel.SetUDPTimeout(e.UDPTimeout)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *engine) setProxy() (err error) {
|
||||
if e.Proxy == "" {
|
||||
return errors.New("empty proxy")
|
||||
|
Reference in New Issue
Block a user