diff --git a/docs/spf-optimizer.md b/docs/spf-optimizer.md index 9ea6cf202..5b3176d4b 100644 --- a/docs/spf-optimizer.md +++ b/docs/spf-optimizer.md @@ -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. diff --git a/pkg/js/helpers.js b/pkg/js/helpers.js index 165883537..97809d056 100644 --- a/pkg/js/helpers.js +++ b/pkg/js/helpers.js @@ -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; }