wait for dns with the correct zone even on external domain setup

This commit is contained in:
Johannes Zellner
2017-06-21 15:04:39 +02:00
parent 77558c823c
commit f994b68701
2 changed files with 9 additions and 3 deletions

View File

@@ -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;

View File

@@ -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);
});
}