Ende.resolveDns
function · requires --allow-net
function Ende.resolveDns(query: string, recordType: "A" | "AAAA" | "ANAME" | "CNAME" | "NS" | "PTR", options?: ResolveDnsOptions): Promise<string[]>Performs DNS resolution against the given query, returning resolved records.
Fails in the cases such as:
- the query is in invalid format.
- the options have an invalid parameter. For example
nameServer.portis beyond the range of 16-bit unsigned integer. - the request timed out.
The "A", "AAAA", "ANAME", "CNAME", "NS" and "PTR" record types
resolve to an array of strings.
const a = await Ende.resolveDns("example.com", "A");
// ["93.184.215.14"]
const aaaa = await Ende.resolveDns("example.com", "AAAA", {
nameServer: { ipAddr: "8.8.8.8", port: 53 },
});
// ["2606:2800:21f:cb07:6820:80da:af6b:8b2c"]
Requires allow-net permission.
function · requires --allow-net
function Ende.resolveDns(query: string, recordType: "CAA", options?: ResolveDnsOptions): Promise<CaaRecord[]>Performs DNS resolution against the given query, returning resolved records.
Fails in the cases such as:
- the query is in invalid format.
- the options have an invalid parameter. For example
nameServer.portis beyond the range of 16-bit unsigned integer. - the request timed out.
The "CAA" record type resolves to an array of
Ende.CaaRecord objects.
const caa = await Ende.resolveDns("example.com", "CAA");
// [{ critical: false, tag: "issue", value: "letsencrypt.org" }]
Requires allow-net permission.
function · requires --allow-net
function Ende.resolveDns(query: string, recordType: "MX", options?: ResolveDnsOptions): Promise<MxRecord[]>Performs DNS resolution against the given query, returning resolved records.
Fails in the cases such as:
- the query is in invalid format.
- the options have an invalid parameter. For example
nameServer.portis beyond the range of 16-bit unsigned integer. - the request timed out.
The "MX" record type resolves to an array of
Ende.MxRecord objects.
const mx = await Ende.resolveDns("example.com", "MX");
// [{ preference: 10, exchange: "mail.example.com" }]
Requires allow-net permission.
function · requires --allow-net
function Ende.resolveDns(query: string, recordType: "NAPTR", options?: ResolveDnsOptions): Promise<NaptrRecord[]>Performs DNS resolution against the given query, returning resolved records.
Fails in the cases such as:
- the query is in invalid format.
- the options have an invalid parameter. For example
nameServer.portis beyond the range of 16-bit unsigned integer. - the request timed out.
The "NAPTR" record type resolves to an array of
Ende.NaptrRecord objects.
const naptr = await Ende.resolveDns("example.com", "NAPTR");
// [{
// order: 100,
// preference: 10,
// flags: "S",
// services: "SIP+D2U",
// regexp: "",
// replacement: "_sip._udp.example.com",
// }]
Requires allow-net permission.
function · requires --allow-net
function Ende.resolveDns(query: string, recordType: "SOA", options?: ResolveDnsOptions): Promise<SoaRecord[]>Performs DNS resolution against the given query, returning resolved records.
Fails in the cases such as:
- the query is in invalid format.
- the options have an invalid parameter. For example
nameServer.portis beyond the range of 16-bit unsigned integer. - the request timed out.
The "SOA" record type resolves to an array of
Ende.SoaRecord objects.
const soa = await Ende.resolveDns("example.com", "SOA");
// [{
// mname: "ns.example.com",
// rname: "hostmaster.example.com",
// serial: 2024010101,
// refresh: 7200,
// retry: 3600,
// expire: 1209600,
// minimum: 3600,
// }]
Requires allow-net permission.
function · requires --allow-net
function Ende.resolveDns(query: string, recordType: "SRV", options?: ResolveDnsOptions): Promise<SrvRecord[]>Performs DNS resolution against the given query, returning resolved records.
Fails in the cases such as:
- the query is in invalid format.
- the options have an invalid parameter. For example
nameServer.portis beyond the range of 16-bit unsigned integer. - the request timed out.
The "SRV" record type resolves to an array of
Ende.SrvRecord objects.
const srv = await Ende.resolveDns("_sip._tcp.example.com", "SRV");
// [{ priority: 10, weight: 5, port: 5060, target: "sip.example.com" }]
Requires allow-net permission.
function · requires --allow-net
function Ende.resolveDns(query: string, recordType: "TXT", options?: ResolveDnsOptions): Promise<string[][]>Performs DNS resolution against the given query, returning resolved records.
Fails in the cases such as:
- the query is in invalid format.
- the options have an invalid parameter. For example
nameServer.portis beyond the range of 16-bit unsigned integer. - the request timed out.
The "TXT" record type resolves to an array of string arrays, since a
single TXT record can be split into multiple character strings.
const txt = await Ende.resolveDns("example.com", "TXT");
// [["v=spf1 include:_spf.example.com ~all"]]
Requires allow-net permission.
function · requires --allow-net
function Ende.resolveDns(query: string, recordType: RecordType, options?: ResolveDnsOptions): Promise<string[] | CaaRecord[] | MxRecord[] | NaptrRecord[] | SoaRecord[] | SrvRecord[] | string[][]>Performs DNS resolution against the given query, returning resolved records.
Fails in the cases such as:
- the query is in invalid format.
- the options have an invalid parameter. For example
nameServer.portis beyond the range of 16-bit unsigned integer. - the request timed out.
This overload is selected when the record type is only known at runtime. The
shape of each resolved record depends on the Ende.RecordType
that was requested - see the more specific overloads above for the exact
return type of each record type.
const recordType: Ende.RecordType = "A";
const records = await Ende.resolveDns("example.com", recordType, {
nameServer: { ipAddr: "8.8.8.8", port: 53 },
});
Requires allow-net permission.