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

Add INCLUDE statement to include records from other domains (#1219)

This commit is contained in:
Vincent Hagen
2021-07-25 18:03:58 +02:00
committed by GitHub
parent 243762d171
commit 6fc3534aa3
5 changed files with 149 additions and 3 deletions

View File

@ -103,6 +103,16 @@ function D(name, registrar) {
conf.domain_names.push(name);
}
function INCLUDE(name) {
var domain = _getDomainObject(name);
if (domain == null) {
throw name + ' was not declared yet and therefore cannot be updated. Use D() before.';
}
return function(d) {
d.records.push.apply(d.records, domain.obj.records);
}
}
// D_EXTEND(name): Update a DNS Domain already added with D(), or subdomain thereof
function D_EXTEND(name) {
var domain = _getDomainObject(name);

View File

@ -0,0 +1,12 @@
var REG = NewRegistrar("Third-Party","NONE");
var CF = NewDnsProvider("Cloudflare", "CLOUDFLAREAPI");
D("foo.com!external",REG,DnsProvider(CF),
A("@","1.2.3.4")
);
D("foo.com!internal",REG,DnsProvider(CF),
INCLUDE("foo.com!external"),
A("local","127.0.0.1")
);

View File

@ -0,0 +1,49 @@
{
"registrars": [
{
"name": "Third-Party",
"type": "NONE"
}
],
"dns_providers": [
{
"name": "Cloudflare",
"type": "CLOUDFLAREAPI"
}
],
"domains": [
{
"name": "foo.com!external",
"registrar": "Third-Party",
"dnsProviders": {
"Cloudflare": -1
},
"records": [
{
"type": "A",
"name": "@",
"target": "1.2.3.4"
}
]
},
{
"name": "foo.com!internal",
"registrar": "Third-Party",
"dnsProviders": {
"Cloudflare": -1
},
"records": [
{
"type": "A",
"name": "@",
"target": "1.2.3.4"
},
{
"type": "A",
"name": "local",
"target": "127.0.0.1"
}
]
}
]
}