From d70e2869d257e5301ec9940ad8e95ea8afaad2c5 Mon Sep 17 00:00:00 2001 From: Simone Carletti Date: Tue, 26 Jan 2016 16:37:50 +0100 Subject: [PATCH] Move toFqdn and unFqdn into a shared place (see GH-84) --- acme/dns_challenge.go | 18 ++++++++++++++++++ acme/dns_challenge_cloudflare.go | 16 ---------------- acme/dns_challenge_dnsimple_test.go | 6 +++--- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/acme/dns_challenge.go b/acme/dns_challenge.go index 906a219e..83fc45be 100644 --- a/acme/dns_challenge.go +++ b/acme/dns_challenge.go @@ -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 +} diff --git a/acme/dns_challenge_cloudflare.go b/acme/dns_challenge_cloudflare.go index 8fbe947a..4781ec5b 100644 --- a/acme/dns_challenge_cloudflare.go +++ b/acme/dns_challenge_cloudflare.go @@ -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 { diff --git a/acme/dns_challenge_dnsimple_test.go b/acme/dns_challenge_dnsimple_test.go index 9dcc8829..0f51afdd 100644 --- a/acme/dns_challenge_dnsimple_test.go +++ b/acme/dns_challenge_dnsimple_test.go @@ -10,9 +10,9 @@ import ( var ( dnsimpleLiveTest bool - dnsimpleEmail string - dnsimpleAPIKey string - dnsimpleDomain string + dnsimpleEmail string + dnsimpleAPIKey string + dnsimpleDomain string ) func init() {