From aa1001f024071d9b4dbe9103141b703dbc22bc54 Mon Sep 17 00:00:00 2001 From: Vinicius Fortuna Date: Tue, 31 Jan 2023 19:21:08 -0600 Subject: [PATCH] Increase the UDP timeout This may address some issues with UDP. Fixes https://github.com/Jigsaw-Code/outline-go-tun2socks/issues/109. --- outline/tunnel.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/outline/tunnel.go b/outline/tunnel.go index 49cd142..f0cd519 100644 --- a/outline/tunnel.go +++ b/outline/tunnel.go @@ -81,7 +81,10 @@ func (t *outlinetunnel) UpdateUDPSupport() bool { func (t *outlinetunnel) registerConnectionHandlers() { var udpHandler core.UDPConnHandler if t.isUDPEnabled { - udpHandler = oss.NewUDPHandler(t.client, 30*time.Second) + // Tun2socks will supposedly call udpHandler.Close() when the app socket is no longer needed. + // However, we set a timeout to be safe. A UDP NAT timeout of at least 5 minutes is recommended + // in RFC 4787 Section 4.3. + udpHandler = oss.NewUDPHandler(t.client, 5*time.Minute) } else { udpHandler = dnsfallback.NewUDPHandler() }