1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

Add debug printfs

This commit is contained in:
Tom Limoncelli
2023-11-12 18:10:13 -05:00
parent 0e8d24cfa0
commit 4f935be608
5 changed files with 34 additions and 8 deletions

View File

@ -9,6 +9,7 @@ import (
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/credsfile"
"github.com/StackExchange/dnscontrol/v4/pkg/prettyzone"
"github.com/StackExchange/dnscontrol/v4/pkg/printer"
"github.com/StackExchange/dnscontrol/v4/providers"
"github.com/urfave/cli/v2"
)
@ -351,7 +352,9 @@ func formatDsl(zonename string, rec *models.RecordConfig, defaultTTL uint32) str
case "TLSA":
target = fmt.Sprintf(`%d, %d, %d, "%s"`, rec.TlsaUsage, rec.TlsaSelector, rec.TlsaMatchingType, rec.GetTargetField())
case "TXT":
printer.Printf("DEBUG: gz raw s=%s q=%q\n", rec.GetTargetTXTJoined(), rec.GetTargetTXTJoined())
target = jsonQuoted(rec.GetTargetTXTJoined())
printer.Printf("DEBUG: gz qtd s=%s q=%q\n", target, target)
// TODO(tlim): If this is an SPF record, generate a SPF_BUILDER().
case "NS":
// NS records at the apex should be NAMESERVER() records.

View File

@ -1088,7 +1088,7 @@ func makeTests(t *testing.T) []*TestGroup {
tc("TXT with 1 backtick", txt("foobt", "blah`blah")),
tc("TXT with 1 double-quotes", txt("foodq", `quo"te`)),
tc("TXT with 2 double-quotes", txt("foodqs", `q"uo"te`)),
//tc("TXT with 1 backslash", txt("fooosbs", `back\slash`)),
tc("TXT with 1 backslash", txt("fooosbs", `back\slash`)),
clear(),
tc("TXT interior ws", txt("foosp", "with spaces")),

View File

@ -360,8 +360,10 @@ func (rc *RecordConfig) ToDiffable(extraMaps ...map[string]string) string {
// This replaces ToDiff()
func (rc *RecordConfig) ToComparableNoTTL() string {
if rc.Type == "TXT" {
fmt.Fprintf(os.Stdout, "DEBUG: ToComNoTTL txts=%s q=%q\n", rc.target, rc.target)
return txtutil.EncodeQuoted(rc.target)
fmt.Fprintf(os.Stdout, "DEBUG: ToComNoTTL raw txts=%s q=%q\n", rc.target, rc.target)
r := txtutil.EncodeQuoted(rc.target)
fmt.Fprintf(os.Stdout, "DEBUG: ToComNoTTL cmp txts=%s q=%q\n", r, r)
return r
}
return rc.GetTargetCombined()
}

View File

@ -7,6 +7,7 @@ import (
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/prettyzone"
"github.com/StackExchange/dnscontrol/v4/pkg/printer"
)
/*
@ -103,7 +104,9 @@ func NewCompareConfig(origin string, existing, desired models.Records, compFn Co
labelMap: map[string]bool{},
keyMap: map[models.RecordKey]bool{},
}
printer.Printf("DEBUG: EXISTING:\n")
cc.addRecords(existing, true) // Must be called first so that CNAME manipulations happen in the correct order.
printer.Printf("DEBUG: DESIRED:\n")
cc.addRecords(desired, false)
cc.verifyCNAMEAssertions()
sort.Slice(cc.ldata, func(i, j int) bool {
@ -215,6 +218,7 @@ func mkCompareBlobs(rc *models.RecordConfig, f func(*models.RecordConfig) string
}
}
// We do this to save memory. This assures the first return value uses the same memory as the second.
lenWithoutTTL := len(comp)
compFull := comp + fmt.Sprintf(" ttl=%d", rc.TTL)

View File

@ -7,6 +7,7 @@ import (
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/printer"
"github.com/StackExchange/dnscontrol/v4/pkg/txtutil"
"github.com/go-gandi/go-gandi/livedns"
)
@ -30,7 +31,15 @@ func nativeToRecords(n livedns.DomainRecord, origin string) (rcs []*models.Recor
rc.Type = "ALIAS"
err = rc.SetTarget(value)
case "TXT":
err = rc.SetTargetTXTfromRFC1035Quoted(value)
//err = rc.SetTargetTXTfromRFC1035Quoted(value)
t := value
printer.Printf("DEBUG gandi txt inbounds=%s q=%q\n", t, t)
td, err := txtutil.ParseQuoted(t)
if err != nil {
return nil, err
}
printer.Printf("DEBUG gandi txt decodeds=%s q=%q\n", td, td)
_ = rc.SetTargetTXT(td)
default:
err = rc.PopulateFromString(rtype, value, origin)
}
@ -60,13 +69,21 @@ func recordsToNative(rcs []*models.RecordConfig, origin string) []livedns.Domain
key := r.Key()
if zr, ok := keys[key]; !ok {
var vals []string
// Allocate a new ZoneRecord:
zr := livedns.DomainRecord{
RrsetType: r.Type,
RrsetTTL: int(r.TTL),
RrsetName: label,
RrsetValues: []string{r.GetTargetCombined()},
//RrsetValues: []string{r.GetTargetCombined()},
}
if r.Type == "TXT" {
vals = r.GetTargetTXTChunked255()
printer.Printf("DEBUG: gandi TXT outbounds=%s q=%q\n", vals, vals)
} else {
vals = []string{r.GetTargetCombined()}
}
zr.RrsetValues = vals
keys[key] = &zr
} else {
zr.RrsetValues = append(zr.RrsetValues, r.GetTargetCombined())