wait for dns with the correct zone even on external domain setup
This commit is contained in:
@@ -8,7 +8,6 @@ var assert = require('assert'),
|
|||||||
dig = require('../dig.js'),
|
dig = require('../dig.js'),
|
||||||
dns = require('dns'),
|
dns = require('dns'),
|
||||||
SubdomainError = require('../subdomains.js').SubdomainError,
|
SubdomainError = require('../subdomains.js').SubdomainError,
|
||||||
tld = require('tldjs'),
|
|
||||||
util = require('util');
|
util = require('util');
|
||||||
|
|
||||||
function isChangeSynced(domain, value, type, nameserver, callback) {
|
function isChangeSynced(domain, value, type, nameserver, callback) {
|
||||||
@@ -38,7 +37,7 @@ function isChangeSynced(domain, value, type, nameserver, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!answer || answer.length === 0) {
|
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);
|
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
|
// http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
|
||||||
value = new RegExp('^' + value.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + '$');
|
value = new RegExp('^' + value.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + '$');
|
||||||
}
|
}
|
||||||
|
|
||||||
debug('waitForIp: domain %s to be %s in zone %s.', domain, value, zoneName);
|
debug('waitForIp: domain %s to be %s in zone %s.', domain, value, zoneName);
|
||||||
|
|
||||||
var attempt = 1;
|
var attempt = 1;
|
||||||
|
|||||||
+7
-1
@@ -13,6 +13,7 @@ module.exports = exports = {
|
|||||||
var assert = require('assert'),
|
var assert = require('assert'),
|
||||||
config = require('./config.js'),
|
config = require('./config.js'),
|
||||||
settings = require('./settings.js'),
|
settings = require('./settings.js'),
|
||||||
|
tld = require('tldjs'),
|
||||||
util = require('util');
|
util = require('util');
|
||||||
|
|
||||||
function SubdomainError(reason, errorOrMessage) {
|
function SubdomainError(reason, errorOrMessage) {
|
||||||
@@ -129,7 +130,12 @@ function waitForDns(domain, value, type, options, callback) {
|
|||||||
settings.getDnsConfig(function (error, dnsConfig) {
|
settings.getDnsConfig(function (error, dnsConfig) {
|
||||||
if (error) return callback(new SubdomainError(SubdomainError.INTERNAL_ERROR, error));
|
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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user