mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 08:14:18 -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
@@ -1,6 +1,7 @@
|
||||
package dnsserver
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
@@ -72,6 +73,21 @@ func normalizeZone(str string) (zoneAddr, error) {
|
||||
return zoneAddr{Zone: dns.Fqdn(host), Port: port, Transport: trans, IPNet: ipnet}, nil
|
||||
}
|
||||
|
||||
// SplitProtocolHostPort - split a full formed address like "dns://[::1}:53" into parts
|
||||
func SplitProtocolHostPort(address string) (protocol string, ip string, port string, err error) {
|
||||
parts := strings.Split(address, "://")
|
||||
switch len(parts) {
|
||||
case 1:
|
||||
ip, port, err := net.SplitHostPort(parts[0])
|
||||
return "", ip, port, err
|
||||
case 2:
|
||||
ip, port, err := net.SplitHostPort(parts[1])
|
||||
return parts[0], ip, port, err
|
||||
default:
|
||||
return "", "", "", fmt.Errorf("provided value is not in an address format : %s", address)
|
||||
}
|
||||
}
|
||||
|
||||
// Supported transports.
|
||||
const (
|
||||
TransportDNS = "dns"
|
||||
|
||||
Reference in New Issue
Block a user