mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
Add dns64 plugin (#3534)
* Add dns64 plugin Add external plugin to core in-tree. * Pull code from upstream: https://github.com/serverwentdown/dns64 * Update docs. Signed-off-by: Ben Kochie <superq@gmail.com> * Make dns64 consistent. Signed-off-by: Ben Kochie <superq@gmail.com> * Cleanup README Signed-off-by: Ben Kochie <superq@gmail.com> * Cleanup minor issues. Signed-off-by: Ben Kochie <superq@gmail.com> * Remove proxy method. Signed-off-by: Ben Kochie <superq@gmail.com> * dns64: big cleanup * Make the code a bit more idiomatic * Add tests * use proper Upstream API Signed-off-by: Casey Callendrello <c1@caseyc.net> Signed-off-by: Ben Kochie <superq@gmail.com> * A little more clenaup * Fix some docs. * Use the correct plugin register method. * Cleanup some review items. Signed-off-by: Ben Kochie <superq@gmail.com> * Add metrics counter for DNS64 translations Add a basic counter of how many DNS64 translations have been completed. Signed-off-by: Ben Kochie <superq@gmail.com> * Add DNSSEC bug link Signed-off-by: Ben Kochie <superq@gmail.com> * Test cleanup Signed-off-by: Ben Kochie <superq@gmail.com> * dns64: more test cleanup Signed-off-by: Casey Callendrello <c1@caseyc.net> Co-authored-by: Casey Callendrello <c1@caseyc.net>
This commit is contained in:
126
plugin/dns64/setup_test.go
Normal file
126
plugin/dns64/setup_test.go
Normal file
@@ -0,0 +1,126 @@
|
||||
package dns64
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/caddyserver/caddy"
|
||||
)
|
||||
|
||||
func TestSetupDns64(t *testing.T) {
|
||||
tests := []struct {
|
||||
inputUpstreams string
|
||||
shouldErr bool
|
||||
prefix string
|
||||
}{
|
||||
{
|
||||
`dns64`,
|
||||
false,
|
||||
"64:ff9b::/96",
|
||||
},
|
||||
{
|
||||
`dns64 64:dead::/96`,
|
||||
false,
|
||||
"64:dead::/96",
|
||||
},
|
||||
{
|
||||
`dns64 {
|
||||
translate_all
|
||||
}`,
|
||||
false,
|
||||
"64:ff9b::/96",
|
||||
},
|
||||
{
|
||||
`dns64`,
|
||||
false,
|
||||
"64:ff9b::/96",
|
||||
},
|
||||
{
|
||||
`dns64 {
|
||||
prefix 64:ff9b::/96
|
||||
}`,
|
||||
false,
|
||||
"64:ff9b::/96",
|
||||
},
|
||||
{
|
||||
`dns64 {
|
||||
prefix 64:ff9b::/32
|
||||
}`,
|
||||
false,
|
||||
"64:ff9b::/32",
|
||||
},
|
||||
{
|
||||
`dns64 {
|
||||
prefix 64:ff9b::/52
|
||||
}`,
|
||||
true,
|
||||
"64:ff9b::/52",
|
||||
},
|
||||
{
|
||||
`dns64 {
|
||||
prefix 64:ff9b::/104
|
||||
}`,
|
||||
true,
|
||||
"64:ff9b::/104",
|
||||
},
|
||||
{
|
||||
`dns64 {
|
||||
prefix 8.8.8.8/24
|
||||
}`,
|
||||
true,
|
||||
"8.8.9.9/24",
|
||||
},
|
||||
{
|
||||
`dns64 {
|
||||
prefix 64:ff9b::/96
|
||||
}`,
|
||||
false,
|
||||
"64:ff9b::/96",
|
||||
},
|
||||
{
|
||||
`dns64 {
|
||||
prefix 2002:ac12:b083::/96
|
||||
}`,
|
||||
false,
|
||||
"2002:ac12:b083::/96",
|
||||
},
|
||||
{
|
||||
`dns64 {
|
||||
prefix 2002:c0a8:a88a::/48
|
||||
}`,
|
||||
false,
|
||||
"2002:c0a8:a88a::/48",
|
||||
},
|
||||
{
|
||||
`dns64 foobar {
|
||||
prefix 64:ff9b::/96
|
||||
}`,
|
||||
true,
|
||||
"64:ff9b::/96",
|
||||
},
|
||||
{
|
||||
`dns64 foobar`,
|
||||
true,
|
||||
"64:ff9b::/96",
|
||||
},
|
||||
{
|
||||
`dns64 {
|
||||
foobar
|
||||
}`,
|
||||
true,
|
||||
"64:ff9b::/96",
|
||||
},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
c := caddy.NewTestController("dns", test.inputUpstreams)
|
||||
dns64, err := dns64Parse(c)
|
||||
if (err != nil) != test.shouldErr {
|
||||
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())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user