Use correct address for packets from localRelayConn

This commit is contained in:
Toby 2021-04-21 17:08:01 -07:00
parent 51abb06911
commit 3b6a2bc56e

View File

@ -327,10 +327,13 @@ func (s *Server) udpServer(clientConn *net.UDPConn, localRelayConn *net.UDPConn,
go func() { go func() {
buf := make([]byte, udpBufferSize) buf := make([]byte, udpBufferSize)
for { for {
n, _, err := localRelayConn.ReadFrom(buf) n, from, err := localRelayConn.ReadFrom(buf)
if n > 0 { if n > 0 {
d := socks5.NewDatagram(socks5.ATYPIPv4, atyp, addr, port, err := socks5.ParseAddress(from.String())
[]byte{0x00, 0x00, 0x00, 0x00}, []byte{0x00, 0x00}, buf[:n]) if err != nil {
continue
}
d := socks5.NewDatagram(atyp, addr, port, buf[:n])
_, _ = clientConn.WriteToUDP(d.Bytes(), clientAddr) _, _ = clientConn.WriteToUDP(d.Bytes(), clientAddr)
} }
if err != nil { if err != nil {