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