mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-05-15 00:50:25 +02:00
all: spoof loopback ranges in client info
Sending them are useless, so using RFC1918 address instead.
This commit is contained in:
committed by
Cuong Manh Le
parent
44ba6aadd9
commit
63f959c951
@@ -573,9 +573,23 @@ func (p *prog) getClientInfo(remoteIP string, msg *dns.Msg) *ctrld.ClientInfo {
|
||||
ci.Hostname = p.ciTable.LookupHostname(ci.IP, ci.Mac)
|
||||
}
|
||||
ci.Self = queryFromSelf(ci.IP)
|
||||
p.spoofLoopbackIpInClientInfo(ci)
|
||||
return ci
|
||||
}
|
||||
|
||||
// spoofLoopbackIpInClientInfo replaces loopback IPs in client info.
|
||||
//
|
||||
// - Preference IPv4.
|
||||
// - Preference RFC1918.
|
||||
func (p *prog) spoofLoopbackIpInClientInfo(ci *ctrld.ClientInfo) {
|
||||
if ip := net.ParseIP(ci.IP); ip == nil || !ip.IsLoopback() {
|
||||
return
|
||||
}
|
||||
if ip := p.ciTable.LookupRFC1918IPv4(ci.Mac); ip != "" {
|
||||
ci.IP = ip
|
||||
}
|
||||
}
|
||||
|
||||
// queryFromSelf reports whether the input IP is from device running ctrld.
|
||||
func queryFromSelf(ip string) bool {
|
||||
netIP := netip.MustParseAddr(ip)
|
||||
|
||||
Reference in New Issue
Block a user