Move toFqdn and unFqdn into a shared place (see GH-84)
This commit is contained in:
parent
08516614dd
commit
d70e2869d2
3 changed files with 21 additions and 19 deletions
|
@ -106,3 +106,21 @@ func checkDNS(domain, fqdn string) bool {
|
||||||
|
|
||||||
return false
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
// TTL must be between 120 and 86400 seconds
|
||||||
func sanitizeTTL(ttl int) int {
|
func sanitizeTTL(ttl int) int {
|
||||||
switch {
|
switch {
|
||||||
|
|
|
@ -10,9 +10,9 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
dnsimpleLiveTest bool
|
dnsimpleLiveTest bool
|
||||||
dnsimpleEmail string
|
dnsimpleEmail string
|
||||||
dnsimpleAPIKey string
|
dnsimpleAPIKey string
|
||||||
dnsimpleDomain string
|
dnsimpleDomain string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue