1
|
declare module "dns" {
|
2
|
// Supported getaddrinfo flags.
|
3
|
const ADDRCONFIG: number;
|
4
|
const V4MAPPED: number;
|
5
|
|
6
|
interface LookupOptions {
|
7
|
family?: number;
|
8
|
hints?: number;
|
9
|
all?: boolean;
|
10
|
verbatim?: boolean;
|
11
|
}
|
12
|
|
13
|
interface LookupOneOptions extends LookupOptions {
|
14
|
all?: false;
|
15
|
}
|
16
|
|
17
|
interface LookupAllOptions extends LookupOptions {
|
18
|
all: true;
|
19
|
}
|
20
|
|
21
|
interface LookupAddress {
|
22
|
address: string;
|
23
|
family: number;
|
24
|
}
|
25
|
|
26
|
function lookup(hostname: string, family: number, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
27
|
function lookup(hostname: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
28
|
function lookup(hostname: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void): void;
|
29
|
function lookup(hostname: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family: number) => void): void;
|
30
|
function lookup(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
31
|
|
32
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
33
|
namespace lookup {
|
34
|
function __promisify__(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
|
35
|
function __promisify__(hostname: string, options?: LookupOneOptions | number): Promise<LookupAddress>;
|
36
|
function __promisify__(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
|
37
|
}
|
38
|
|
39
|
function lookupService(address: string, port: number, callback: (err: NodeJS.ErrnoException | null, hostname: string, service: string) => void): void;
|
40
|
|
41
|
namespace lookupService {
|
42
|
function __promisify__(address: string, port: number): Promise<{ hostname: string, service: string }>;
|
43
|
}
|
44
|
|
45
|
interface ResolveOptions {
|
46
|
ttl: boolean;
|
47
|
}
|
48
|
|
49
|
interface ResolveWithTtlOptions extends ResolveOptions {
|
50
|
ttl: true;
|
51
|
}
|
52
|
|
53
|
interface RecordWithTtl {
|
54
|
address: string;
|
55
|
ttl: number;
|
56
|
}
|
57
|
|
58
|
/** @deprecated Use AnyARecord or AnyAaaaRecord instead. */
|
59
|
type AnyRecordWithTtl = AnyARecord | AnyAaaaRecord;
|
60
|
|
61
|
interface AnyARecord extends RecordWithTtl {
|
62
|
type: "A";
|
63
|
}
|
64
|
|
65
|
interface AnyAaaaRecord extends RecordWithTtl {
|
66
|
type: "AAAA";
|
67
|
}
|
68
|
|
69
|
interface MxRecord {
|
70
|
priority: number;
|
71
|
exchange: string;
|
72
|
}
|
73
|
|
74
|
interface AnyMxRecord extends MxRecord {
|
75
|
type: "MX";
|
76
|
}
|
77
|
|
78
|
interface NaptrRecord {
|
79
|
flags: string;
|
80
|
service: string;
|
81
|
regexp: string;
|
82
|
replacement: string;
|
83
|
order: number;
|
84
|
preference: number;
|
85
|
}
|
86
|
|
87
|
interface AnyNaptrRecord extends NaptrRecord {
|
88
|
type: "NAPTR";
|
89
|
}
|
90
|
|
91
|
interface SoaRecord {
|
92
|
nsname: string;
|
93
|
hostmaster: string;
|
94
|
serial: number;
|
95
|
refresh: number;
|
96
|
retry: number;
|
97
|
expire: number;
|
98
|
minttl: number;
|
99
|
}
|
100
|
|
101
|
interface AnySoaRecord extends SoaRecord {
|
102
|
type: "SOA";
|
103
|
}
|
104
|
|
105
|
interface SrvRecord {
|
106
|
priority: number;
|
107
|
weight: number;
|
108
|
port: number;
|
109
|
name: string;
|
110
|
}
|
111
|
|
112
|
interface AnySrvRecord extends SrvRecord {
|
113
|
type: "SRV";
|
114
|
}
|
115
|
|
116
|
interface AnyTxtRecord {
|
117
|
type: "TXT";
|
118
|
entries: string[];
|
119
|
}
|
120
|
|
121
|
interface AnyNsRecord {
|
122
|
type: "NS";
|
123
|
value: string;
|
124
|
}
|
125
|
|
126
|
interface AnyPtrRecord {
|
127
|
type: "PTR";
|
128
|
value: string;
|
129
|
}
|
130
|
|
131
|
interface AnyCnameRecord {
|
132
|
type: "CNAME";
|
133
|
value: string;
|
134
|
}
|
135
|
|
136
|
type AnyRecord = AnyARecord |
|
137
|
AnyAaaaRecord |
|
138
|
AnyCnameRecord |
|
139
|
AnyMxRecord |
|
140
|
AnyNaptrRecord |
|
141
|
AnyNsRecord |
|
142
|
AnyPtrRecord |
|
143
|
AnySoaRecord |
|
144
|
AnySrvRecord |
|
145
|
AnyTxtRecord;
|
146
|
|
147
|
function resolve(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
148
|
function resolve(hostname: string, rrtype: "A", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
149
|
function resolve(hostname: string, rrtype: "AAAA", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
150
|
function resolve(hostname: string, rrtype: "ANY", callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
|
151
|
function resolve(hostname: string, rrtype: "CNAME", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
152
|
function resolve(hostname: string, rrtype: "MX", callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
|
153
|
function resolve(hostname: string, rrtype: "NAPTR", callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
|
154
|
function resolve(hostname: string, rrtype: "NS", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
155
|
function resolve(hostname: string, rrtype: "PTR", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
156
|
function resolve(hostname: string, rrtype: "SOA", callback: (err: NodeJS.ErrnoException | null, addresses: SoaRecord) => void): void;
|
157
|
function resolve(hostname: string, rrtype: "SRV", callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
|
158
|
function resolve(hostname: string, rrtype: "TXT", callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
|
159
|
function resolve(
|
160
|
hostname: string,
|
161
|
rrtype: string,
|
162
|
callback: (err: NodeJS.ErrnoException | null, addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]) => void,
|
163
|
): void;
|
164
|
|
165
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
166
|
namespace resolve {
|
167
|
function __promisify__(hostname: string, rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR"): Promise<string[]>;
|
168
|
function __promisify__(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
|
169
|
function __promisify__(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
|
170
|
function __promisify__(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
|
171
|
function __promisify__(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
|
172
|
function __promisify__(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
|
173
|
function __promisify__(hostname: string, rrtype: "TXT"): Promise<string[][]>;
|
174
|
function __promisify__(hostname: string, rrtype: string): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
|
175
|
}
|
176
|
|
177
|
function resolve4(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
178
|
function resolve4(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
|
179
|
function resolve4(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
|
180
|
|
181
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
182
|
namespace resolve4 {
|
183
|
function __promisify__(hostname: string): Promise<string[]>;
|
184
|
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
185
|
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
186
|
}
|
187
|
|
188
|
function resolve6(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
189
|
function resolve6(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
|
190
|
function resolve6(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
|
191
|
|
192
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
193
|
namespace resolve6 {
|
194
|
function __promisify__(hostname: string): Promise<string[]>;
|
195
|
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
196
|
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
197
|
}
|
198
|
|
199
|
function resolveCname(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
200
|
namespace resolveCname {
|
201
|
function __promisify__(hostname: string): Promise<string[]>;
|
202
|
}
|
203
|
|
204
|
function resolveMx(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
|
205
|
namespace resolveMx {
|
206
|
function __promisify__(hostname: string): Promise<MxRecord[]>;
|
207
|
}
|
208
|
|
209
|
function resolveNaptr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
|
210
|
namespace resolveNaptr {
|
211
|
function __promisify__(hostname: string): Promise<NaptrRecord[]>;
|
212
|
}
|
213
|
|
214
|
function resolveNs(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
215
|
namespace resolveNs {
|
216
|
function __promisify__(hostname: string): Promise<string[]>;
|
217
|
}
|
218
|
|
219
|
function resolvePtr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
220
|
namespace resolvePtr {
|
221
|
function __promisify__(hostname: string): Promise<string[]>;
|
222
|
}
|
223
|
|
224
|
function resolveSoa(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void): void;
|
225
|
namespace resolveSoa {
|
226
|
function __promisify__(hostname: string): Promise<SoaRecord>;
|
227
|
}
|
228
|
|
229
|
function resolveSrv(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
|
230
|
namespace resolveSrv {
|
231
|
function __promisify__(hostname: string): Promise<SrvRecord[]>;
|
232
|
}
|
233
|
|
234
|
function resolveTxt(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
|
235
|
namespace resolveTxt {
|
236
|
function __promisify__(hostname: string): Promise<string[][]>;
|
237
|
}
|
238
|
|
239
|
function resolveAny(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
|
240
|
namespace resolveAny {
|
241
|
function __promisify__(hostname: string): Promise<AnyRecord[]>;
|
242
|
}
|
243
|
|
244
|
function reverse(ip: string, callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void): void;
|
245
|
function setServers(servers: ReadonlyArray<string>): void;
|
246
|
function getServers(): string[];
|
247
|
|
248
|
// Error codes
|
249
|
const NODATA: string;
|
250
|
const FORMERR: string;
|
251
|
const SERVFAIL: string;
|
252
|
const NOTFOUND: string;
|
253
|
const NOTIMP: string;
|
254
|
const REFUSED: string;
|
255
|
const BADQUERY: string;
|
256
|
const BADNAME: string;
|
257
|
const BADFAMILY: string;
|
258
|
const BADRESP: string;
|
259
|
const CONNREFUSED: string;
|
260
|
const TIMEOUT: string;
|
261
|
const EOF: string;
|
262
|
const FILE: string;
|
263
|
const NOMEM: string;
|
264
|
const DESTRUCTION: string;
|
265
|
const BADSTR: string;
|
266
|
const BADFLAGS: string;
|
267
|
const NONAME: string;
|
268
|
const BADHINTS: string;
|
269
|
const NOTINITIALIZED: string;
|
270
|
const LOADIPHLPAPI: string;
|
271
|
const ADDRGETNETWORKPARAMS: string;
|
272
|
const CANCELLED: string;
|
273
|
|
274
|
class Resolver {
|
275
|
getServers: typeof getServers;
|
276
|
setServers: typeof setServers;
|
277
|
resolve: typeof resolve;
|
278
|
resolve4: typeof resolve4;
|
279
|
resolve6: typeof resolve6;
|
280
|
resolveAny: typeof resolveAny;
|
281
|
resolveCname: typeof resolveCname;
|
282
|
resolveMx: typeof resolveMx;
|
283
|
resolveNaptr: typeof resolveNaptr;
|
284
|
resolveNs: typeof resolveNs;
|
285
|
resolvePtr: typeof resolvePtr;
|
286
|
resolveSoa: typeof resolveSoa;
|
287
|
resolveSrv: typeof resolveSrv;
|
288
|
resolveTxt: typeof resolveTxt;
|
289
|
reverse: typeof reverse;
|
290
|
cancel(): void;
|
291
|
}
|
292
|
|
293
|
namespace promises {
|
294
|
function getServers(): string[];
|
295
|
|
296
|
function lookup(hostname: string, family: number): Promise<LookupAddress>;
|
297
|
function lookup(hostname: string, options: LookupOneOptions): Promise<LookupAddress>;
|
298
|
function lookup(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
|
299
|
function lookup(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
|
300
|
function lookup(hostname: string): Promise<LookupAddress>;
|
301
|
|
302
|
function lookupService(address: string, port: number): Promise<{ hostname: string, service: string }>;
|
303
|
|
304
|
function resolve(hostname: string): Promise<string[]>;
|
305
|
function resolve(hostname: string, rrtype: "A"): Promise<string[]>;
|
306
|
function resolve(hostname: string, rrtype: "AAAA"): Promise<string[]>;
|
307
|
function resolve(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
|
308
|
function resolve(hostname: string, rrtype: "CNAME"): Promise<string[]>;
|
309
|
function resolve(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
|
310
|
function resolve(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
|
311
|
function resolve(hostname: string, rrtype: "NS"): Promise<string[]>;
|
312
|
function resolve(hostname: string, rrtype: "PTR"): Promise<string[]>;
|
313
|
function resolve(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
|
314
|
function resolve(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
|
315
|
function resolve(hostname: string, rrtype: "TXT"): Promise<string[][]>;
|
316
|
function resolve(hostname: string, rrtype: string): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
|
317
|
|
318
|
function resolve4(hostname: string): Promise<string[]>;
|
319
|
function resolve4(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
320
|
function resolve4(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
321
|
|
322
|
function resolve6(hostname: string): Promise<string[]>;
|
323
|
function resolve6(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
324
|
function resolve6(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
325
|
|
326
|
function resolveAny(hostname: string): Promise<AnyRecord[]>;
|
327
|
|
328
|
function resolveCname(hostname: string): Promise<string[]>;
|
329
|
|
330
|
function resolveMx(hostname: string): Promise<MxRecord[]>;
|
331
|
|
332
|
function resolveNaptr(hostname: string): Promise<NaptrRecord[]>;
|
333
|
|
334
|
function resolveNs(hostname: string): Promise<string[]>;
|
335
|
|
336
|
function resolvePtr(hostname: string): Promise<string[]>;
|
337
|
|
338
|
function resolveSoa(hostname: string): Promise<SoaRecord>;
|
339
|
|
340
|
function resolveSrv(hostname: string): Promise<SrvRecord[]>;
|
341
|
|
342
|
function resolveTxt(hostname: string): Promise<string[][]>;
|
343
|
|
344
|
function reverse(ip: string): Promise<string[]>;
|
345
|
|
346
|
function setServers(servers: ReadonlyArray<string>): void;
|
347
|
|
348
|
class Resolver {
|
349
|
getServers: typeof getServers;
|
350
|
resolve: typeof resolve;
|
351
|
resolve4: typeof resolve4;
|
352
|
resolve6: typeof resolve6;
|
353
|
resolveAny: typeof resolveAny;
|
354
|
resolveCname: typeof resolveCname;
|
355
|
resolveMx: typeof resolveMx;
|
356
|
resolveNaptr: typeof resolveNaptr;
|
357
|
resolveNs: typeof resolveNs;
|
358
|
resolvePtr: typeof resolvePtr;
|
359
|
resolveSoa: typeof resolveSoa;
|
360
|
resolveSrv: typeof resolveSrv;
|
361
|
resolveTxt: typeof resolveTxt;
|
362
|
reverse: typeof reverse;
|
363
|
setServers: typeof setServers;
|
364
|
}
|
365
|
}
|
366
|
}
|