Chore: reset udp timeout after sending each packet (#1260)

This commit is contained in:
Jason Lyu 2021-02-26 10:40:55 +08:00 committed by GitHub
parent f63c9eb22f
commit f53686103d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)
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) {