mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 02:33:14 -04:00
Plugin/BIND - extend the syntax to allow multiple addresses (#1512)
* Extend bind to allow multiple addresses. UTs added. Changes the log for server starting, adding address when available * update readme for bind * fixes after review * minor fix on readme * accept multiple BIND directives in blocserver, consolidate the addresses * fixes after review - format logging server address, variable names
This commit is contained in:
committed by
Miek Gieben
parent
a0834b1dd5
commit
76455c6a0d
@@ -63,3 +63,48 @@ func TestNormalizeZoneReverse(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSplitProtocolHostPort(t *testing.T) {
|
||||
for i, test := range []struct {
|
||||
input string
|
||||
proto string
|
||||
ip string
|
||||
port string
|
||||
shouldErr bool
|
||||
}{
|
||||
{"dns://:53", "dns", "", "53", false},
|
||||
{"dns://127.0.0.1:4005", "dns", "127.0.0.1", "4005", false},
|
||||
{"[ffe0:34ab:1]:4005", "", "ffe0:34ab:1", "4005", false},
|
||||
|
||||
// port part is mandatory
|
||||
{"dns://", "dns", "", "", true},
|
||||
{"dns://127.0.0.1", "dns", "127.0.0.1", "", true},
|
||||
// cannot be empty
|
||||
{"", "", "", "", true},
|
||||
// invalid format with twice ://
|
||||
{"dns://127.0.0.1://53", "", "", "", true},
|
||||
} {
|
||||
proto, ip, port, err := SplitProtocolHostPort(test.input)
|
||||
if test.shouldErr && err == nil {
|
||||
t.Errorf("Test %d: (address = %s) expected error, but there wasn't any", i, test.input)
|
||||
continue
|
||||
}
|
||||
if !test.shouldErr && err != nil {
|
||||
t.Errorf("Test %d: (address = %s) expected no error, but there was one: %v", i, test.input, err)
|
||||
continue
|
||||
}
|
||||
if err == nil || test.shouldErr {
|
||||
continue
|
||||
}
|
||||
if proto != test.proto {
|
||||
t.Errorf("Test %d: (address = %s) expected protocol with value %s but got %s", i, test.input, test.proto, proto)
|
||||
}
|
||||
if ip != test.ip {
|
||||
t.Errorf("Test %d: (address = %s) expected ip with value %s but got %s", i, test.input, test.ip, ip)
|
||||
}
|
||||
if port != test.port {
|
||||
t.Errorf("Test %d: (address = %s) expected port with value %s but got %s", i, test.input, test.port, port)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user