diff options
Diffstat (limited to 'plugin/pkg/dnsutil/join.go')
-rw-r--r-- | plugin/pkg/dnsutil/join.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/plugin/pkg/dnsutil/join.go b/plugin/pkg/dnsutil/join.go new file mode 100644 index 000000000..515bf3dad --- /dev/null +++ b/plugin/pkg/dnsutil/join.go @@ -0,0 +1,19 @@ +package dnsutil + +import ( + "strings" + + "github.com/miekg/dns" +) + +// Join 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 Join(labels []string) string { + ll := len(labels) + if labels[ll-1] == "." { + s := strings.Join(labels[:ll-1], ".") + return dns.Fqdn(s) + } + s := strings.Join(labels, ".") + return dns.Fqdn(s) +} |