Do not rely on admin subdomain for dns backend config validation

This commit is contained in:
Johannes Zellner
2017-11-07 23:13:58 +01:00
parent c723b289dc
commit e1be8b669f
4 changed files with 41 additions and 15 deletions
+11 -3
View File
@@ -256,12 +256,20 @@ function verifyDnsConfig(dnsConfig, fqdn, zoneName, ip, callback) {
return callback(new DomainError(DomainError.BAD_FIELD, 'Domain nameservers are not set to Cloudflare')); return callback(new DomainError(DomainError.BAD_FIELD, 'Domain nameservers are not set to Cloudflare'));
} }
upsert(credentials, zoneName, 'my', 'A', [ ip ], function (error, changeId) { const testSubdomain = 'cloudrontestdns';
upsert(credentials, zoneName, testSubdomain, 'A', [ ip ], function (error, changeId) {
if (error) return callback(error); if (error) return callback(error);
debug('verifyDnsConfig: A record added with change id %s', changeId); debug('verifyDnsConfig: Test A record added with change id %s', changeId);
callback(null, credentials); del(dnsConfig, zoneName, testSubdomain, 'A', [ ip ], function (error) {
if (error) return callback(error);
debug('verifyDnsConfig: Test A record removed again');
callback(null, credentials);
});
}); });
}); });
}); });
+10 -4
View File
@@ -221,14 +221,20 @@ function verifyDnsConfig(dnsConfig, fqdn, zoneName, ip, callback) {
return callback(new DomainError(DomainError.BAD_FIELD, 'Domain nameservers are not set to Digital Ocean')); return callback(new DomainError(DomainError.BAD_FIELD, 'Domain nameservers are not set to Digital Ocean'));
} }
const name = config.adminLocation() + (fqdn === zoneName ? '' : '.' + fqdn.slice(0, - zoneName.length - 1)); const testSubdomain = 'cloudrontestdns';
upsert(credentials, zoneName, name, 'A', [ ip ], function (error, changeId) { upsert(credentials, zoneName, testSubdomain, 'A', [ ip ], function (error, changeId) {
if (error) return callback(error); if (error) return callback(error);
debug('verifyDnsConfig: A record added with change id %s', changeId); debug('verifyDnsConfig: Test A record added with change id %s', changeId);
callback(null, credentials); del(dnsConfig, zoneName, testSubdomain, 'A', [ ip ], function (error) {
if (error) return callback(error);
debug('verifyDnsConfig: Test A record removed again');
callback(null, credentials);
});
}); });
}); });
} }
+10 -4
View File
@@ -187,14 +187,20 @@ function verifyDnsConfig(dnsConfig, fqdn, zoneName, ip, callback) {
return callback(new DomainError(DomainError.BAD_FIELD, 'Domain nameservers are not set to Google Cloud DNS')); return callback(new DomainError(DomainError.BAD_FIELD, 'Domain nameservers are not set to Google Cloud DNS'));
} }
const name = config.adminLocation() + (fqdn === zoneName ? '' : '.' + fqdn.slice(0, - zoneName.length - 1)); const testSubdomain = 'cloudrontestdns';
upsert(credentials, zoneName, name, 'A', [ ip ], function (error, changeId) { upsert(credentials, zoneName, testSubdomain, 'A', [ ip ], function (error, changeId) {
if (error) return callback(error); if (error) return callback(error);
debug('verifyDnsConfig: A record added with change id %s', changeId); debug('verifyDnsConfig: Test A record added with change id %s', changeId);
callback(null, credentials); del(dnsConfig, zoneName, testSubdomain, 'A', [ ip ], function (error) {
if (error) return callback(error);
debug('verifyDnsConfig: Test A record removed again');
callback(null, credentials);
});
}); });
}); });
}); });
+10 -4
View File
@@ -247,14 +247,20 @@ function verifyDnsConfig(dnsConfig, fqdn, zoneName, ip, callback) {
return callback(new DomainError(DomainError.BAD_FIELD, 'Domain nameservers are not set to Route53')); return callback(new DomainError(DomainError.BAD_FIELD, 'Domain nameservers are not set to Route53'));
} }
const name = config.adminLocation() + (fqdn === zoneName ? '' : '.' + fqdn.slice(0, - zoneName.length - 1)); const testSubdomain = 'cloudrontestdns';
upsert(credentials, zoneName, name, 'A', [ ip ], function (error, changeId) { upsert(credentials, zoneName, testSubdomain, 'A', [ ip ], function (error, changeId) {
if (error) return callback(error); if (error) return callback(error);
debug('verifyDnsConfig: A record added with change id %s', changeId); debug('verifyDnsConfig: Test A record added with change id %s', changeId);
callback(null, credentials); del(dnsConfig, zoneName, testSubdomain, 'A', [ ip ], function (error) {
if (error) return callback(error);
debug('verifyDnsConfig: Test A record removed again');
callback(null, credentials);
});
}); });
}); });
}); });