[6a3a178] | 1 | declare module 'dns' {
|
---|
| 2 | // Supported getaddrinfo flags.
|
---|
| 3 | const ADDRCONFIG: number;
|
---|
| 4 | const V4MAPPED: number;
|
---|
| 5 |
|
---|
| 6 | interface LookupOptions {
|
---|
| 7 | family?: number | undefined;
|
---|
| 8 | hints?: number | undefined;
|
---|
| 9 | all?: boolean | undefined;
|
---|
| 10 | verbatim?: boolean | undefined;
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | interface LookupOneOptions extends LookupOptions {
|
---|
| 14 | all?: false | undefined;
|
---|
| 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 | interface ResolverOptions {
|
---|
| 275 | timeout?: number | undefined;
|
---|
| 276 | }
|
---|
| 277 |
|
---|
| 278 | class Resolver {
|
---|
| 279 | constructor(options?: ResolverOptions);
|
---|
| 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 | constructor(options?: ResolverOptions);
|
---|
| 355 | getServers: typeof getServers;
|
---|
| 356 | resolve: typeof resolve;
|
---|
| 357 | resolve4: typeof resolve4;
|
---|
| 358 | resolve6: typeof resolve6;
|
---|
| 359 | resolveAny: typeof resolveAny;
|
---|
| 360 | resolveCname: typeof resolveCname;
|
---|
| 361 | resolveMx: typeof resolveMx;
|
---|
| 362 | resolveNaptr: typeof resolveNaptr;
|
---|
| 363 | resolveNs: typeof resolveNs;
|
---|
| 364 | resolvePtr: typeof resolvePtr;
|
---|
| 365 | resolveSoa: typeof resolveSoa;
|
---|
| 366 | resolveSrv: typeof resolveSrv;
|
---|
| 367 | resolveTxt: typeof resolveTxt;
|
---|
| 368 | reverse: typeof reverse;
|
---|
| 369 | setServers: typeof setServers;
|
---|
| 370 | }
|
---|
| 371 | }
|
---|
| 372 | }
|
---|