1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-05 11:17:03 +00:00

- fixing incorrect IP comparison. unsafeCompare was comparing between converted IP address with IP string.

- `IPInRange` should be both inclusive to accommodate /32 private subnet additions
- added more tests
This commit is contained in:
Muhammad Iqbal Alaydrus
2022-11-22 17:31:22 +07:00
parent 6a49bc8315
commit 5db7ea1732
2 changed files with 31 additions and 7 deletions

View File

@@ -58,4 +58,34 @@ func TestIP(t *testing.T) {
if expected := "126.105.144.250"; expected != got {
t.Logf("expected addr to be found: %s but got: %s", expected, got)
}
addresses = []string{
"10.10.233.1",
"126.105.144.250",
"192.168.99.33",
"172.18.22.23",
"10.0.0.0",
"10.255.255.255",
}
got, ok = GetIPAddress(addresses, privateRanges)
if !ok {
t.Logf("expected addr to be matched")
}
if expected := "126.105.144.250"; expected != got {
t.Logf("expected addr to be found: %s but got: %s", expected, got)
}
addresses = []string{
"10.0.0.0",
"10.10.233.1",
"192.168.99.33",
"172.18.22.23",
}
got, ok = GetIPAddress(addresses, privateRanges)
if ok {
t.Logf("expected addr to not be matched")
}
}