chore: move "disable TCP timeout for SOCKS5 UDP holder" out of the loop

This commit is contained in:
Toby 2022-02-20 23:48:34 -08:00
parent cea6052309
commit 52bcc1d57b

View File

@ -301,12 +301,12 @@ func (s *Server) handleUDP(c *net.TCPConn, r *socks5.Request) error {
_, _ = socks5.NewReply(socks5.RepSuccess, atyp, addr, port).WriteTo(c)
// Let UDP server do its job, we hold the TCP connection here
go s.udpServer(udpConn, localRelayConn, hyUDP)
if s.TCPTimeout != 0 {
// Disable TCP timeout for UDP holder
_ = c.SetDeadline(time.Time{})
}
buf := make([]byte, 1024)
for {
if s.TCPTimeout != 0 {
// Disable TCP timeout for UDP holder
_ = c.SetDeadline(time.Time{})
}
_, err := c.Read(buf)
if err != nil {
closeErr = err