mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-04 01:07:49 +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
@@ -241,6 +241,21 @@ func (t *Table) LookupHostname(ip, mac string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// LookupRFC1918IPv4 returns the RFC1918 IPv4 address for the given MAC address, if any.
|
||||
func (t *Table) LookupRFC1918IPv4(mac string) string {
|
||||
t.initOnce.Do(t.init)
|
||||
for _, r := range t.ipResolvers {
|
||||
ip, err := netip.ParseAddr(r.LookupIP(mac))
|
||||
if err != nil || ip.Is6() {
|
||||
continue
|
||||
}
|
||||
if ip.IsPrivate() {
|
||||
return ip.String()
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type macEntry struct {
|
||||
mac string
|
||||
src string
|
||||
|
||||
Reference in New Issue
Block a user