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

New features: DU() and getConfiguredDomains() to assist modifying domains (#800)

* Added DU() and getConfiguredDomains()

* Added docs for both new functions

* Added a space between option and its value

* Renamed "DU" to "D_EXTEND", adjusted docs

* Fixed: Changed old DU() calls to D_EXTEND()
This commit is contained in:
Patrik Kernstock
2020-08-04 14:43:02 +01:00
committed by GitHub
parent f21c8fc400
commit d2d210a5af
5 changed files with 235 additions and 105 deletions

View File

@@ -0,0 +1,30 @@
---
name: D_EXTEND
parameters:
- name
- modifiers...
---
`D_EXTEND` adds records (and metadata) to a domain. The domain must have previously been defined by `D()`. `D_EXTEND()` behaves the same as `D()` in all other ways: The first argument is the domain name. See the documentation of `D` for further details.
Example:
{% include startExample.html %}
{% highlight js %}
D('domain.tld', REG, DnsProvider(DNS),
A('@', "127.0.0.1")
)
D_EXTEND('domain.tld',
A('@', "127.0.0.2")
)
{%endhighlight%}
This will end up in following modifications:
```
******************** Domain: domain.tld
----- Getting nameservers from: registrar
----- DNS Provider: registrar...3 corrections
#1: CREATE A domain.tld 127.0.0.1 ttl=43200
#2: CREATE A domain.tld 127.0.0.2 ttl=43200
#3: REFRESH zone domain.tld
```
{% include endExample.html %}

View File

@@ -0,0 +1,63 @@
---
name: getConfiguredDomains
parameters:
- name
- modifiers...
---
`getConfiguredDomains` getConfiguredDomains is a helper function that returns the domain names
configured at the time the function is called. Calling this function early or later in
`dnsconfig.js` may return different results. Typical usage is to iterate over all
domains at the end of your configuration file.
Example for adding records to all configured domains:
{% include startExample.html %}
{% highlight js %}
var domains = getConfiguredDomains();
for(i = 0; i < domains.length; i++) {
D_EXTEND(domains[i],
TXT('_important', 'BLA') // I know, not really creative.
)
}
{%endhighlight%}
This will end up in following modifications:
```
******************** Domain: domain1.tld
----- Getting nameservers from: registrar
----- DNS Provider: registrar...2 corrections
#1: CREATE TXT _important.domain1.tld "BLA" ttl=43200
#2: REFRESH zone domain1.tld
******************** Domain: domain2.tld
----- Getting nameservers from: registrar
----- DNS Provider: registrar...2 corrections
#1: CREATE TXT _important.domain2.tld "BLA" ttl=43200
#2: REFRESH zone domain2.tld
```
{% include endExample.html %}
Example for adding DMARC report records:
{% include startExample.html %}
This example might be more useful, specially for configuring the DMARC report records. According to DMARC RFC you need to specify `domain2.tld._report.dmarc.domain1.tld` to allow `domain2.tld` to send aggregate/forensic email reports to `domain1.tld`. This can be used to do this in an easy way, without using the wildcard from the RFC.
{% highlight js %}
var domains = getConfiguredDomains();
for(i = 0; i < domains.length; i++) {
D_EXTEND("domain1.tld",
TXT(domains[i] + '._report._dmarc', 'v=DMARC1')
);
}
{%endhighlight%}
This will end up in following modifications:
```
******************** Domain: domain2.tld
----- Getting nameservers from: registrar
----- DNS Provider: registrar...4 corrections
#1: CREATE TXT domain1.tld._report._dmarc.domain2.tld "v=DMARC1" ttl=43200
#2: CREATE TXT domain3.tld._report._dmarc.domain2.tld "v=DMARC1" ttl=43200
#3: CREATE TXT domain4.tld._report._dmarc.domain2.tld "v=DMARC1" ttl=43200
#4: REFRESH zone domain2.tld
```
{% include endExample.html %}