diff --git a/src/dns/waitfordns.js b/src/dns/waitfordns.js index b271d8ae7..3e2dc2365 100644 --- a/src/dns/waitfordns.js +++ b/src/dns/waitfordns.js @@ -8,7 +8,6 @@ var assert = require('assert'), dig = require('../dig.js'), dns = require('dns'), SubdomainError = require('../subdomains.js').SubdomainError, - tld = require('tldjs'), util = require('util'); function isChangeSynced(domain, value, type, nameserver, callback) { @@ -38,7 +37,7 @@ function isChangeSynced(domain, value, type, nameserver, callback) { } if (!answer || answer.length === 0) { - debug('bad answer from nameserver %s (%s) resolving %s (%s): %j', nameserver, nsIp, domain, type, answer); + debug('bad answer from nameserver %s (%s) resolving %s (%s)', nameserver, nsIp, domain, type); return iteratorCallback(null, false); } @@ -72,6 +71,7 @@ function waitForDns(domain, zoneName, value, type, options, callback) { // http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript value = new RegExp('^' + value.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + '$'); } + debug('waitForIp: domain %s to be %s in zone %s.', domain, value, zoneName); var attempt = 1; diff --git a/src/subdomains.js b/src/subdomains.js index 6d3a688be..19e6b8cc8 100644 --- a/src/subdomains.js +++ b/src/subdomains.js @@ -13,6 +13,7 @@ module.exports = exports = { var assert = require('assert'), config = require('./config.js'), settings = require('./settings.js'), + tld = require('tldjs'), util = require('util'); function SubdomainError(reason, errorOrMessage) { @@ -129,7 +130,12 @@ function waitForDns(domain, value, type, options, callback) { settings.getDnsConfig(function (error, dnsConfig) { if (error) return callback(new SubdomainError(SubdomainError.INTERNAL_ERROR, error)); - api(dnsConfig.provider).waitForDns(domain, config.zoneName(), value, type, options, callback); + var zoneName = config.zoneName(); + + // if the domain is on another zone in case of external domain, use the correct zone + if (!domain.endsWith(zoneName)) zoneName = tld.getDomain(domain); + + api(dnsConfig.provider).waitForDns(domain, zoneName, value, type, options, callback); }); }