diff --git a/internal/config/dns/dns_path.go b/internal/config/dns/dns_path.go index 94b238045..c648aed2d 100644 --- a/internal/config/dns/dns_path.go +++ b/internal/config/dns/dns_path.go @@ -37,6 +37,9 @@ func msgPath(s, prefix string) string { // dnsJoin joins labels to form a fully qualified domain name. If the last label is // the root label it is ignored. Not other syntax checks are performed. func dnsJoin(labels ...string) string { + if len(labels) == 0 { + return "" + } ll := len(labels) if labels[ll-1] == "." { return strings.Join(labels[:ll-1], ".") + "." @@ -50,6 +53,9 @@ func msgUnPath(s string) string { if l[len(l)-1] == "" { l = l[:len(l)-1] } + if len(l) < 2 { + return s + } // start with 1, to strip /skydns for i, j := 1, len(l)-1; i < j; i, j = i+1, j-1 { l[i], l[j] = l[j], l[i]