mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 10:43:17 -04:00
Dns.join (#944)
* Add dnsutil.Join * Create dnsutil.Join Create Join helper function and move bits in the code over.
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/coredns/coredns/middleware/pkg/dnsutil"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
@@ -24,7 +26,7 @@ func Domain(s string) string {
|
||||
for i, j := 1, len(l)-1; i < j; i, j = i+1, j-1 {
|
||||
l[i], l[j] = l[j], l[i]
|
||||
}
|
||||
return dns.Fqdn(strings.Join(l[1:len(l)-1], "."))
|
||||
return dnsutil.Join(l[1 : len(l)-1])
|
||||
}
|
||||
|
||||
// PathWithWildcard ascts as Path, but if a name contains wildcards (* or any), the name will be
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
"log"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/coredns/coredns/middleware/etcd/msg"
|
||||
"github.com/coredns/coredns/middleware/pkg/dnsutil"
|
||||
"github.com/coredns/coredns/middleware/proxy"
|
||||
"github.com/coredns/coredns/request"
|
||||
|
||||
@@ -62,7 +62,7 @@ Services:
|
||||
// Chop of left most label, because that is used as the nameserver place holder
|
||||
// and drop the right most labels that belong to zone.
|
||||
// We must *also* chop of dns.stub. which means cutting two more labels.
|
||||
domain = dns.Fqdn(strings.Join(labels[1:len(labels)-dns.CountLabel(z)-2], "."))
|
||||
domain = dnsutil.Join(labels[1 : len(labels)-dns.CountLabel(z)-2])
|
||||
if domain == z {
|
||||
log.Printf("[WARNING] Skipping nameserver for domain we are authoritative for: %s", domain)
|
||||
continue Services
|
||||
|
||||
Reference in New Issue
Block a user