Fix: satisfy RFC4343 - DNS case insensitivity (#2260)

This commit is contained in:
bobo liu
2022-08-12 13:47:51 +08:00
committed by GitHub
parent 50105f0559
commit 71cad51e8f
2 changed files with 25 additions and 0 deletions

View File

@ -75,6 +75,27 @@ func TestPool_Basic(t *testing.T) {
}
}
func TestPool_Case_Insensitive(t *testing.T) {
_, ipnet, _ := net.ParseCIDR("192.168.0.1/29")
pools, tempfile, err := createPools(Options{
IPNet: ipnet,
Size: 10,
})
assert.Nil(t, err)
defer os.Remove(tempfile)
for _, pool := range pools {
first := pool.Lookup("foo.com")
last := pool.Lookup("Foo.Com")
foo, exist := pool.LookBack(last)
assert.True(t, first.Equal(pool.Lookup("Foo.Com")))
assert.Equal(t, pool.Lookup("fOo.cOM"), first)
assert.True(t, exist)
assert.Equal(t, foo, "foo.com")
}
}
func TestPool_CycleUsed(t *testing.T) {
_, ipnet, _ := net.ParseCIDR("192.168.0.1/29")
pools, tempfile, err := createPools(Options{