2016-10-07 13:14:27 -07:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
exports = module.exports = {
|
|
|
|
|
upsert: upsert,
|
|
|
|
|
get: get,
|
|
|
|
|
del: del,
|
2017-01-10 11:13:33 +01:00
|
|
|
waitForDns: waitForDns,
|
|
|
|
|
verifyDnsConfig: verifyDnsConfig
|
2016-10-07 13:14:27 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var assert = require('assert'),
|
2016-10-08 13:00:40 -07:00
|
|
|
debug = require('debug')('box:dns/noop'),
|
2016-10-07 13:14:27 -07:00
|
|
|
util = require('util');
|
|
|
|
|
|
|
|
|
|
function upsert(dnsConfig, zoneName, subdomain, type, values, callback) {
|
|
|
|
|
assert.strictEqual(typeof dnsConfig, 'object');
|
|
|
|
|
assert.strictEqual(typeof zoneName, 'string');
|
|
|
|
|
assert.strictEqual(typeof subdomain, 'string');
|
|
|
|
|
assert.strictEqual(typeof type, 'string');
|
|
|
|
|
assert(util.isArray(values));
|
|
|
|
|
assert.strictEqual(typeof callback, 'function');
|
|
|
|
|
|
|
|
|
|
debug('upsert: %s for zone %s of type %s with values %j', subdomain, zoneName, type, values);
|
|
|
|
|
|
2018-06-29 22:25:34 +02:00
|
|
|
return callback(null);
|
2016-10-07 13:14:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get(dnsConfig, zoneName, subdomain, type, callback) {
|
|
|
|
|
assert.strictEqual(typeof dnsConfig, 'object');
|
|
|
|
|
assert.strictEqual(typeof zoneName, 'string');
|
|
|
|
|
assert.strictEqual(typeof subdomain, 'string');
|
|
|
|
|
assert.strictEqual(typeof type, 'string');
|
|
|
|
|
assert.strictEqual(typeof callback, 'function');
|
|
|
|
|
|
2016-10-08 14:38:59 -07:00
|
|
|
callback(null, [ ]); // returning ip confuses apptask into thinking the entry already exists
|
2016-10-07 13:14:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function del(dnsConfig, zoneName, subdomain, type, values, callback) {
|
|
|
|
|
assert.strictEqual(typeof dnsConfig, 'object');
|
|
|
|
|
assert.strictEqual(typeof zoneName, 'string');
|
|
|
|
|
assert.strictEqual(typeof subdomain, 'string');
|
|
|
|
|
assert.strictEqual(typeof type, 'string');
|
|
|
|
|
assert(util.isArray(values));
|
|
|
|
|
assert.strictEqual(typeof callback, 'function');
|
|
|
|
|
|
|
|
|
|
return callback();
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-08 14:19:14 -08:00
|
|
|
function waitForDns(domain, zoneName, value, options, callback) {
|
2016-12-14 13:22:54 -08:00
|
|
|
assert.strictEqual(typeof domain, 'string');
|
2017-06-11 22:12:23 -07:00
|
|
|
assert.strictEqual(typeof zoneName, 'string');
|
2018-02-08 14:19:14 -08:00
|
|
|
assert.strictEqual(typeof value, 'string');
|
2016-12-14 13:22:54 -08:00
|
|
|
assert(options && typeof options === 'object'); // { interval: 5000, times: 50000 }
|
|
|
|
|
assert.strictEqual(typeof callback, 'function');
|
|
|
|
|
|
|
|
|
|
callback();
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-11 22:32:05 -07:00
|
|
|
function verifyDnsConfig(dnsConfig, domain, zoneName, ip, callback) {
|
2017-01-10 11:13:33 +01:00
|
|
|
assert.strictEqual(typeof dnsConfig, 'object');
|
|
|
|
|
assert.strictEqual(typeof domain, 'string');
|
2017-06-11 22:32:05 -07:00
|
|
|
assert.strictEqual(typeof zoneName, 'string');
|
2017-01-10 11:13:33 +01:00
|
|
|
assert.strictEqual(typeof ip, 'string');
|
|
|
|
|
assert.strictEqual(typeof callback, 'function');
|
|
|
|
|
|
2018-01-09 14:46:38 -08:00
|
|
|
return callback(null, { });
|
2017-01-10 11:13:33 +01:00
|
|
|
}
|