mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-01-11 01:47:53 +08:00
8dea9edc34
TXT records are now handled different. 1. The raw input from dnsconfig.js is passed all the way to the provider. The provider can determine if it can or can't handle such records (auditrecords.go) and processes them internally as such. 2. The CanUseTXTMulti capability is no longer needed. * DSPs now register a table of functions * Use audits for txt record variations * unit tests pass. integration fails. * fix deepcopy problem * rename to AuditRecordSupport * Reduce use of TXTMulti * Remove CanUseTXTMulti * fix Test Skip * fix DO * fix vultr * fix NDC * msdns fixes * Fix powerdns and cloudflare * HEDNS: Fix usage of target field to resolve TXT handling (#1067) * Fix HEXONET Co-authored-by: Robert Blenkinsopp <robert@blenkinsopp.net> Co-authored-by: Jakob Ackermann <das7pad@outlook.com>
33 lines
897 B
Go
33 lines
897 B
Go
package txtutil
|
|
|
|
import (
|
|
"github.com/StackExchange/dnscontrol/v3/models"
|
|
)
|
|
|
|
// SplitSingleLongTxt finds TXT records with a single long string and splits it
|
|
// into 255-octet chunks. This is used by providers that, when a user specifies
|
|
// one long TXT string, split it into smaller strings behind the scenes.
|
|
// Typically this replaces the TXTMulti capability.
|
|
func SplitSingleLongTxt(records []*models.RecordConfig) {
|
|
for _, rc := range records {
|
|
if rc.HasFormatIdenticalToTXT() {
|
|
s := rc.TxtStrings[0]
|
|
if len(rc.TxtStrings) == 1 && len(s) > 255 {
|
|
rc.SetTargetTXTs(splitChunks(s, 255))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func splitChunks(buf string, lim int) []string {
|
|
var chunk string
|
|
chunks := make([]string, 0, len(buf)/lim+1)
|
|
for len(buf) >= lim {
|
|
chunk, buf = buf[:lim], buf[lim:]
|
|
chunks = append(chunks, chunk)
|
|
}
|
|
if len(buf) > 0 {
|
|
chunks = append(chunks, buf[:])
|
|
}
|
|
return chunks
|
|
}
|