From 8f09aa04447c110874445443ba4e2844c111af90 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Fri, 26 Feb 2021 10:40:55 +0800 Subject: [PATCH] Chore: reset udp timeout after sending each packet (#1260) --- tunnel/connection.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tunnel/connection.go b/tunnel/connection.go index b3554a47..5d46eb58 100644 --- a/tunnel/connection.go +++ b/tunnel/connection.go @@ -104,8 +104,13 @@ func handleUDPToRemote(packet C.UDPPacket, pc C.PacketConn, metadata *C.Metadata return errors.New("udp addr invalid") } - _, err := pc.WriteTo(packet.Data(), addr) - return err + if _, err := pc.WriteTo(packet.Data(), addr); err != nil { + return err + } + // reset timeout + pc.SetReadDeadline(time.Now().Add(udpTimeout)) + + return nil } func handleUDPToLocal(packet C.UDPPacket, pc net.PacketConn, key string, fAddr net.Addr) {