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 authored and Cuong Manh Le committed 2023-06-02 22:43:00 +07:00
1 parent bbfa7c6c22
commit a46bb152af
1 file changed
+12 -2
+12 -2
View File
@@ -423,9 +423,19 @@ func spoofRemoteAddr(addr net.Addr, ci *ctrld.ClientInfo) net.Addr {
if ci != nil && ci.IP != "" { if ci != nil && ci.IP != "" {
switch addr := addr.(type) { switch addr := addr.(type) {
case *net.UDPAddr: 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: 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 return addr