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

TXT records should check length at check/preview time (#947)

* TXT records should check length
* Add validation to TXT generator
* Split and validate long TXT targets
* Add a metaparameter to TXT records to indicate autosplit is requested.
* SPF_BUILDER marks TXT records as needing to be autosplit.
* Validate should check for overly-long TXT targets
This commit is contained in:
Tom Limoncelli
2020-11-18 07:05:26 -05:00
committed by GitHub
parent 550fa436ed
commit 13a1360779
8 changed files with 333 additions and 143 deletions

View File

@ -123,7 +123,7 @@ function D_EXTEND(name) {
// _getDomainObject(name): This implements the domain matching
// algorithm used by D_EXTEND(). Candidate matches are an exact match
// of the domain's name, or if name is a proper subdomain of the
// domain's name. The longest match is returned.
// domain's name. The longest match is returned.
function _getDomainObject(name) {
var domain = null;
var domainLen = 0;
@ -416,6 +416,12 @@ function isStringOrArray(x) {
return _.isString(x) || _.isArray(x);
}
// AUTOSPLIT is a modifier that instructs the Go-level code to
// split this TXT record's target into chunks of 255.
var AUTOSPLIT = { txtSplitAlgorithm: 'multistring' }; // Create 255-byte chunks
//var TXTMULTISPACE = { txtSplitAlgorithm: 'space' }; // Split on space [not implemented]
// TXT(name,target, recordModifiers...)
var TXT = recordBuilder('TXT', {
args: [
@ -841,10 +847,12 @@ function SPF_BUILDER(value) {
p.flatten = value.flatten.join(',');
// Only add the raw spf record if it isn't an empty string
if (value.raw !== '') {
rp = {};
rp.txtSplitAlgorithm = 'multistring'; // Split the target if needed.
if (value.ttl) {
r.push(TXT(value.raw, rawspf, TTL(value.ttl)));
r.push(TXT(value.raw, rawspf, rp, TTL(value.ttl)));
} else {
r.push(TXT(value.raw, rawspf));
r.push(TXT(value.raw, rawspf, rp));
}
}
}
@ -862,6 +870,8 @@ function SPF_BUILDER(value) {
p.txtMaxSize = value.txtMaxSize;
}
p.txtSplitAlgorithm = 'multistring'; // Split the target if needed.
// Generate a TXT record with the metaparameters.
if (value.ttl) {
r.push(TXT(value.label, rawspf, p, TTL(value.ttl)));