Skip to content

Commit

Permalink
Merge pull request #4 from libdns/sanitized-logging
Browse files Browse the repository at this point in the history
 Don't log query params (which include password) unless an env var is set
  • Loading branch information
gizmoguy authored Aug 18, 2024
2 parents 5662f8b + 2577ec3 commit d8d5965
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net/http"
"net/netip"
"net/url"
"os"
"strings"
"time"

Expand All @@ -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"

Expand All @@ -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()
Expand Down Expand Up @@ -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,
)
}

Expand Down

0 comments on commit d8d5965

Please sign in to comment.