From 92dc6c6298eb5aeebe695d6eea5fbe9d7a06c214 Mon Sep 17 00:00:00 2001 From: William Harrison <87287585+wdhdev@users.noreply.github.com> Date: Wed, 23 Apr 2025 21:35:15 +0800 Subject: [PATCH] changes to internal domains --- tests/json.test.js | 17 ++++++++++------- util/excluded.json | 6 ------ util/internal.json | 8 ++++++++ util/raw-api.js | 32 +++++++++++++++++++++++++++++--- util/reserved.json | 6 ------ 5 files changed, 47 insertions(+), 22 deletions(-) delete mode 100644 util/excluded.json create mode 100644 util/internal.json diff --git a/tests/json.test.js b/tests/json.test.js index b27738d63..16d73c67e 100644 --- a/tests/json.test.js +++ b/tests/json.test.js @@ -30,8 +30,9 @@ const optionalRedirectConfigFields = { const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; const hostnameRegex = /^(?=.{1,253}$)(?:(?:[_a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)\.)+[a-zA-Z]{2,63}$/; -const excludedDomains = require("../util/excluded.json"); +const internalDomains = require("../util/internal.json"); const reservedDomains = require("../util/reserved.json"); + const domainsPath = path.resolve("domains"); const files = fs.readdirSync(domainsPath); @@ -84,7 +85,7 @@ async function validateFields(t, obj, fields, file, prefix = "") { if (obj.hasOwnProperty(key)) { t.is(typeof obj[key], fields[key], `${file}: Field ${fieldPath} should be of type ${fields[key]}`); - } else if (fields === requiredFields) { + } else if (fields === requiredFields || fields === requiredOwnerFields) { t.true(false, `${file}: Missing required field: ${fieldPath}`); } } @@ -103,17 +104,19 @@ async function validateFileName(t, file) { hostnameRegex, `${file}: FQDN must be 1-253 characters, can use letters, numbers, dots, and non-consecutive hyphens.` ); + t.false(internalDomains.includes(subdomain), `${file}: Subdomain name is registered internally`); t.false(reservedDomains.includes(subdomain), `${file}: Subdomain name is reserved`); t.true( - !reservedDomains.some((reserved) => subdomain.endsWith(`.${reserved}`)), + !internalDomains.some((i) => subdomain.endsWith(`.${i}`)), + `${file}: Subdomain name is registered internally` + ); + t.true( + !reservedDomains.some((r) => subdomain.endsWith(`.${r}`)), `${file}: Subdomain name is reserved` ); const rootSubdomain = subdomain.split(".").pop(); - - if (!excludedDomains.includes(rootSubdomain)) { - t.false(rootSubdomain.startsWith("_"), `${file}: Root subdomains should not start with an underscore`); - } + t.false(rootSubdomain.startsWith("_"), `${file}: Root subdomains should not start with an underscore`); } async function processFile(file, t) { diff --git a/util/excluded.json b/util/excluded.json deleted file mode 100644 index 9f7268d2e..000000000 --- a/util/excluded.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - "_discord", - "_psl", - "_gh-is-a-dev-o", - "_github-pages-challenge-is-a-dev" -] diff --git a/util/internal.json b/util/internal.json new file mode 100644 index 000000000..5e71fc3d1 --- /dev/null +++ b/util/internal.json @@ -0,0 +1,8 @@ +[ + "autoconfig", + "autodiscover", + "data", + "docs", + "raw", + "www" +] diff --git a/util/raw-api.js b/util/raw-api.js index 92ec27992..22cae7621 100644 --- a/util/raw-api.js +++ b/util/raw-api.js @@ -3,6 +3,7 @@ const path = require("path"); const directoryPath = path.join(__dirname, "../domains"); const reserved = require(path.join(__dirname, "reserved.json")); +const internal = require(path.join(__dirname, "internal.json")); const outputDir = path.join(__dirname, "../raw-api"); if (!fs.existsSync(outputDir)) { @@ -12,6 +13,31 @@ if (!fs.existsSync(outputDir)) { let v1 = []; let v2 = []; +for (const subdomain of internal) { + const commonData = { + owner: { + username: "is-a-dev" + }, + domain: `${subdomain}.is-a.dev`, + subdomain: subdomain, + internal: true + }; + + const records = { + CNAME: "internal.is-a.dev" + } + + v1.push({ + ...commonData, + record: records + }); + + v2.push({ + ...commonData, + records: records + }); +} + for (const subdomain of reserved) { const commonData = { owner: { @@ -22,18 +48,18 @@ for (const subdomain of reserved) { reserved: true }; - const reservedRecords = { + const records = { URL: "https://is-a.dev/reserved" } v1.push({ ...commonData, - record: reservedRecords + record: records }); v2.push({ ...commonData, - records: reservedRecords + records: records }); } diff --git a/util/reserved.json b/util/reserved.json index d43d55922..2e855d680 100644 --- a/util/reserved.json +++ b/util/reserved.json @@ -8,8 +8,6 @@ "apps", "assets", "auth", - "autoconfig", - "autodiscover", "billing", "blog", "bot", @@ -21,12 +19,10 @@ "com", "dash", "dashboard", - "data", "dev", "discord", "dns", "doc", - "docs", "documentation", "domain", "email", @@ -82,7 +78,6 @@ "prod", "production", "r", - "raw", "rdap", "redirect", "register", @@ -114,7 +109,6 @@ "website", "whois", "ww", - "www", "wwww", "your-domain-name", "zone"