mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
DOCS: Fix examples in documentation (#1435)
* Add example include * Replace example includes * Remove old example includes
This commit is contained in:
@@ -17,8 +17,7 @@ Modifier arguments are processed according to type as follows:
|
||||
- An array argument will have all of it's members evaluated recursively. This allows you to combine multiple common records or modifiers into a variable that can
|
||||
be used like a macro in multiple domains.
|
||||
|
||||
{% include startExample.html %}
|
||||
|
||||
{% capture example %}
|
||||
```js
|
||||
var REGISTRAR = NewRegistrar("name.com", "NAMEDOTCOM");
|
||||
var r53 = NewDnsProvider("R53","ROUTE53");
|
||||
@@ -44,8 +43,9 @@ D("example.com", REGISTRAR, DnsProvider(r53),
|
||||
GOOGLE_APPS_DOMAIN_MX
|
||||
);
|
||||
```
|
||||
{% endcapture %}
|
||||
|
||||
{% include endExample.html %}
|
||||
{% include example.html content=example %}
|
||||
|
||||
|
||||
# Split Horizon DNS
|
||||
@@ -58,8 +58,7 @@ To differentiate the different domains, specify the domains as
|
||||
`domain.tld!tag`, such as `example.com!inside` and
|
||||
`example.com!outside`.
|
||||
|
||||
{% include startExample.html %}
|
||||
|
||||
{% capture example %}
|
||||
```js
|
||||
var REG = NewRegistrar("Third-Party", "NONE");
|
||||
var DNS_INSIDE = NewDnsProvider("Cloudflare", "CLOUDFLAREAPI");
|
||||
@@ -77,8 +76,9 @@ D_EXTEND("example.com!inside",
|
||||
A("internal", "10.99.99.99")
|
||||
);
|
||||
```
|
||||
{% endcapture %}
|
||||
|
||||
{% include endExample.html %}
|
||||
{% include example.html content=example %}
|
||||
|
||||
A domain name without a `!` is assigned a tag that is the empty
|
||||
string. For example, `example.com` and `example.com!` are equivalent.
|
||||
|
||||
@@ -7,8 +7,7 @@ parameters:
|
||||
`DEFAULTS` allows you to declare a set of default arguments to apply to all subsequent domains. Subsequent calls to [D](#D) will have these
|
||||
arguments passed as if they were the first modifiers in the argument list.
|
||||
|
||||
{% include startExample.html %}
|
||||
|
||||
{% capture example %}
|
||||
```js
|
||||
var COMMON = NewDnsProvider("foo","BIND");
|
||||
// we want to create backup zone files for all domains, but not actually register them.
|
||||
@@ -21,5 +20,6 @@ D("example.com", REGISTRAR, DnsProvider("R53"), A("@","1.2.3.4")); // this domai
|
||||
DEFAULTS();
|
||||
D("example2.com", REGISTRAR, DnsProvider("R53"), A("@","1.2.3.4")); // this domain will not have the previous defaults.
|
||||
```
|
||||
{% endcapture %}
|
||||
|
||||
{% include endExample.html %}
|
||||
{% include example.html content=example %}
|
||||
|
||||
@@ -31,8 +31,7 @@ in a `D_EXTEND` subdomain may not be what you expect.
|
||||
|
||||
Example:
|
||||
|
||||
{% include startExample.html %}
|
||||
|
||||
{% capture example %}
|
||||
```js
|
||||
D("domain.tld", REG, DnsProvider(DNS),
|
||||
A("@", "127.0.0.1"), // domain.tld
|
||||
@@ -77,8 +76,9 @@ This will end up in the following modifications:
|
||||
#11: CREATE CNAME g.sub.sub.domain.tld h.sub.sub.domain.tld.
|
||||
#12: CREATE CNAME i.sub.domain.tld j.sub.domain.tld.
|
||||
```
|
||||
{% endcapture %}
|
||||
|
||||
{% include endExample.html %}
|
||||
{% include example.html content=example %}
|
||||
|
||||
ProTips: `D_EXTEND()` permits you to create very complex and
|
||||
sophisticated configurations, but you shouldn't. Be nice to the next
|
||||
|
||||
@@ -18,8 +18,7 @@ Otherwise the syntax of `FETCH` is the same as `fetch`.
|
||||
> 1. Relying on external sources adds a point of failure. If the external source doesn't work, your script won't either. Please make sure you are aware of the consequences.
|
||||
> 2. Make sure DnsControl only uses verified configuration if you want to use `FETCH`. For example, an attacker can send Pull Requests to your config repo, and have your CI test malicious configurations and make arbitrary HTTP requests. Therefore, `FETCH` must be explicitly enabled with flag `--allow-fetch` on DnsControl invocation.
|
||||
|
||||
{% include startExample.html %}
|
||||
|
||||
{% capture example %}
|
||||
```js
|
||||
var REG_NONE = NewRegistrar('none', 'NONE');
|
||||
var DNS_BIND = NewDnsProvider('bind', 'BIND');
|
||||
@@ -42,5 +41,6 @@ FETCH('https://example.com', {
|
||||
]);
|
||||
});
|
||||
```
|
||||
{% endcapture %}
|
||||
|
||||
{% include endExample.html %}
|
||||
{% include example.html content=example %}
|
||||
|
||||
@@ -8,12 +8,12 @@ Converts an IPv4 address from string to an integer. This allows performing mathe
|
||||
|
||||
This does not accept IPv6 addresses. (PRs gladly accepted.)
|
||||
|
||||
{% include startExample.html %}
|
||||
|
||||
{% capture example %}
|
||||
```js
|
||||
var addrA = IP('1.2.3.4')
|
||||
var addrB = addrA + 1
|
||||
// addrB = 1.2.3.5
|
||||
```
|
||||
{% endcapture %}
|
||||
|
||||
{% include endExample.html %}
|
||||
{% include example.html content=example %}
|
||||
|
||||
@@ -14,13 +14,13 @@ Metadata is an optional object, that will only be used by certain providers. See
|
||||
|
||||
This function will return the name as a string so that you may assign it to a variable to use inside [D](#D) directives.
|
||||
|
||||
{% include startExample.html %}
|
||||
|
||||
{% capture example %}
|
||||
```js
|
||||
var REGISTRAR = NewRegistrar("name.com", "NAMEDOTCOM");
|
||||
var R53 = NewDnsProvider("r53", "ROUTE53");
|
||||
|
||||
D("example.com", REGISTRAR, DnsProvider(R53), A("@","1.2.3.4"));
|
||||
```
|
||||
{% endcapture %}
|
||||
|
||||
{% include endExample.html %}
|
||||
{% include example.html content=example %}
|
||||
|
||||
@@ -14,13 +14,13 @@ Metadata is an optional object, that will only be used by certain providers. See
|
||||
|
||||
This function will return the name as a string so that you may assign it to a variable to use inside [D](#D) directives.
|
||||
|
||||
{% include startExample.html %}
|
||||
|
||||
{% capture example %}
|
||||
```js
|
||||
var REGISTRAR = NewRegistrar("name.com", "NAMEDOTCOM");
|
||||
var r53 = NewDnsProvider("R53","ROUTE53");
|
||||
|
||||
D("example.com", REGISTRAR, DnsProvider(r53), A("@","1.2.3.4"));
|
||||
```
|
||||
{% endcapture %}
|
||||
|
||||
{% include endExample.html %}
|
||||
{% include example.html content=example %}
|
||||
|
||||
@@ -6,10 +6,10 @@ parameters:
|
||||
|
||||
`PANIC` terminates the script and therefore DnsControl with an exit code of 1. This should be used if your script cannot gather enough information to generate records, for example when a HTTP request failed.
|
||||
|
||||
{% include startExample.html %}
|
||||
|
||||
{% capture example %}
|
||||
```js
|
||||
PANIC("Something really bad has happened");
|
||||
```
|
||||
{% endcapture %}
|
||||
|
||||
{% include endExample.html %}
|
||||
{% include example.html content=example %}
|
||||
|
||||
@@ -29,8 +29,7 @@ Note that the lower bits (the ones outside the netmask) must be zeros. They are
|
||||
zeroed out automatically. Thus, `REV('1.2.3.4/24') is an error. This is done
|
||||
to catch typos.
|
||||
|
||||
{% include startExample.html %}
|
||||
|
||||
{% capture example %}
|
||||
```js
|
||||
D(REV('1.2.3.0/24'), REGISTRAR, DnsProvider(BIND),
|
||||
PTR("1", 'foo.example.com.'),
|
||||
@@ -47,8 +46,9 @@ D(REV('2001:db8:302::/48'), REGISTRAR, DnsProvider(BIND),
|
||||
PTR("2001:db8:302::3", 'three.example.com.'), // 3.0.0...
|
||||
);
|
||||
```
|
||||
{% endcapture %}
|
||||
|
||||
{% include endExample.html %}
|
||||
{% include example.html content=example %}
|
||||
|
||||
In the future we plan on adding a flag to `A()` which will insert
|
||||
the correct PTR() record if the appropriate `D(REV()` domain (i.e. `.arpa` domain) has been
|
||||
|
||||
@@ -11,8 +11,7 @@ configured at the time the function is called. Calling this function early or la
|
||||
domains at the end of your configuration file.
|
||||
|
||||
Example for adding records to all configured domains:
|
||||
{% include startExample.html %}
|
||||
|
||||
{% capture example %}
|
||||
```js
|
||||
var domains = getConfiguredDomains();
|
||||
for(i = 0; i < domains.length; i++) {
|
||||
@@ -37,12 +36,12 @@ This will end up in following modifications:
|
||||
#1: CREATE TXT _important.domain2.tld "BLA" ttl=43200
|
||||
#2: REFRESH zone domain2.tld
|
||||
```
|
||||
{% endcapture %}
|
||||
|
||||
{% include endExample.html %}
|
||||
{% include example.html content=example %}
|
||||
|
||||
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.
|
||||
{% capture example %}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.
|
||||
|
||||
```js
|
||||
var domains = getConfiguredDomains();
|
||||
@@ -64,5 +63,6 @@ This will end up in following modifications:
|
||||
#3: CREATE TXT domain4.tld._report._dmarc.domain2.tld "v=DMARC1" ttl=43200
|
||||
#4: REFRESH zone domain2.tld
|
||||
```
|
||||
{% endcapture %}
|
||||
|
||||
{% include endExample.html %}
|
||||
{% include example.html content=example %}
|
||||
|
||||
@@ -18,8 +18,7 @@ the currently-loading file (which may not be the file where the
|
||||
is interpreted relative to the program's working directory at the time
|
||||
of the call.
|
||||
|
||||
{% include startExample.html %}
|
||||
|
||||
{% capture example %}
|
||||
```js
|
||||
// dnsconfig.js
|
||||
require('kubernetes/clusters.js');
|
||||
@@ -52,14 +51,14 @@ function includeK8Sdev() {
|
||||
return [ /* ... */ ];
|
||||
}
|
||||
```
|
||||
{% endcapture %}
|
||||
|
||||
{% include endExample.html %}
|
||||
{% include example.html content=example %}
|
||||
|
||||
You can also use it to require json files and initialize variables with it:
|
||||
For Example:
|
||||
|
||||
{% include startExample.html %}
|
||||
|
||||
{% capture example %}
|
||||
```js
|
||||
// dnsconfig.js
|
||||
var domains = require('./domain-ip-map.json')
|
||||
@@ -78,8 +77,9 @@ for (var domain in domains) {
|
||||
"myotherdomain.org": "5.5.5.5"
|
||||
}
|
||||
```
|
||||
{% endcapture %}
|
||||
|
||||
{% include endExample.html %}
|
||||
{% include example.html content=example %}
|
||||
|
||||
# Future
|
||||
|
||||
|
||||
Reference in New Issue
Block a user