"use strict"; var conf = { registrars: [], dns_providers: [], domains: [] }; var defaultArgs = []; function initialize(){ conf = { registrars: [], dns_providers: [], domains: [] }; defaultArgs = []; } function NewRegistrar(name,type,meta) { if (type) { type == "MANUAL"; } var reg = {name: name, type: type, meta: meta}; conf.registrars.push(reg); return name; } function NewDnsProvider(name, type, meta) { if ((typeof meta === 'object') && ('ip_conversions' in meta)) { meta.ip_conversions = format_tt(meta.ip_conversions) } var dsp = {name: name, type: type, meta: meta}; conf.dns_providers.push(dsp); return name; } function newDomain(name,registrar) { return {name: name, registrar: registrar, meta:{}, records:[], dnsProviders: {}, defaultTTL: 0, nameservers:[]}; } function processDargs(m, domain) { // for each modifier, if it is a... // function: call it with domain // array: process recursively // object: merge it into metadata if (_.isFunction(m)) { m(domain); } else if (_.isArray(m)) { for (var j in m) { processDargs(m[j], domain) } } else if (_.isObject(m)) { _.extend(domain.meta,m); } else { throw "WARNING: domain modifier type unsupported: "+ typeof m + " Domain: "+ domain.name; } } // D(name,registrar): Create a DNS Domain. Use the parameters as records and mods. function D(name,registrar) { var domain = newDomain(name,registrar); for (var i = 0; i< defaultArgs.length; i++){ processDargs(defaultArgs[i],domain) } for (var i = 2; i 0; i--) { num = Math.floor(num/256); d = num%256 + '.' + d; } return d; }