mirror of
https://github.com/tiennm99/open-domains.git
synced 2026-10-14 20:17:30 +00:00
fix: SRV record validation
// Description: This code validates the SRV record format in a DNS configuration.
This commit is contained in:
1 parent
0f018df1ab
commit
76a1bddc40
2 files changed
+41
-1
No files matched your search
@@ -76,3 +76,43 @@ t("Nested subdomains should not exist if the parent domain has NS records", (t)
|
||||
t.pass();
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
//Note: This test is commented out because certain users only provide email addresses with no usernames.
|
||||
|
||||
t("Nested subdomains should be owned by the parent subdomain's owner", (t) => {
|
||||
files.forEach((file) => {
|
||||
// Skip directories and process only .json files
|
||||
const filePath = path.join(domainsPath, file);
|
||||
if (fs.lstatSync(filePath).isDirectory()) {
|
||||
return; // Skip directories
|
||||
}
|
||||
|
||||
const subdomain = file.replace(/\.json$/, "");
|
||||
|
||||
// Skip first-level subdomains (e.g., "banana.is-cool.dev")
|
||||
// First-level subdomains have no immediate parent to check
|
||||
if (subdomain.split(".").length > 3) {
|
||||
// Get the immediate parent domain, by getting the last 3 parts.
|
||||
const parentSubdomain = subdomain.split(".").slice(-3).join(".");
|
||||
const parentFilePath = path.join(domainsPath, `${parentSubdomain}.json`);
|
||||
|
||||
// Check if the parent file exists before attempting to read it
|
||||
if (fs.existsSync(parentFilePath)) {
|
||||
const parentDomain = fs.readJsonSync(parentFilePath);
|
||||
const subdomainData = fs.readJsonSync(filePath);
|
||||
|
||||
// Check if the owner of the subdomain matches the parent domain's owner
|
||||
if (subdomainData.owner !== parentDomain.owner) {
|
||||
t.fail(`${file}: Owner mismatch with parent domain ${parentSubdomain}`);
|
||||
}
|
||||
} else {
|
||||
t.fail(`${parentSubdomain}.json file does not exist`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
t.pass();
|
||||
});
|
||||
*/
|
||||
@@ -270,7 +270,7 @@ t("All files should have valid record values", (t) => {
|
||||
);
|
||||
|
||||
t.regex(
|
||||
value.target,
|
||||
record.target,
|
||||
hostnameRegex,
|
||||
`${file}: SRV record value should be a valid hostname for target at index ${value.indexOf(record)}`
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user