mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-09-29 13:51:51 +02:00
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:
1 parent
bbfa7c6c22
commit
a46bb152af
1 file changed
+12
-2
+12
-2
@@ -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
|
||||||
|
|||||||
Reference in new issue
Block a user