all: spoof loopback ranges in client info

Sending them are useless, so using RFC1918 address instead.
This commit is contained in:
Cuong Manh Le
2023-10-27 22:53:15 +07:00
committed by Cuong Manh Le
parent 44ba6aadd9
commit 63f959c951
3 changed files with 48 additions and 0 deletions
+19
View File
@@ -25,3 +25,22 @@ func Test_normalizeIP(t *testing.T) {
})
}
}
func TestTable_LookupRFC1918IPv4(t *testing.T) {
table := &Table{
dhcp: &dhcp{},
arp: &arpDiscover{},
}
table.ipResolvers = append(table.ipResolvers, table.dhcp)
table.ipResolvers = append(table.ipResolvers, table.arp)
macAddress := "cc:19:f9:8a:49:e6"
rfc1918IPv4 := "10.0.10.245"
table.dhcp.ip.Store(macAddress, "127.0.0.1")
table.arp.ip.Store(macAddress, rfc1918IPv4)
if got := table.LookupRFC1918IPv4(macAddress); got != rfc1918IPv4 {
t.Fatalf("unexpected result, want: %s, got: %s", rfc1918IPv4, got)
}
}