diff --git a/proxy/socks5/client.go b/proxy/socks5/client.go index e79a07d..ddd20bd 100644 --- a/proxy/socks5/client.go +++ b/proxy/socks5/client.go @@ -86,9 +86,20 @@ func (s *Socks5) DialUDP(network, addr string) (pc net.PacketConn, writeTo net.A return nil, nil, err } - pc, nextHop, err := s.dialer.DialUDP(network, uAddr.String()) + var uAddress string + h, p, _ := net.SplitHostPort(uAddr.String()) + // if returned bind ip is unspecified + if ip := net.ParseIP(h); ip != nil && ip.IsUnspecified() { + // indicate using conventional addr + h, _, _ = net.SplitHostPort(s.addr) + uAddress = net.JoinHostPort(h, p) + } else { + uAddress = uAddr.String() + } + + pc, nextHop, err := s.dialer.DialUDP(network, uAddress) if err != nil { - log.F("[socks5] dialudp to %s error: %s", uAddr.String(), err) + log.F("[socks5] dialudp to %s error: %s", uAddress, err) return nil, nil, err }