Fixup other staticIp checks

This commit is contained in:
Johannes Zellner 2016-09-09 11:58:39 +02:00
parent 29dcc97da3
commit c3250eb37d
2 changed files with 6 additions and 3 deletions

View File

@ -444,12 +444,13 @@ Cloudron.prototype.setAutoupdatePattern = function (pattern) {
};
Cloudron.prototype.checkA = function (callback) {
var that = this;
var expectedIp = this._.isCustomDomain ? this._.staticIp : this._.ip;
dns.resolve4(this._box.domain, function (error, records) {
if (error) return callback(error);
if (records.length !== 1) return callback(new Error('Got ' + JSON.stringify(records) + ' A records. Expecting 1 length array'));
if (records[0] !== that._box.staticIp) return callback(new Error('Bad A record. ' + records[0] + '. Expecting ' + that._box.staticIp));
if (records[0] !== expectedIp) return callback(new Error('Bad A record. ' + records[0] + '. Expecting ' + expectedIp));
callback(null, records);
});

View File

@ -153,9 +153,11 @@ describe('Cloudron backup testing', function () {
});
it('wait for local dns', function () {
var expectedIp = box.isCustomDomain ? box.staticIp : box.ip;
for (var i = 0; i < 50; i++) {
var ip = dnsSync.resolve(box.domain);
if (ip === box.staticIp) return;
if (ip === expectedIp) return;
console.log('waiting for local dns to change from %s to %s', ip, box.staticIp);
sleep(30);