UNPKG

4.11 kBTypeScriptView Raw
1declare module "dns/promises" {
2 import {
3 LookupAddress,
4 LookupOneOptions,
5 LookupAllOptions,
6 LookupOptions,
7 AnyRecord,
8 CaaRecord,
9 MxRecord,
10 NaptrRecord,
11 SoaRecord,
12 SrvRecord,
13 ResolveWithTtlOptions,
14 RecordWithTtl,
15 ResolveOptions,
16 ResolverOptions,
17 } from "dns";
18
19 function getServers(): string[];
20
21 function lookup(hostname: string, family: number): Promise<LookupAddress>;
22 function lookup(hostname: string, options: LookupOneOptions): Promise<LookupAddress>;
23 function lookup(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
24 function lookup(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
25 function lookup(hostname: string): Promise<LookupAddress>;
26
27 function lookupService(address: string, port: number): Promise<{ hostname: string, service: string }>;
28
29 function resolve(hostname: string): Promise<string[]>;
30 function resolve(hostname: string, rrtype: "A"): Promise<string[]>;
31 function resolve(hostname: string, rrtype: "AAAA"): Promise<string[]>;
32 function resolve(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
33 function resolve(hostname: string, rrtype: "CAA"): Promise<CaaRecord[]>;
34 function resolve(hostname: string, rrtype: "CNAME"): Promise<string[]>;
35 function resolve(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
36 function resolve(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
37 function resolve(hostname: string, rrtype: "NS"): Promise<string[]>;
38 function resolve(hostname: string, rrtype: "PTR"): Promise<string[]>;
39 function resolve(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
40 function resolve(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
41 function resolve(hostname: string, rrtype: "TXT"): Promise<string[][]>;
42 function resolve(hostname: string, rrtype: string): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
43
44 function resolve4(hostname: string): Promise<string[]>;
45 function resolve4(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
46 function resolve4(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
47
48 function resolve6(hostname: string): Promise<string[]>;
49 function resolve6(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
50 function resolve6(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
51
52 function resolveAny(hostname: string): Promise<AnyRecord[]>;
53
54 function resolveCaa(hostname: string): Promise<CaaRecord[]>;
55
56 function resolveCname(hostname: string): Promise<string[]>;
57
58 function resolveMx(hostname: string): Promise<MxRecord[]>;
59
60 function resolveNaptr(hostname: string): Promise<NaptrRecord[]>;
61
62 function resolveNs(hostname: string): Promise<string[]>;
63
64 function resolvePtr(hostname: string): Promise<string[]>;
65
66 function resolveSoa(hostname: string): Promise<SoaRecord>;
67
68 function resolveSrv(hostname: string): Promise<SrvRecord[]>;
69
70 function resolveTxt(hostname: string): Promise<string[][]>;
71
72 function reverse(ip: string): Promise<string[]>;
73
74 function setServers(servers: ReadonlyArray<string>): void;
75
76 class Resolver {
77 constructor(options?: ResolverOptions);
78
79 cancel(): void;
80 getServers: typeof getServers;
81 resolve: typeof resolve;
82 resolve4: typeof resolve4;
83 resolve6: typeof resolve6;
84 resolveAny: typeof resolveAny;
85 resolveCname: typeof resolveCname;
86 resolveMx: typeof resolveMx;
87 resolveNaptr: typeof resolveNaptr;
88 resolveNs: typeof resolveNs;
89 resolvePtr: typeof resolvePtr;
90 resolveSoa: typeof resolveSoa;
91 resolveSrv: typeof resolveSrv;
92 resolveTxt: typeof resolveTxt;
93 reverse: typeof reverse;
94 setLocalAddress(ipv4?: string, ipv6?: string): void;
95 setServers: typeof setServers;
96 }
97}