NEW: Added support for specific TTL when using SPF_BUILDER (#476)

* Added support for specific TTL for SPF_BUILDER

* Added updated static.go file

* Use IF instead of reading defaultTTL
This commit is contained in:
Patrik Kernstock 2019-05-23 15:25:06 +02:00 committed by Tom Limoncelli
parent c65ba1c84c
commit f9df8c744a
2 changed files with 13 additions and 2 deletions

View file

@ -41,6 +41,7 @@ D("example.tld", REG, DSP, ...
label: "@",
overflow: "_spf%d",
raw: "_rawspf",
ttl: "5m",
parts: [
"v=spf1",
"ip4:198.252.206.0/24", // ny-mail*
@ -101,6 +102,7 @@ The parameters are:
* `label:` The label of the first TXT record. (Optional. Default: `"@"`)
* `overflow:` If set, SPF strings longer than 255 chars will be split into multiple TXT records. The value of this setting determines the template for what the additional labels will be named. If not set, no splitting will occur and dnscontrol may generate TXT strings that are too long.
* `raw:` The label of the unaltered SPF settings. (Optional. Default: `"_rawspf"`)
* `ttl:` This allows setting a specific TTL on this SPF record. (Optional. Default: using default record TTL)
* `parts:` The individual parts of the SPF settings.
* `flatten:` Which includes should be inlined. For safety purposes the flattening is done on an opt-in basis. If `"*"` is listed, all includes will be flattened... this might create more problems than is solves due to length limitations.

View file

@ -645,6 +645,7 @@ var FRAME = recordBuilder('FRAME');
// parts: The parts of the SPF record (to be joined with ' ').
// label: The DNS label for the primary SPF record. (default: '@')
// raw: Where (which label) to store an unaltered version of the SPF settings.
// ttl: The time for TTL, integer or string. (default: not defined, using DefaultTTL)
// split: The template for additional records to be created (default: '_spf%d')
// flatten: A list of domains to be flattened.
@ -666,7 +667,11 @@ function SPF_BUILDER(value) {
// If flattening is requested, generate a TXT record with the raw SPF settings.
if (value.flatten && value.flatten.length > 0) {
p.flatten = value.flatten.join(',');
r.push(TXT(value.raw, rawspf));
if (value.ttl) {
r.push(TXT(value.raw, rawspf, TTL(value.ttl)));
} else {
r.push(TXT(value.raw, rawspf));
}
}
// If overflow is specified, enable splitting.
@ -675,7 +680,11 @@ function SPF_BUILDER(value) {
}
// Generate a TXT record with the metaparameters.
r.push(TXT(value.label, rawspf, p));
if (value.ttl) {
r.push(TXT(value.label, rawspf, p, TTL(value.ttl)));
} else {
r.push(TXT(value.label, rawspf, p));
}
return r;
}