From 6a53c52167fd229f754929d031fd9e3185682020 Mon Sep 17 00:00:00 2001 From: xjasonlyu Date: Sun, 3 Apr 2022 22:09:41 +0800 Subject: [PATCH] Chore: add udp-timeout constraint --- engine/engine.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engine/engine.go b/engine/engine.go index 017ff09..3f82c86 100644 --- a/engine/engine.go +++ b/engine/engine.go @@ -5,6 +5,7 @@ import ( "fmt" "net" "sync" + "time" "github.com/xjasonlyu/tun2socks/v2/component/dialer" "github.com/xjasonlyu/tun2socks/v2/core" @@ -113,6 +114,9 @@ func general(k *Key) error { } if k.UDPTimeout > 0 { + if k.UDPTimeout < time.Second { + return errors.New("invalid udp timeout value") + } tunnel.SetUDPTimeout(k.UDPTimeout) } return nil