UNPKG

7.88 kBTypeScriptView Raw
1// Modified from the node.js definitions.
2// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/dns.d.ts
3
4import {
5 AnyRecord,
6 LookupAddress,
7 LookupAllOptions,
8 LookupOneOptions,
9 LookupOptions,
10 MxRecord,
11 NaptrRecord,
12 RecordWithTtl,
13 ResolveOptions,
14 ResolveWithTtlOptions,
15 SoaRecord,
16 SrvRecord,
17} from "dns";
18export * from "dns";
19
20// lookup:
21export function lookup(
22 hostname: string,
23 family: number,
24 callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void,
25): void;
26export function lookup(
27 hostname: string,
28 // `options` can't be mixed into `family`
29 // tslint:disable-next-line: unified-signatures
30 options: LookupOneOptions,
31 callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void,
32): void;
33export function lookup(
34 hostname: string,
35 options: LookupAllOptions,
36 callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void,
37): void;
38export function lookup(
39 hostname: string,
40 options: LookupOptions,
41 callback: (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family: number) => void,
42): void;
43export function lookup(
44 hostname: string,
45 callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void,
46): void;
47
48export function lookup(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
49export function lookup(hostname: string, options?: LookupOneOptions | number): Promise<[string, number]>;
50export function lookup(hostname: string, options: LookupOptions): Promise<[string, number] | LookupAddress[]>;
51
52export function lookupService(
53 address: string,
54 port: number,
55 callback: (err: NodeJS.ErrnoException | null, hostname: string, service: string) => void,
56): void;
57export function lookupService(address: string, port: number): Promise<[string, string]>;
58
59// resolve:
60export function resolve(
61 hostname: string,
62 callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
63): void;
64export function resolve(
65 hostname: string,
66 rrtype: "A" | "AAAA" | "CNAME" | "NS" | "PTR",
67 callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
68): void;
69export function resolve(
70 hostname: string,
71 rrtype: "ANY",
72 callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void,
73): void;
74export function resolve(
75 hostname: string,
76 rrtype: "MX",
77 callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void,
78): void;
79export function resolve(
80 hostname: string,
81 rrtype: "NAPTR",
82 callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void,
83): void;
84export function resolve(
85 hostname: string,
86 rrtype: "SOA",
87 callback: (err: NodeJS.ErrnoException | null, addresses: SoaRecord) => void,
88): void;
89export function resolve(
90 hostname: string,
91 rrtype: "SRV",
92 callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void,
93): void;
94export function resolve(
95 hostname: string,
96 rrtype: "TXT",
97 callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void,
98): void;
99export function resolve(
100 hostname: string,
101 rrtype: string,
102 callback: (
103 err: NodeJS.ErrnoException | null,
104 addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[],
105 ) => void,
106): void;
107
108export function resolve(hostname: string, rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR"): Promise<string[]>;
109export function resolve(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
110export function resolve(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
111export function resolve(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
112export function resolve(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
113export function resolve(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
114export function resolve(hostname: string, rrtype: "TXT"): Promise<string[][]>;
115export function resolve(
116 hostname: string,
117 rrtype: string,
118): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
119
120// resolve4:
121export function resolve4(
122 hostname: string,
123 callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
124): void;
125export function resolve4(
126 hostname: string,
127 options: ResolveWithTtlOptions,
128 callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void,
129): void;
130export function resolve4(
131 hostname: string,
132 options: ResolveOptions,
133 callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void,
134): void;
135
136export function resolve4(hostname: string): Promise<string[]>;
137export function resolve4(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
138export function resolve4(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
139
140// resolve6:
141export function resolve6(
142 hostname: string,
143 callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
144): void;
145export function resolve6(
146 hostname: string,
147 options: ResolveWithTtlOptions,
148 callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void,
149): void;
150export function resolve6(
151 hostname: string,
152 options: ResolveOptions,
153 callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void,
154): void;
155
156export function resolve6(hostname: string): Promise<string[]>;
157export function resolve6(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
158export function resolve6(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
159
160export function resolveCname(
161 hostname: string,
162 callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
163): void;
164export function resolveCname(hostname: string): Promise<string[]>;
165
166export function resolveMx(
167 hostname: string,
168 callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void,
169): void;
170export function resolveMx(hostname: string): Promise<MxRecord[]>;
171
172export function resolveNaptr(
173 hostname: string,
174 callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void,
175): void;
176export function resolveNaptr(hostname: string): Promise<NaptrRecord[]>;
177
178export function resolveNs(
179 hostname: string,
180 callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
181): void;
182export function resolveNs(hostname: string): Promise<string[]>;
183
184export function resolvePtr(
185 hostname: string,
186 callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
187): void;
188export function resolvePtr(hostname: string): Promise<string[]>;
189
190export function resolveSoa(
191 hostname: string,
192 callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void,
193): void;
194export function resolveSoa(hostname: string): Promise<SoaRecord>;
195
196export function resolveSrv(
197 hostname: string,
198 callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void,
199): void;
200export function resolveSrv(hostname: string): Promise<SrvRecord[]>;
201
202export function resolveTxt(
203 hostname: string,
204 callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void,
205): void;
206export function resolveTxt(hostname: string): Promise<string[][]>;
207
208export function resolveAny(
209 hostname: string,
210 callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void,
211): void;
212export function resolveAny(hostname: string): Promise<AnyRecord[]>;
213
214export function reverse(ip: string, callback: (err: NodeJS.ErrnoException | null, domains: string[]) => void): void;
215export function reverse(ip: string): Promise<string[]>;