Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export async function script1({hostname}: {
- hostname: string
- }): Promise<{
- pass: boolean;
- error?: string;
- }> {
- const nameservers = await dns(hostname, "NS");
- if (!nameservers.length) {
- return {
- pass: false,
- error: "No nameservers found. Could be an issue with the DNS server."
- };
- }
- const failed = [];
- for (let i = 0; i < nameservers.length; ++i) {
- const server = nameservers[i].value;
- const serverA = await dns(server, "A");
- if (!serverA.length) {
- return {
- pass: false,
- error: `No A record found for nameserver ${server}.`
- };
- }
- const nsIp = serverA[0].value;
- const records = await dns(hostname, "A", nsIp);
- if (!records.length) {
- failed.push(server);
- }
- }
- if (failed.length) {
- return {
- pass: false,
- error: `The following nameservers did not respond with an A-record for ${hostname}: ${failed.join(
- ", "
- )}`
- };
- }
- return {
- pass: true
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement