fix(script): narrows case to just URL+MX to reduce the number of new dns records

This commit is contained in:
Akshay Nair
2022-05-15 21:42:29 +05:30
parent 99e45067b5
commit e153b5f75e
2 changed files with 15 additions and 17 deletions
+13 -15
View File
@@ -15,25 +15,23 @@ const toHostList = R.chain(data => {
// URL redirection must contain explicit A record
// Wildcard A record breaks when used with MX
// Ref: https://github.com/is-a-dev/register/issues/2365
if (data.record.URL) {
if (data.record.URL && data.record.MX) {
data.record.A = [ DOMAIN_HOST_IP ]
}
return R.pipe(
data.record,
getRecords,
R.chain(([recordType, values]) => {
const valueList = Array.isArray(values) ? values : [values];
const records = getRecords(data.record);
return valueList.map((value, index) => ({
name: data.name,
type: recordType,
address: address(recordType, value),
ttl: TTL,
...(recordType === 'MX' ? { priority: index + 20 } : {})
}))
}),
);
return R.chain(([recordType, values]) => {
const valueList = Array.isArray(values) ? values : [values];
return valueList.map((value, index) => ({
name: data.name,
type: recordType,
address: address(recordType, value),
ttl: TTL,
...(recordType === 'MX' ? { priority: index + 20 } : {})
}))
}, records)
});
const registerDomains = async ({ domainService, getDomains, log = () => { } }) => {
+2 -2
View File
@@ -95,7 +95,7 @@ const getDomainService = ({ cpanel }) => {
cpanel.zone.add
),
recordToZone,
print(({ name }) => `Adding zone for ${name}...`),
print(r => `Adding zone for ${r.name}: (${r.type} ${r.address})...`),
));
const removeZoneRecord = lazyTask(R.compose(
R.ifElse(R.propEq('type', 'MX'),
@@ -103,7 +103,7 @@ const getDomainService = ({ cpanel }) => {
R.compose(cpanel.zone.remove, R.pick(['line']))
),
recordToZone,
print(({ name }) => `Deleting zone for ${name}...`),
print(r => `Deleting zone for ${r.name}: (${r.type} ${r.address})...`),
));
const addRedirection = lazyTask(R.compose(
cpanel.redirection.add,