mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
gandi works
This commit is contained in:
@ -1088,8 +1088,8 @@ 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`)),
|
||||
clear(),
|
||||
tc("TXT with 1 backslash", txt("fooosbs", `back\slash`)),
|
||||
//clear(),
|
||||
|
||||
tc("TXT interior ws", txt("foosp", "with spaces")),
|
||||
tc("TXT trailing ws", txt("foows1", "with space at end ")),
|
||||
@ -1099,7 +1099,7 @@ func makeTests(t *testing.T) []*TestGroup {
|
||||
//clear(),
|
||||
|
||||
// TODO(tlim): Re-add this when we fix the RFC1035 escaped-quotes issue.
|
||||
//tc("Create TXT with frequently escaped characters", txt("fooex", `!^.*$@#%^&()([][{}{<></:;-_=+\`)),
|
||||
tc("Create TXT with frequently escaped characters", txt("fooex", `!^.*$@#%^&()([][{}{<></:;-_=+\`)),
|
||||
clear(),
|
||||
),
|
||||
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
@ -324,7 +323,7 @@ func (rc *RecordConfig) ToDiffable(extraMaps ...map[string]string) string {
|
||||
content = fmt.Sprintf("%s %v %d %d %d %d ttl=%d", rc.target, rc.SoaMbox, rc.SoaRefresh, rc.SoaRetry, rc.SoaExpire, rc.SoaMinttl, rc.TTL)
|
||||
// SoaSerial is not used in comparison
|
||||
case "TXT":
|
||||
fmt.Fprintf(os.Stdout, "DEBUG: XXXXXXXXXXXXXXXX\n")
|
||||
//fmt.Fprintf(os.Stdout, "DEBUG: XXXXXXXXXXXXXXXX\n")
|
||||
t := rc.GetTargetField()
|
||||
te := txtutil.EncodeQuoted(t)
|
||||
content = fmt.Sprintf("%v ttl=%d", te, rc.TTL)
|
||||
@ -360,9 +359,9 @@ 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 raw txts=%s q=%q\n", rc.target, 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)
|
||||
//fmt.Fprintf(os.Stdout, "DEBUG: ToComNoTTL cmp txts=%s q=%q\n", r, r)
|
||||
return r
|
||||
}
|
||||
return rc.GetTargetCombined()
|
||||
|
@ -45,7 +45,10 @@ func (rc *RecordConfig) GetTargetCombined() string {
|
||||
}
|
||||
}
|
||||
|
||||
if rc.Type == "SOA" {
|
||||
switch rc.Type {
|
||||
case "TXT":
|
||||
return rc.target
|
||||
case "SOA":
|
||||
return fmt.Sprintf("%s %v %d %d %d %d %d", rc.target, rc.SoaMbox, rc.SoaSerial, rc.SoaRefresh, rc.SoaRetry, rc.SoaExpire, rc.SoaMinttl)
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/StackExchange/dnscontrol/v4/models"
|
||||
"github.com/StackExchange/dnscontrol/v4/pkg/prettyzone"
|
||||
"github.com/StackExchange/dnscontrol/v4/pkg/printer"
|
||||
)
|
||||
|
||||
/*
|
||||
@ -104,9 +103,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")
|
||||
//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")
|
||||
//printer.Printf("DEBUG: DESIRED:\n")
|
||||
cc.addRecords(desired, false)
|
||||
cc.verifyCNAMEAssertions()
|
||||
sort.Slice(cc.ldata, func(i, j int) bool {
|
||||
|
@ -33,13 +33,17 @@ func nativeToRecords(n livedns.DomainRecord, origin string) (rcs []*models.Recor
|
||||
case "TXT":
|
||||
//err = rc.SetTargetTXTfromRFC1035Quoted(value)
|
||||
t := value
|
||||
printer.Printf("DEBUG gandi txt inbounds=%s q=%q\n", t, t)
|
||||
//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)
|
||||
//td := t
|
||||
//printer.Printf("DEBUG gandi txt decodeds=%s q=%q\n", td, td)
|
||||
err = rc.SetTargetTXT(td)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
default:
|
||||
err = rc.PopulateFromString(rtype, value, origin)
|
||||
}
|
||||
@ -68,25 +72,27 @@ func recordsToNative(rcs []*models.RecordConfig, origin string) []livedns.Domain
|
||||
}
|
||||
key := r.Key()
|
||||
|
||||
var val string
|
||||
if r.Type == "TXT" {
|
||||
t := r.GetTargetTXTJoined()
|
||||
//printer.Printf("DEBUG: txt outbounds=%s q=%q\n", t, t)
|
||||
val = txtutil.EncodeQuoted(t)
|
||||
//printer.Printf("DEBUG: txt encodeds=%s q=%q\n", val, val)
|
||||
} else {
|
||||
val = r.GetTargetCombined()
|
||||
}
|
||||
|
||||
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()},
|
||||
RrsetType: r.Type,
|
||||
RrsetTTL: int(r.TTL),
|
||||
RrsetName: label,
|
||||
RrsetValues: []string{val},
|
||||
}
|
||||
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())
|
||||
zr.RrsetValues = append(zr.RrsetValues, val)
|
||||
|
||||
if r.TTL != uint32(zr.RrsetTTL) {
|
||||
printer.Warnf("All TTLs for a rrset (%v) must be the same. Using smaller of %v and %v.\n", key, r.TTL, zr.RrsetTTL)
|
||||
@ -94,7 +100,6 @@ func recordsToNative(rcs []*models.RecordConfig, origin string) []livedns.Domain
|
||||
zr.RrsetTTL = int(r.TTL)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,9 +175,6 @@ func PrepDesiredRecords(dc *models.DomainConfig) {
|
||||
printer.Warnf("Gandi does not support ttls > 30 days. Setting %s from %d to 2592000\n", rec.GetLabelFQDN(), rec.TTL)
|
||||
rec.TTL = 2592000
|
||||
}
|
||||
//if rec.Type == "TXT" {
|
||||
// rec.SetTarget("\"" + rec.GetTargetField() + "\"") // FIXME(tlim): Should do proper quoting.
|
||||
//}
|
||||
if rec.Type == "NS" && rec.GetLabel() == "@" {
|
||||
if !strings.HasSuffix(rec.GetTargetField(), ".gandi.net.") {
|
||||
printer.Warnf("Gandi does not support changing apex NS records. Ignoring %s\n", rec.GetTargetField())
|
||||
|
Reference in New Issue
Block a user