2021-01-19 09:39:04 -05:00
|
|
|
const nameServer = { nameServer: { ipAddr: "127.0.0.1", port: 4553 } };
|
|
|
|
|
2022-05-16 05:20:41 -04:00
|
|
|
const [a, aaaa, aname, caa, cname, mx, naptr, ns, ptr, soa, srv, txt] =
|
|
|
|
await Promise
|
|
|
|
.all([
|
|
|
|
Deno.resolveDns("www.example.com", "A", nameServer),
|
|
|
|
Deno.resolveDns("www.example.com", "AAAA", nameServer),
|
|
|
|
Deno.resolveDns("www.example.com", "ANAME", nameServer),
|
|
|
|
Deno.resolveDns("example.com", "CAA", nameServer),
|
|
|
|
Deno.resolveDns("alias.example.com", "CNAME", nameServer),
|
|
|
|
Deno.resolveDns("example.com", "MX", nameServer),
|
|
|
|
Deno.resolveDns("example.com", "NAPTR", nameServer),
|
|
|
|
Deno.resolveDns("example.com", "NS", nameServer),
|
|
|
|
Deno.resolveDns("1.2.3.4.IN-ADDR.ARPA.", "PTR", nameServer),
|
|
|
|
Deno.resolveDns("example.com", "SOA", nameServer),
|
|
|
|
Deno.resolveDns("_service._tcp.example.com", "SRV", nameServer),
|
|
|
|
Deno.resolveDns("example.com", "TXT", nameServer),
|
|
|
|
]);
|
2021-01-19 09:39:04 -05:00
|
|
|
|
|
|
|
console.log("A");
|
|
|
|
console.log(JSON.stringify(a));
|
|
|
|
|
|
|
|
console.log("AAAA");
|
|
|
|
console.log(JSON.stringify(aaaa));
|
|
|
|
|
|
|
|
console.log("ANAME");
|
|
|
|
console.log(JSON.stringify(aname));
|
|
|
|
|
2022-05-16 05:20:41 -04:00
|
|
|
console.log("CAA");
|
|
|
|
console.log(JSON.stringify(caa));
|
|
|
|
|
2021-01-19 09:39:04 -05:00
|
|
|
console.log("CNAME");
|
|
|
|
console.log(JSON.stringify(cname));
|
|
|
|
|
|
|
|
console.log("MX");
|
|
|
|
console.log(JSON.stringify(mx));
|
|
|
|
|
2022-05-15 11:42:02 -04:00
|
|
|
console.log("NAPTR");
|
|
|
|
console.log(JSON.stringify(naptr));
|
|
|
|
|
2022-05-03 14:04:20 -04:00
|
|
|
console.log("NS");
|
|
|
|
console.log(JSON.stringify(ns));
|
|
|
|
|
2021-01-19 09:39:04 -05:00
|
|
|
console.log("PTR");
|
|
|
|
console.log(JSON.stringify(ptr));
|
|
|
|
|
2022-05-14 08:08:35 -04:00
|
|
|
console.log("SOA");
|
|
|
|
console.log(JSON.stringify(soa));
|
|
|
|
|
2021-01-19 09:39:04 -05:00
|
|
|
console.log("SRV");
|
|
|
|
console.log(JSON.stringify(srv));
|
|
|
|
|
|
|
|
console.log("TXT");
|
|
|
|
console.log(JSON.stringify(txt));
|
2021-01-20 09:47:17 -05:00
|
|
|
|
|
|
|
try {
|
|
|
|
await Deno.resolveDns("not-found-example.com", "A", nameServer);
|
2021-10-10 06:14:45 -04:00
|
|
|
} catch (e) {
|
2021-10-27 17:43:40 -04:00
|
|
|
console.log(
|
|
|
|
`Error ${
|
|
|
|
e instanceof Error ? e.name : "[non-error]"
|
|
|
|
} thrown for not-found-example.com`,
|
|
|
|
);
|
2021-01-20 09:47:17 -05:00
|
|
|
}
|
2023-01-11 15:31:14 -05:00
|
|
|
|
|
|
|
try {
|
|
|
|
// @ts-ignore testing invalid overloads
|
|
|
|
await Deno.resolveDns("example.com", "SSHFP", nameServer);
|
|
|
|
} catch (e) {
|
2024-09-05 09:22:31 -04:00
|
|
|
console.log((e as Error).message);
|
2023-01-11 15:31:14 -05:00
|
|
|
}
|
2023-02-11 09:14:02 -05:00
|
|
|
|
|
|
|
try {
|
|
|
|
const ac = new AbortController();
|
|
|
|
queueMicrotask(() => ac.abort());
|
|
|
|
await Deno.resolveDns("www.example.com", "A", {
|
|
|
|
...nameServer,
|
|
|
|
signal: ac.signal,
|
|
|
|
});
|
|
|
|
} catch (e) {
|
2024-09-05 09:22:31 -04:00
|
|
|
console.log((e as Error).name);
|
2023-02-11 09:14:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
const ac = new AbortController();
|
|
|
|
ac.abort();
|
|
|
|
await Deno.resolveDns("www.example.com", "A", {
|
|
|
|
...nameServer,
|
|
|
|
signal: ac.signal,
|
|
|
|
});
|
|
|
|
} catch (e) {
|
2024-09-05 09:22:31 -04:00
|
|
|
console.log((e as Error).name);
|
2023-02-11 09:14:02 -05:00
|
|
|
}
|