Move toFqdn and unFqdn into a shared place (see GH-84)

This commit is contained in:
Simone Carletti 2016-01-26 16:37:50 +01:00
parent 08516614dd
commit d70e2869d2
3 changed files with 21 additions and 19 deletions

View file

@ -106,3 +106,21 @@ func checkDNS(domain, fqdn string) bool {
return false
}
// toFqdn converts the name into a fqdn appending a trailing dot.
func toFqdn(name string) string {
n := len(name)
if n == 0 || name[n-1] == '.' {
return name
}
return name + "."
}
// unFqdn converts the fqdn into a name removing the trailing dot.
func unFqdn(name string) string {
n := len(name)
if n != 0 && name[n-1] == '.' {
return name[:n-1]
}
return name
}

View file

@ -123,22 +123,6 @@ func newTxtRecord(zoneID, fqdn, value string, ttl int) *cloudflare.Record {
}
}
func toFqdn(name string) string {
n := len(name)
if n == 0 || name[n-1] == '.' {
return name
}
return name + "."
}
func unFqdn(name string) string {
n := len(name)
if n != 0 && name[n-1] == '.' {
return name[:n-1]
}
return name
}
// TTL must be between 120 and 86400 seconds
func sanitizeTTL(ttl int) int {
switch {

View file

@ -10,9 +10,9 @@ import (
var (
dnsimpleLiveTest bool
dnsimpleEmail string
dnsimpleAPIKey string
dnsimpleDomain string
dnsimpleEmail string
dnsimpleAPIKey string
dnsimpleDomain string
)
func init() {