plugin/dns64 : add support for DNS requests over IPv4 network (#4809)

This commit is contained in:
Ondřej Benkovský
2022-01-07 17:16:23 +01:00
committed by GitHub
parent 39a99a5bbe
commit b546031f9b
5 changed files with 106 additions and 9 deletions

View File

@@ -10,17 +10,20 @@ func TestSetupDns64(t *testing.T) {
tests := []struct {
inputUpstreams string
shouldErr bool
prefix string
wantPrefix string
wantAllowIpv4 bool
}{
{
`dns64`,
false,
"64:ff9b::/96",
false,
},
{
`dns64 64:dead::/96`,
false,
"64:dead::/96",
false,
},
{
`dns64 {
@@ -28,11 +31,13 @@ func TestSetupDns64(t *testing.T) {
}`,
false,
"64:ff9b::/96",
false,
},
{
`dns64`,
false,
"64:ff9b::/96",
false,
},
{
`dns64 {
@@ -40,6 +45,7 @@ func TestSetupDns64(t *testing.T) {
}`,
false,
"64:ff9b::/96",
false,
},
{
`dns64 {
@@ -47,6 +53,7 @@ func TestSetupDns64(t *testing.T) {
}`,
false,
"64:ff9b::/32",
false,
},
{
`dns64 {
@@ -54,6 +61,7 @@ func TestSetupDns64(t *testing.T) {
}`,
true,
"64:ff9b::/52",
false,
},
{
`dns64 {
@@ -61,6 +69,7 @@ func TestSetupDns64(t *testing.T) {
}`,
true,
"64:ff9b::/104",
false,
},
{
`dns64 {
@@ -68,6 +77,7 @@ func TestSetupDns64(t *testing.T) {
}`,
true,
"8.8.9.9/24",
false,
},
{
`dns64 {
@@ -75,6 +85,7 @@ func TestSetupDns64(t *testing.T) {
}`,
false,
"64:ff9b::/96",
false,
},
{
`dns64 {
@@ -82,6 +93,7 @@ func TestSetupDns64(t *testing.T) {
}`,
false,
"2002:ac12:b083::/96",
false,
},
{
`dns64 {
@@ -89,6 +101,7 @@ func TestSetupDns64(t *testing.T) {
}`,
false,
"2002:c0a8:a88a::/48",
false,
},
{
`dns64 foobar {
@@ -96,11 +109,13 @@ func TestSetupDns64(t *testing.T) {
}`,
true,
"64:ff9b::/96",
false,
},
{
`dns64 foobar`,
true,
"64:ff9b::/96",
false,
},
{
`dns64 {
@@ -108,6 +123,15 @@ func TestSetupDns64(t *testing.T) {
}`,
true,
"64:ff9b::/96",
false,
},
{
`dns64 {
allow_ipv4
}`,
false,
"64:ff9b::/96",
true,
},
}
@@ -118,8 +142,11 @@ func TestSetupDns64(t *testing.T) {
t.Errorf("Test %d expected %v error, got %v for %s", i+1, test.shouldErr, err, test.inputUpstreams)
}
if err == nil {
if dns64.Prefix.String() != test.prefix {
t.Errorf("Test %d expected prefix %s, got %v", i+1, test.prefix, dns64.Prefix.String())
if dns64.Prefix.String() != test.wantPrefix {
t.Errorf("Test %d expected prefix %s, got %v", i+1, test.wantPrefix, dns64.Prefix.String())
}
if dns64.AllowIPv4 != test.wantAllowIpv4 {
t.Errorf("Test %d expected prefix %v, got %v", i+1, test.wantAllowIpv4, dns64.AllowIPv4)
}
}
}