proxy: optimize timeout handling in udp copy

This commit is contained in:
nadoo committed 2022-02-26 22:32:11 +08:00
1 parent 4b313a3fe1
commit 2ad3498abd
15 files changed
+46 -41

No files matched your search

+1 -1
View File
@@ -35,7 +35,7 @@ func (pc *PktConn) ReadFrom(b []byte) (int, net.Addr, error) {
return 0, nil, err
}
// TODO: we know that we use it in proxy.RelayUDP and the length of b is enough, check it later.
// TODO: we know that we use it in proxy.CopyUDP and the length of b is enough, check it later.
if len(b) < 2 {
return 0, nil, errors.New("buf size is not enough")
}
+2 -2
View File
@@ -210,6 +210,6 @@ func (s *Trojan) ServeUoT(c net.Conn, tgt socks.Addr) {
pc := NewPktConn(c, tgt)
log.F("[trojan] %s <-tcp-> %s - %s <-udp-> %s", c.RemoteAddr(), c.LocalAddr(), rc.LocalAddr(), tgt)
go proxy.RelayUDP(rc, tgtAddr, pc, 2*time.Minute)
proxy.RelayUDP(pc, nil, rc, 2*time.Minute)
go proxy.CopyUDP(rc, tgtAddr, pc, 2*time.Minute, 5*time.Second)
proxy.CopyUDP(pc, nil, rc, 2*time.Minute, 5*time.Second)
}