Skip to content

Commit

Permalink
test single redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
wdhdev authored Oct 19, 2024
1 parent efedee3 commit f63a352
Showing 1 changed file with 35 additions and 28 deletions.
63 changes: 35 additions & 28 deletions dnsconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ function getDomainsList(filesPath) {
var domains = getDomainsList("./domains");
var commit = [];

for (var idx in domains) {
var subdomainName = domains[idx].name;
var domainData = domains[idx].data;
for (var subdomain in domains) {
var subdomainName = domains[subdomain].name;
var fullSubdomain = subdomainName + ".is-a.dev";
var domainData = domains[subdomain].data;
var proxyState = domainData.proxied ? { cloudflare_proxy: "on" } : { cloudflare_proxy: "off" };

// Handle A records
Expand Down Expand Up @@ -89,32 +90,38 @@ for (var idx in domains) {
commit.push(
A(subdomainName, "45.85.238.5", { cloudflare_proxy: "on" }),
TXT("_redirect." + subdomainName, "v=txtv0;type=host;to=" + domainData.record.URL)
);
)
}

// Exceptions
// is-a.dev
commit.push(IGNORE("@", "MX"));
commit.push(IGNORE("@", "TXT"));
// *.is-a.dev
commit.push(IGNORE("\\*"));
// _acme-challenge.is-a.dev
commit.push(IGNORE("_acme-challenge", "TXT"));
// _dmarc.is-a.dev
commit.push(IGNORE("_dmarc", "TXT"));
// ns1.is-a.dev
commit.push(IGNORE("ns1", "A"));
commit.push(IGNORE("ns1", "AAAA"));
// ns2.is-a.dev
commit.push(IGNORE("ns2", "A"));
commit.push(IGNORE("ns2", "AAAA"));
// ns3.is-a.dev
commit.push(IGNORE("ns3", "A"));
commit.push(IGNORE("ns3", "AAAA"));
// ns4.is-a.dev
commit.push(IGNORE("ns4", "A"));
commit.push(IGNORE("ns4", "AAAA"));
}

// Test
commit.push(
A("test", "192.0.2.1", { cloudflare_proxy: "on" }),
CF_SINGLE_REDIRECT("test.is-a.dev", 302, 'http.host eq "test.is-a.dev"', "https://google.com")
)

// Exceptions
// is-a.dev
commit.push(IGNORE("@", "MX"));
commit.push(IGNORE("@", "TXT"));
// *.is-a.dev
commit.push(IGNORE("\\*"));
// _acme-challenge.is-a.dev
commit.push(IGNORE("_acme-challenge", "TXT"));
// _dmarc.is-a.dev
commit.push(IGNORE("_dmarc", "TXT"));
// ns1.is-a.dev
commit.push(IGNORE("ns1", "A"));
commit.push(IGNORE("ns1", "AAAA"));
// ns2.is-a.dev
commit.push(IGNORE("ns2", "A"));
commit.push(IGNORE("ns2", "AAAA"));
// ns3.is-a.dev
commit.push(IGNORE("ns3", "A"));
commit.push(IGNORE("ns3", "AAAA"));
// ns4.is-a.dev
commit.push(IGNORE("ns4", "A"));
commit.push(IGNORE("ns4", "AAAA"));

// Commit all DNS records
D("is-a.dev", NewRegistrar("none"), DnsProvider(NewDnsProvider("cloudflare")), commit);
D("is-a.dev", NewRegistrar("none"), DnsProvider(NewDnsProvider("cloudflare", { "manage_single_redirects": true })), commit);

0 comments on commit f63a352

Please sign in to comment.