diff --git a/src/dns/cloudflare.js b/src/dns/cloudflare.js index c78343de2..aa8752ba3 100644 --- a/src/dns/cloudflare.js +++ b/src/dns/cloudflare.js @@ -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')); } - 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); - 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); + }); }); }); }); diff --git a/src/dns/digitalocean.js b/src/dns/digitalocean.js index e8ed1b8a0..9f67ebe53 100644 --- a/src/dns/digitalocean.js +++ b/src/dns/digitalocean.js @@ -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')); } - 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); - 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); + }); }); }); } diff --git a/src/dns/gcdns.js b/src/dns/gcdns.js index 6b06c8bbe..9a0eed6b7 100644 --- a/src/dns/gcdns.js +++ b/src/dns/gcdns.js @@ -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')); } - 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); - 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); + }); }); }); }); diff --git a/src/dns/route53.js b/src/dns/route53.js index 3c9b7140a..51ba34615 100644 --- a/src/dns/route53.js +++ b/src/dns/route53.js @@ -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')); } - 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); - 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); + }); }); }); });