117 lines
2.5 KiB
JavaScript
117 lines
2.5 KiB
JavaScript
//////////////////////////////////////////////////////////////////////////
|
|
// providers section
|
|
|
|
var REG_NONE = NewRegistrar('none');
|
|
var PDNS = NewDnsProvider(
|
|
'powerdns',
|
|
{
|
|
'dnssec_on_create': true
|
|
}
|
|
);
|
|
var CLOUDFLARE = NewDnsProvider(
|
|
'cloudflare'
|
|
);
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// turn off cloudflare proxying by default
|
|
|
|
DEFAULTS(
|
|
CF_PROXY_DEFAULT_OFF
|
|
);
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// some global variables and constants
|
|
|
|
// the current domain
|
|
var domain;
|
|
|
|
// dn42 reverse zones follow RFC2317
|
|
REVCOMPAT('rfc2317')
|
|
|
|
// reverse maps
|
|
var rev4_map = [ ]
|
|
var rev6_map = [ ]
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// determine reverse zones from maps
|
|
|
|
function rev4_zone(ipv4)
|
|
{
|
|
var num = IP(ipv4)
|
|
|
|
for (var i = 0; i < rev4_map.length; i++) {
|
|
|
|
z = rev4_map[i]
|
|
|
|
var prefix = z[0]
|
|
var mask = z[1]
|
|
var zone = z[2]
|
|
|
|
if (((num & mask) >>> 0) == prefix) {
|
|
return zone
|
|
}
|
|
}
|
|
|
|
console.log("rev4_zone failed to find match: " + ipv4)
|
|
return undefined
|
|
}
|
|
|
|
function rev6_zone(ipv6)
|
|
{
|
|
for (var i = 0; i < rev6_map.length; i++) {
|
|
|
|
z = rev6_map[i]
|
|
|
|
var prefix = z[0]
|
|
var zone = z[1]
|
|
var plen = prefix.length
|
|
|
|
if (ipv6.substring(0, plen) == prefix) {
|
|
return zone
|
|
}
|
|
}
|
|
|
|
console.log("rev6_zone failed to find match: " + ipv6)
|
|
return undefined
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// return the fqdn for a name
|
|
|
|
function fqdn(name)
|
|
{
|
|
if (name === '@') {
|
|
return domain+'.';
|
|
}
|
|
return name+"."+domain+'.';
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// add a forward and reverse zone record
|
|
|
|
function host(name, ipv6, ipv4)
|
|
{
|
|
if (typeof ipv6 !== 'undefined') {
|
|
D_EXTEND(domain, AAAA(name, ipv6))
|
|
var z6 = rev6_zone(ipv6)
|
|
D_EXTEND(z6, PTR(ipv6, fqdn(name)))
|
|
}
|
|
|
|
if (typeof ipv4 !== 'undefined') {
|
|
D_EXTEND(domain, A(name, ipv4))
|
|
var z4 = rev4_zone(ipv4)
|
|
D_EXTEND(z4, PTR(ipv4, fqdn(name)))
|
|
}
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// import dynamic info
|
|
require_glob('dynamic/', false)
|
|
|
|
// import individual domain files
|
|
require_glob('domains/', false)
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// end of file
|