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

NEW FEATURE: IGNORE() (diff2 only) (#2388)

Co-authored-by: Jeffrey Cafferata <jeffrey@jcid.nl>
This commit is contained in:
Tom Limoncelli
2023-05-24 15:14:36 -04:00
committed by GitHub
parent 64f083af4e
commit 0b7dabacc8
20 changed files with 890 additions and 159 deletions

View File

@@ -809,10 +809,56 @@ function format_tt(transform_table) {
return lines.join(' ; ');
}
// IGNORE(name)
function IGNORE(name) {
// deprecated, use IGNORE_NAME
return IGNORE_NAME(name);
//function UNMANAGED(label_pattern, rType_pattern, target_pattern) {
// return function (d) {
// d.unmanaged.push({
// label_pattern: label_pattern,
// rType_pattern: rType_pattern,
// target_pattern: target_pattern,
// });
// };
//}
function DISABLE_IGNORE_SAFETY_CHECK(d) {
// This disables a safety check intended to prevent DNSControl and
// another system getting into a battle as they both try to update
// the same record over and over, back and forth. However, people
// kept asking for it so... caveat emptor!
// It only affects the current domain.
d.unmanaged_disable_safety_check = true;
}
var IGNORE_NAME_DISABLE_SAFETY_CHECK = {
ignore_name_disable_safety_check: 'true',
// (NOTE: diff1 only.)
// This disables a safety check intended to prevent:
// 1. Two owners toggling a record between two settings.
// 2. The other owner wiping all records at this label, which won't
// be noticed until the next time dnscontrol is run.
// See https://github.com/StackExchange/dnscontrol/issues/1106
};
// IGNORE(labelPattern, rtypePattern, targetPattern)
function IGNORE(labelPattern, rtypePattern, targetPattern) {
if (labelPattern === undefined) {
labelPattern = '*';
}
if (rtypePattern === undefined) {
rtypePattern = '*';
}
if (targetPattern === undefined) {
targetPattern = '*';
}
return function (d) {
// diff1
d.ignored_names.push({ pattern: labelPattern, types: rtypePattern });
// diff2
d.unmanaged.push({
label_pattern: labelPattern,
rType_pattern: rtypePattern,
target_pattern: targetPattern,
});
};
}
// IGNORE_NAME(name, rTypes)
@@ -821,7 +867,9 @@ function IGNORE_NAME(name, rTypes) {
rTypes = '*';
}
return function (d) {
// diff1
d.ignored_names.push({ pattern: name, types: rTypes });
// diff2
d.unmanaged.push({
label_pattern: name,
rType_pattern: rTypes,
@@ -829,18 +877,11 @@ function IGNORE_NAME(name, rTypes) {
};
}
var IGNORE_NAME_DISABLE_SAFETY_CHECK = {
ignore_name_disable_safety_check: 'true',
// This disables a safety check intended to prevent:
// 1. Two owners toggling a record between two settings.
// 2. The other owner wiping all records at this label, which won't
// be noticed until the next time dnscontrol is run.
// See https://github.com/StackExchange/dnscontrol/issues/1106
};
function IGNORE_TARGET(target, rType) {
return function (d) {
// diff1
d.ignored_targets.push({ pattern: target, type: rType });
// diff2
d.unmanaged.push({
rType_pattern: rType,
target_pattern: target,
@@ -902,25 +943,6 @@ function AUTODNSSEC(d) {
);
}
function UNMANAGED(label_pattern, rType_pattern, target_pattern) {
return function (d) {
d.unmanaged.push({
label_pattern: label_pattern,
rType_pattern: rType_pattern,
target_pattern: target_pattern,
});
};
}
function DISABLE_UNMANAGED_SAFETY_CHECK(d) {
// This disables a safety check intended to prevent DNSControl and
// another system getting into a battle as they both try to update
// the same record over and over, back and forth. However, people
// kept asking for it so... caveat emptor!
// It only affects the current domain.
d.unmanaged_disable_safety_check = true;
}
/**
* @deprecated
*/

View File

@@ -8,3 +8,16 @@ D("foo.com", "none"
, IGNORE_NAME("@")
, IGNORE_TARGET("@", "CNAME")
);
D("diff2.com", "none"
, IGNORE("mylabel")
, IGNORE("mylabel2", "")
, IGNORE("mylabel3", "", "")
, IGNORE("", "A")
, IGNORE("", "A,AAAA")
, IGNORE("", "", "mytarget")
, IGNORE("labelc", "CNAME", "targetc")
// Compatibility mode:
, IGNORE_NAME("nametest")
, IGNORE_TARGET("targettest1")
, IGNORE_TARGET("targettest2", "A")
);

View File

@@ -66,7 +66,8 @@
},
{
"label_pattern": "legacyignore",
"rType_pattern": "*"
"rType_pattern": "*",
"target_pattern": "*"
},
{
"label_pattern": "@",
@@ -77,6 +78,97 @@
"target_pattern": "@"
}
]
},
{
"name": "diff2.com",
"registrar": "none",
"dnsProviders": {},
"records": [],
"ignored_names": [
{
"pattern": "mylabel",
"types": "*"
},
{
"pattern": "mylabel2",
"types": ""
},
{
"pattern": "mylabel3",
"types": ""
},
{
"pattern": "",
"types": "A"
},
{
"pattern": "",
"types": "A,AAAA"
},
{
"pattern": "",
"types": ""
},
{
"pattern": "labelc",
"types": "CNAME"
},
{
"pattern": "nametest",
"types": "*"
}
],
"ignored_targets": [
{
"pattern": "targettest1",
"type": ""
},
{
"pattern": "targettest2",
"type": "A"
}
],
"unmanaged": [
{
"label_pattern": "mylabel",
"rType_pattern": "*",
"target_pattern": "*"
},
{
"label_pattern": "mylabel2",
"target_pattern": "*"
},
{
"label_pattern": "mylabel3"
},
{
"rType_pattern": "A",
"target_pattern": "*"
},
{
"rType_pattern": "A,AAAA",
"target_pattern": "*"
},
{
"target_pattern": "mytarget"
},
{
"label_pattern": "labelc",
"rType_pattern": "CNAME",
"target_pattern": "targetc"
},
{
"label_pattern": "nametest",
"rType_pattern": "*"
},
{
"target_pattern": "targettest1"
},
{
"rType_pattern": "A",
"target_pattern": "targettest2"
}
]
}
]
}
}

View File

@@ -16,9 +16,10 @@
"unmanaged": [
{
"label_pattern": "\\*.testignore",
"rType_pattern": "*"
"rType_pattern": "*",
"target_pattern": "*"
}
]
}
]
}
}

View File

@@ -1,9 +0,0 @@
D("foo.com", "none"
, UNMANAGED("", "", "targetGlob1")
, UNMANAGED("", "CNAME", "")
, UNMANAGED("", "A", "targetGlob3")
, UNMANAGED("lab4")
, UNMANAGED("notype", "", "targetGlob5")
, UNMANAGED("lab6", "A, CNAME")
, UNMANAGED("lab7", "TXT", "targetGlob7")
);

View File

@@ -1,40 +0,0 @@
{
"dns_providers": [],
"domains": [
{
"dnsProviders": {},
"name": "foo.com",
"records": [],
"registrar": "none",
"unmanaged": [
{
"target_pattern": "targetGlob1"
},
{
"rType_pattern": "CNAME"
},
{
"rType_pattern": "A",
"target_pattern": "targetGlob3"
},
{
"label_pattern": "lab4"
},
{
"label_pattern": "notype",
"target_pattern": "targetGlob5"
},
{
"label_pattern": "lab6",
"rType_pattern": "A, CNAME"
},
{
"label_pattern": "lab7",
"rType_pattern": "TXT",
"target_pattern": "targetGlob7"
}
]
}
],
"registrars": []
}

View File

@@ -1,5 +1,5 @@
D("unsafe.com", "none"
, DISABLE_UNMANAGED_SAFETY_CHECK
, DISABLE_IGNORE_SAFETY_CHECK
);
D("safe.com", "none"
);