From 17ecf10f79160f384531bc2bca476536bca23946 Mon Sep 17 00:00:00 2001 From: Anton Zadvorny Date: Sat, 10 Jul 2021 11:32:55 +0300 Subject: [PATCH] Fix WriteTo length --- udp.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/udp.go b/udp.go index f5fe64b..02dbfda 100644 --- a/udp.go +++ b/udp.go @@ -47,7 +47,13 @@ func (s *UDPConn) WriteTo(b []byte, addr net.Addr) (int, error) { atyp, host, port := socksAddr.Socks() datagram := NewDatagram(atyp, host, port, b) - return s.PacketConn.WriteTo(datagram.Bytes(), s.ServerAddr) + + n, err := s.PacketConn.WriteTo(datagram.Bytes(), s.ServerAddr) + if n < 10 { + n = 10 + } + + return n - 10, err } func (s *UDPConn) Write(b []byte) (int, error) {