cmd/ctrld: do not mutual net.Addr when spoofing client source IP

Otherwise, the original address will be overwritten, causing the
connection between the listener and dnsmasq broken.
This commit is contained in:
Cuong Manh Le
2023-06-02 21:16:49 +07:00
committed by Cuong Manh Le
parent bbfa7c6c22
commit a46bb152af

View File

@@ -423,9 +423,19 @@ func spoofRemoteAddr(addr net.Addr, ci *ctrld.ClientInfo) net.Addr {
if ci != nil && ci.IP != "" {
switch addr := addr.(type) {
case *net.UDPAddr:
addr.IP = net.ParseIP(ci.IP)
udpAddr := &net.UDPAddr{
IP: net.ParseIP(ci.IP),
Port: addr.Port,
Zone: addr.Zone,
}
return udpAddr
case *net.TCPAddr:
addr.IP = net.ParseIP(ci.IP)
udpAddr := &net.TCPAddr{
IP: net.ParseIP(ci.IP),
Port: addr.Port,
Zone: addr.Zone,
}
return udpAddr
}
}
return addr