Add initial refreshDNS() function

This commit is contained in:
Johannes Zellner
2017-01-02 13:00:30 +01:00
parent a2bdd294a8
commit 3523974163

View File

@@ -22,6 +22,7 @@ exports = module.exports = {
checkDiskSpace: checkDiskSpace,
readDkimPublicKeySync: readDkimPublicKeySync,
refreshDNS: refreshDNS,
events: new (require('events').EventEmitter)(),
@@ -447,8 +448,8 @@ function txtRecordsWithSpf(callback) {
});
}
function addDnsRecords() {
var callback = NOOP_CALLBACK;
function addDnsRecords(callback) {
callback = typeof callback === 'function' ? callback : NOOP_CALLBACK;
if (process.env.BOX_ENV === 'test') return callback();
@@ -788,3 +789,21 @@ function migrate(options, callback) {
doMigrate(options, callback);
});
}
function refreshDNS(callback) {
assert.strictEqual(typeof callback, 'function');
sysinfo.getIp(function (error, ip) {
if (error) return callback(new CloudronError(CloudronError.INTERNAL_ERROR, error));
debug('refreshDNS: current ip %s', ip);
addDnsRecords(function (error) {
if (error) return callback(error);
debug('refreshDNS: done');
callback();
});
});
}