File
Blob: src/node/dns.ts
| 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. |
| 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: |
| 3 | // https://opensource.org/licenses/Apache-2.0 |
| 4 | // Copyright Joyent and Node contributors. All rights reserved. MIT license. |
| 5 | |
| 6 | import type nodejsDns from 'node:dns'; |
| 7 | import * as errorCodes from 'node-internal:internal_dns_constants'; |
| 8 | import * as dns from 'node-internal:internal_dns'; |
| 9 | import { callbackify } from 'node-internal:internal_utils'; |
| 10 | import * as dnsPromises from 'node-internal:internal_dns_promises'; |
| 11 | |
| 12 | export * from 'node-internal:internal_dns_constants'; |
| 13 | |
| 14 | export const promises = dnsPromises; |
| 15 | export const reverse = callbackify(dns.reverse.bind(dns)); |
| 16 | export const resolveTxt = callbackify(dns.resolveTxt.bind(dns)); |
| 17 | export const resolveCaa = callbackify(dns.resolveCaa.bind(dns)); |
| 18 | export const resolveMx = callbackify(dns.resolveMx.bind(dns)); |
| 19 | export const resolveCname = callbackify(dns.resolveCname.bind(dns)); |
| 20 | export const resolveNs = callbackify(dns.resolveNs.bind(dns)); |
| 21 | export const resolvePtr = callbackify(dns.resolvePtr.bind(dns)); |
| 22 | export const resolveSrv = callbackify(dns.resolveSrv.bind(dns)); |
| 23 | export const resolveSoa = callbackify(dns.resolveSoa.bind(dns)); |
| 24 | export const resolveNaptr = callbackify(dns.resolveNaptr.bind(dns)); |
| 25 | export const resolve4 = callbackify(dns.resolve4.bind(dns)); |
| 26 | export const resolve6 = callbackify(dns.resolve6.bind(dns)); |
| 27 | export const getServers = dns.getServers.bind(dns); |
| 28 | export const setServers = dns.setServers.bind(dns); |
| 29 | export const getDefaultResultOrder = dns.getDefaultResultOrder.bind(dns); |
| 30 | export const setDefaultResultOrder = dns.setDefaultResultOrder.bind(dns); |
| 31 | export const lookup = dns.lookup.bind(dns); |
| 32 | export const lookupService = callbackify(dns.lookupService.bind(this)); |
| 33 | export const resolve = callbackify(dns.resolve.bind(this)); |
| 34 | export const resolveAny = callbackify(dns.resolveAny.bind(this)); |
| 35 | |
| 36 | export class Resolver implements nodejsDns.Resolver { |
| 37 | cancel(): void { |
| 38 | // TODO(soon): Implement this. |
| 39 | throw new Error('Not implemented'); |
| 40 | } |
| 41 | |
| 42 | setLocalAddress(): void { |
| 43 | // Does not apply to workerd implementation |
| 44 | throw new Error('Not implemented'); |
| 45 | } |
| 46 | |
| 47 | getServers(...args: Parameters<typeof getServers>): string[] { |
| 48 | return getServers(...args); |
| 49 | } |
| 50 | |
| 51 | // @ts-expect-error TS2416 Type mismatch. |
| 52 | resolve(...args: Parameters<typeof resolve>): void { |
| 53 | resolve(...args); |
| 54 | } |
| 55 | |
| 56 | // @ts-expect-error TS2416 Type mismatch. |
| 57 | resolve4(...args: Parameters<typeof resolve4>): void { |
| 58 | resolve4(...args); |
| 59 | } |
| 60 | |
| 61 | // @ts-expect-error TS2416 Type mismatch. |
| 62 | resolve6(...args: Parameters<typeof resolve6>): void { |
| 63 | resolve6(...args); |
| 64 | } |
| 65 | |
| 66 | // @ts-expect-error TS2416 Type mismatch. |
| 67 | resolveAny(...args: Parameters<typeof resolveAny>): void { |
| 68 | resolveAny(...args); |
| 69 | } |
| 70 | |
| 71 | // @ts-expect-error TS2416 Type mismatch. |
| 72 | resolveCaa(...args: Parameters<typeof resolveCaa>): void { |
| 73 | resolveCaa(...args); |
| 74 | } |
| 75 | |
| 76 | // @ts-expect-error TS2416 Type mismatch. |
| 77 | resolveCname(...args: Parameters<typeof resolveCname>): void { |
| 78 | resolveCname(...args); |
| 79 | } |
| 80 | |
| 81 | // @ts-expect-error TS2416 Type mismatch. |
| 82 | resolveMx(...args: Parameters<typeof resolveMx>): void { |
| 83 | resolveMx(...args); |
| 84 | } |
| 85 | |
| 86 | // @ts-expect-error TS2416 Type mismatch. |
| 87 | resolveNaptr(...args: Parameters<typeof resolveNaptr>): void { |
| 88 | resolveNaptr(...args); |
| 89 | } |
| 90 | |
| 91 | // @ts-expect-error TS2416 Type mismatch. |
| 92 | resolveNs(...args: Parameters<typeof resolveNs>): void { |
| 93 | resolveNs(...args); |
| 94 | } |
| 95 | |
| 96 | // @ts-expect-error TS2416 Type mismatch. |
| 97 | resolvePtr(...args: Parameters<typeof resolvePtr>): void { |
| 98 | resolvePtr(...args); |
| 99 | } |
| 100 | |
| 101 | // @ts-expect-error TS2416 Type mismatch. |
| 102 | resolveSoa(...args: Parameters<typeof resolveSoa>): void { |
| 103 | resolveSoa(...args); |
| 104 | } |
| 105 | |
| 106 | // @ts-expect-error TS2416 Type mismatch. |
| 107 | resolveSrv(...args: Parameters<typeof resolveSrv>): void { |
| 108 | resolveSrv(...args); |
| 109 | } |
| 110 | |
| 111 | // @ts-expect-error TS2416 Type mismatch. |
| 112 | resolveTxt(...args: Parameters<typeof resolveTxt>): void { |
| 113 | resolveTxt(...args); |
| 114 | } |
| 115 | |
| 116 | reverse(...args: Parameters<typeof reverse>): void { |
| 117 | reverse(...args); |
| 118 | } |
| 119 | |
| 120 | setServers(...args: Parameters<typeof setServers>): void { |
| 121 | setServers(...args); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | export default { |
| 126 | getServers, |
| 127 | lookup, |
| 128 | lookupService, |
| 129 | resolve, |
| 130 | resolve4, |
| 131 | resolve6, |
| 132 | resolveAny, |
| 133 | resolveCname, |
| 134 | resolveCaa, |
| 135 | resolveMx, |
| 136 | resolveNaptr, |
| 137 | resolveNs, |
| 138 | resolvePtr, |
| 139 | resolveSoa, |
| 140 | resolveSrv, |
| 141 | resolveTxt, |
| 142 | reverse, |
| 143 | setDefaultResultOrder, |
| 144 | getDefaultResultOrder, |
| 145 | setServers, |
| 146 | Resolver, |
| 147 | promises, |
| 148 | ...errorCodes, |
| 149 | }; |