1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-21 04:52:26 -05:00

feat(ts/dns): RecordWithTtl interface

This commit is contained in:
siaeyy 2025-01-15 05:23:39 +03:00
parent 974e2f44b2
commit 406162d7b8

View file

@ -4674,6 +4674,22 @@ declare namespace Deno {
* and the promise returned will be rejected with an AbortError.
*/
signal?: AbortSignal;
/** */
ttl?: boolean;
}
export interface RecordWithTtl {
/** */
data:
| string
| CaaRecord
| MxRecord
| NaptrRecord
| SoaRecord
| SrvRecord
| string[];
/** */
ttl: number;
}
/** If {@linkcode Deno.resolveDns} is called with `"CAA"` record type
@ -4748,6 +4764,37 @@ declare namespace Deno {
target: string;
}
/**
* Performs DNS resolution against the given query, returning resolved
* records with ttl values.
*
* Fails in the cases such as:
*
* - the query is in invalid format.
* - the options have an invalid parameter. For example `nameServer.port` is
* beyond the range of 16-bit unsigned integer.
* - the request timed out.
*
* ```ts
* const a = await Deno.resolveDns("example.com", "A", { ttl: true });
*
* const aaaa = await Deno.resolveDns("example.com", "AAAA", {
* nameServer: { ipAddr: "8.8.8.8", port: 53 },
* ttl: true,
* });
* ```
*
* Requires `allow-net` permission.
*
* @tags allow-net
* @category Network
*/
export function resolveDns(
query: string,
recordType: RecordType,
options?: { ttl: true } & ResolveDnsOptions,
): Promise<RecordWithTtl[]>;
/**
* Performs DNS resolution against the given query, returning resolved
* records.
@ -4994,6 +5041,7 @@ declare namespace Deno {
| SoaRecord[]
| SrvRecord[]
| string[][]
| RecordWithTtl[]
>;
/**