Skip to content

Commit

Permalink
Chore: reset udp timeout after sending each packet (#1260)
Browse files Browse the repository at this point in the history
  • Loading branch information
xjasonlyu authored Feb 26, 2021
1 parent f63c9eb commit f536861
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tunnel/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit f536861

Please sign in to comment.