infrastructure/dns/functions.js

73 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

2024-09-24 23:10:59 +00:00
function service(target, domain, host, alias) {
return {
target: target,
domain: domain,
host: hosts[host],
alias: alias,
record: function() {
return my_host_record(this.target, this.resolve_host());
},
resolve_host: function() {
if (this.alias) {
return services[this.alias].resolve_host();
}
return this.host;
}
};
}
function collect_services(domain) {
var result = [];
for (var key in services) {
var s = services[key];
if (s.domain == domain) {
result.push(s.record());
}
}
return result;
}
function my_host_record(target, host) {
2024-10-29 13:10:54 +00:00
switch (target) {
case "db":
return [
A(target, host.ipv4_address_vpn),
AAAA(target, host.ipv6_address_vpn)
];
default:
return [
A(target, host.ipv4_address),
AAAA(target, host.ipv6_address)
];
}
2024-09-24 23:10:59 +00:00
}
function verify_amazon_ses(dkims) {
var result = [];
for (var i in dkims) {
var my_dkim = dkims[i] + "._domainkey";
var ses_dkim = dkims[i] + ".dkim.amazonses.com.";
result.push(CNAME(my_dkim, ses_dkim));
}
return result;
}
function acme_challenge(subd, target) {
var final_subd = "_acme-challenge";
if (subd) {
final_subd += "." + subd;
}
final_target = target + ".acme.serguzim.me.";
return CNAME(final_subd, final_target);
}
function verify_dmarc_reports(domains) {
var result = [];
for (d in domains) {
result.push(TXT(d + "._report._dmarc", "v=DMARC1"));
}
return result;
}