Add DNS wildcard backend

It assumes that the user setup the wildcard DNS entry manually.
This commit is contained in:
Girish Ramakrishnan
2016-10-07 13:14:27 -07:00
parent e456c4b39c
commit 49e3dba1f2

62
src/dns/wildcard.js Normal file
View File

@@ -0,0 +1,62 @@
'use strict';
exports = module.exports = {
upsert: upsert,
get: get,
del: del,
getChangeStatus: getChangeStatus
};
var assert = require('assert'),
debug = require('debug')('box:dns/wildcard'),
SubdomainError = require('../subdomains.js').SubdomainError,
sysinfo = require('..sysinfo.js'),
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);
return callback();
}
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');
if (type !== 'A') return callback(null, [ ]);
sysinfo.getIp(function (error, ip) {
if (error) return callback(new SubdomainError(SubdomainError.INTERNAL_ERROR, error.message));
return callback(null, [ ip ]);
});
}
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();
}
function getChangeStatus(dnsConfig, changeId, callback) {
assert.strictEqual(typeof dnsConfig, 'object');
assert.strictEqual(typeof changeId, 'string');
assert.strictEqual(typeof callback, 'function');
callback(null, 'INSYNC');
}