diff --git a/client.go b/client.go index 7077e1a..2136858 100644 --- a/client.go +++ b/client.go @@ -10,6 +10,7 @@ import ( "net/http" "net/netip" "net/url" + "os" "strings" "time" @@ -20,7 +21,7 @@ import ( const ( // User agent to use for API requests - userAgent = "libdns-he/1.0.1" + userAgent = "libdns-he/1.0.2" // API URL to POST updates to updateURL = "https://dyn.dns.he.net/nic/update" @@ -42,6 +43,11 @@ const ( codeNotFqdn = "notfqdn" ) +var ( + // Set environment variable to "TRUE" to enable debug logging + debug = os.Getenv("LIBDNS_HE_DEBUG") +) + // Query Google DNS for A/AAAA/TXT record for a given DNS name func (p *Provider) getDomain(ctx context.Context, zone string) ([]libdns.Record, error) { p.mutex.Lock() @@ -224,8 +230,14 @@ func (p *Provider) doRequest(ctx context.Context, domain string, params map[stri respBody := string(bodyBytes) if err := checkResponse(u, respBody); err != nil { + if debug == "TRUE" { + return errors.Wrapf(err, + "HE api request failed, query=%s, response=%s", query, respBody, + ) + } + return errors.Wrapf(err, - "HE api request failed, query=%s, response=%s", query, respBody, + "HE api request failed, response=%s", respBody, ) }