changes to internal domains

This commit is contained in:
William Harrison
2025-04-23 21:35:15 +08:00
committed by GitHub
parent bf7ebc069b
commit 92dc6c6298
5 changed files with 47 additions and 22 deletions
+10 -7
View File
@@ -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) {
-6
View File
@@ -1,6 +0,0 @@
[
"_discord",
"_psl",
"_gh-is-a-dev-o",
"_github-pages-challenge-is-a-dev"
]
+8
View File
@@ -0,0 +1,8 @@
[
"autoconfig",
"autodiscover",
"data",
"docs",
"raw",
"www"
]
+29 -3
View File
@@ -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
});
}
-6
View File
@@ -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"