aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Ai Hoshino <ambiguous404@gmail.com> 2023-09-21 09:43:08 +0800
committerGravatar GitHub <noreply@github.com> 2023-09-20 18:43:08 -0700
commit7319142fd866d8314364d769f401a492892f7d63 (patch)
tree581466ccd682482f080ad6b8dc41eeb33e2f4626
parent365fc0d39ddfaed8683eb6ee75013a0fe3adcae2 (diff)
downloadbun-7319142fd866d8314364d769f401a492892f7d63.tar.gz
bun-7319142fd866d8314364d769f401a492892f7d63.tar.zst
bun-7319142fd866d8314364d769f401a492892f7d63.zip
feat(node:dns): implement `dns.lookupService` (#5613)
* feat(node:dns): implement dns.lookupService Close: #4347 * fix flags * add `getSockaddr` * fix sockaddr size * flaky test
-rw-r--r--src/bun.js/api/bun/dns_resolver.zig306
-rw-r--r--src/bun.js/bindings/BunObject.cpp3
-rw-r--r--src/deps/c_ares.zig109
-rw-r--r--src/js/node/dns.js11
-rw-r--r--src/js/out/InternalModuleRegistryConstants.h6
-rw-r--r--test/js/node/dns/node-dns.test.js66
6 files changed, 492 insertions, 9 deletions
diff --git a/src/bun.js/api/bun/dns_resolver.zig b/src/bun.js/api/bun/dns_resolver.zig
index b2d209c95..eea516242 100644
--- a/src/bun.js/api/bun/dns_resolver.zig
+++ b/src/bun.js/api/bun/dns_resolver.zig
@@ -812,6 +812,170 @@ pub const GetHostByAddrInfoRequest = struct {
}
};
+pub const CAresNameInfo = struct {
+ const log = Output.scoped(@This(), true);
+
+ globalThis: *JSC.JSGlobalObject = undefined,
+ promise: JSC.JSPromise.Strong,
+ poll_ref: JSC.PollRef,
+ allocated: bool = false,
+ next: ?*@This() = null,
+ name: []const u8,
+
+ pub fn init(globalThis: *JSC.JSGlobalObject, allocator: std.mem.Allocator, name: []const u8) !*@This() {
+ var this = try allocator.create(@This());
+ var poll_ref = JSC.PollRef.init();
+ poll_ref.ref(globalThis.bunVM());
+ this.* = .{ .globalThis = globalThis, .promise = JSC.JSPromise.Strong.init(globalThis), .poll_ref = poll_ref, .allocated = true, .name = name };
+ return this;
+ }
+
+ pub fn processResolve(this: *@This(), err_: ?c_ares.Error, _: i32, result: ?c_ares.struct_nameinfo) void {
+ if (err_) |err| {
+ var promise = this.promise;
+ var globalThis = this.globalThis;
+ const error_value = globalThis.createErrorInstance("lookupService failed: {s}", .{err.label()});
+ error_value.put(
+ globalThis,
+ JSC.ZigString.static("code"),
+ JSC.ZigString.init(err.code()).toValueGC(globalThis),
+ );
+
+ promise.reject(globalThis, error_value);
+ this.deinit();
+ return;
+ }
+ if (result == null) {
+ var promise = this.promise;
+ var globalThis = this.globalThis;
+ const error_value = globalThis.createErrorInstance("lookupService failed: No results", .{});
+ error_value.put(
+ globalThis,
+ JSC.ZigString.static("code"),
+ JSC.ZigString.init("EUNREACHABLE").toValueGC(globalThis),
+ );
+
+ promise.reject(globalThis, error_value);
+ this.deinit();
+ return;
+ }
+ var name_info = result.?;
+ const array = name_info.toJSReponse(this.globalThis.allocator(), this.globalThis);
+ this.onComplete(array);
+ return;
+ }
+
+ pub fn onComplete(this: *@This(), result: JSC.JSValue) void {
+ var promise = this.promise;
+ var globalThis = this.globalThis;
+ this.promise = .{};
+ promise.resolve(globalThis, result);
+ this.deinit();
+ }
+
+ pub fn deinit(this: *@This()) void {
+ this.poll_ref.unrefOnNextTick(this.globalThis.bunVM());
+ // freed
+ bun.default_allocator.free(this.name);
+
+ if (this.allocated)
+ this.globalThis.allocator().destroy(this);
+ }
+};
+
+pub const GetNameInfoRequest = struct {
+ const request_type = @This();
+
+ const log = Output.scoped(@This(), false);
+
+ resolver_for_caching: ?*DNSResolver = null,
+ hash: u64 = 0,
+ cache: @This().CacheConfig = @This().CacheConfig{},
+ head: CAresNameInfo,
+ tail: *CAresNameInfo = undefined,
+
+ pub fn init(
+ cache: DNSResolver.LookupCacheHit(@This()),
+ resolver: ?*DNSResolver,
+ name: []const u8,
+ globalThis: *JSC.JSGlobalObject,
+ comptime cache_field: []const u8,
+ ) !*@This() {
+ var request = try globalThis.allocator().create(@This());
+ var hasher = std.hash.Wyhash.init(0);
+ hasher.update(name);
+ const hash = hasher.final();
+ var poll_ref = JSC.PollRef.init();
+ poll_ref.ref(globalThis.bunVM());
+ request.* = .{
+ .resolver_for_caching = resolver,
+ .hash = hash,
+ .head = .{ .poll_ref = poll_ref, .globalThis = globalThis, .promise = JSC.JSPromise.Strong.init(globalThis), .allocated = false, .name = name },
+ };
+ request.tail = &request.head;
+ if (cache == .new) {
+ request.resolver_for_caching = resolver;
+ request.cache = @This().CacheConfig{
+ .pending_cache = true,
+ .entry_cache = false,
+ .pos_in_pending = @as(u5, @truncate(@field(resolver.?, cache_field).indexOf(cache.new).?)),
+ .name_len = @as(u9, @truncate(name.len)),
+ };
+ cache.new.lookup = request;
+ }
+ return request;
+ }
+
+ pub const CacheConfig = packed struct(u16) {
+ pending_cache: bool = false,
+ entry_cache: bool = false,
+ pos_in_pending: u5 = 0,
+ name_len: u9 = 0,
+ };
+
+ pub const PendingCacheKey = struct {
+ hash: u64,
+ len: u16,
+ lookup: *request_type = undefined,
+
+ pub fn append(this: *PendingCacheKey, cares_lookup: *CAresNameInfo) void {
+ var tail = this.lookup.tail;
+ tail.next = cares_lookup;
+ this.lookup.tail = cares_lookup;
+ }
+
+ pub fn init(name: []const u8) PendingCacheKey {
+ var hasher = std.hash.Wyhash.init(0);
+ hasher.update(name);
+ const hash = hasher.final();
+ return PendingCacheKey{
+ .hash = hash,
+ .len = @as(u16, @truncate(name.len)),
+ .lookup = undefined,
+ };
+ }
+ };
+
+ pub fn onCaresComplete(this: *@This(), err_: ?c_ares.Error, timeout: i32, result: ?c_ares.struct_nameinfo) void {
+ if (this.resolver_for_caching) |resolver| {
+ if (this.cache.pending_cache) {
+ resolver.drainPendingNameInfoCares(
+ this.cache.pos_in_pending,
+ err_,
+ timeout,
+ result,
+ );
+ return;
+ }
+ }
+
+ var head = this.head;
+ bun.default_allocator.destroy(this);
+
+ head.processResolve(err_, timeout, result);
+ }
+};
+
pub const GetAddrInfoRequest = struct {
const log = Output.scoped(.GetAddrInfoRequest, false);
@@ -1325,6 +1489,7 @@ pub const DNSResolver = struct {
pending_ptr_cache_cares: PtrPendingCache = PtrPendingCache.init(),
pending_cname_cache_cares: CnamePendingCache = CnamePendingCache.init(),
pending_addr_cache_crares: AddrPendingCache = AddrPendingCache.init(),
+ pending_nameinfo_cache_cares: NameInfoPendingCache = NameInfoPendingCache.init(),
const PendingCache = bun.HiveArray(GetAddrInfoRequest.PendingCacheKey, 32);
const SrvPendingCache = bun.HiveArray(ResolveInfoRequest(c_ares.struct_ares_srv_reply, "srv").PendingCacheKey, 32);
@@ -1337,6 +1502,7 @@ pub const DNSResolver = struct {
const PtrPendingCache = bun.HiveArray(ResolveInfoRequest(c_ares.struct_hostent, "ptr").PendingCacheKey, 32);
const CnamePendingCache = bun.HiveArray(ResolveInfoRequest(c_ares.struct_hostent, "cname").PendingCacheKey, 32);
const AddrPendingCache = bun.HiveArray(GetHostByAddrInfoRequest.PendingCacheKey, 32);
+ const NameInfoPendingCache = bun.HiveArray(GetNameInfoRequest.PendingCacheKey, 32);
fn getKey(this: *DNSResolver, index: u8, comptime cache_name: []const u8, comptime request_type: type) request_type.PendingCacheKey {
var cache = &@field(this, cache_name);
@@ -1523,6 +1689,47 @@ pub const DNSResolver = struct {
}
}
+ pub fn drainPendingNameInfoCares(this: *DNSResolver, index: u8, err: ?c_ares.Error, timeout: i32, result: ?c_ares.struct_nameinfo) void {
+ const key = this.getKey(index, "pending_nameinfo_cache_cares", GetNameInfoRequest);
+
+ var name_info = result orelse {
+ var pending: ?*CAresNameInfo = key.lookup.head.next;
+ key.lookup.head.processResolve(err, timeout, null);
+ bun.default_allocator.destroy(key.lookup);
+
+ while (pending) |value| {
+ pending = value.next;
+ value.processResolve(err, timeout, null);
+ }
+ return;
+ };
+
+ var pending: ?*CAresNameInfo = key.lookup.head.next;
+ var prev_global = key.lookup.head.globalThis;
+
+ var array = name_info.toJSReponse(this.vm.allocator, prev_global);
+ array.ensureStillAlive();
+ key.lookup.head.onComplete(array);
+ bun.default_allocator.destroy(key.lookup);
+
+ array.ensureStillAlive();
+
+ while (pending) |value| {
+ var new_global = value.globalThis;
+ if (prev_global != new_global) {
+ array = name_info.toJSReponse(this.vm.allocator, new_global);
+ prev_global = new_global;
+ }
+ pending = value.next;
+
+ {
+ array.ensureStillAlive();
+ value.onComplete(array);
+ array.ensureStillAlive();
+ }
+ }
+ }
+
pub const CacheHit = union(enum) {
inflight: *GetAddrInfoRequest.PendingCacheKey,
new: *GetAddrInfoRequest.PendingCacheKey,
@@ -2376,6 +2583,95 @@ pub const DNSResolver = struct {
return values;
}
+ // Resolves the given address and port into a host name and service using the operating system's underlying getnameinfo implementation.
+ // If address is not a valid IP address, a TypeError will be thrown. The port will be coerced to a number.
+ // If it is not a legal port, a TypeError will be thrown.
+ pub fn lookupService(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ const arguments = callframe.arguments(3);
+ if (arguments.len < 2) {
+ globalThis.throwNotEnoughArguments("lookupService", 3, arguments.len);
+ return .zero;
+ }
+
+ const addr_value = arguments.ptr[0];
+ const port_value = arguments.ptr[1];
+ if (addr_value.isEmptyOrUndefinedOrNull() or !addr_value.isString()) {
+ globalThis.throwInvalidArgumentType("lookupService", "address", "string");
+ return .zero;
+ }
+ const addr_str = addr_value.toStringOrNull(globalThis) orelse {
+ return .zero;
+ };
+ if (addr_str.length() == 0) {
+ globalThis.throwInvalidArgumentType("lookupService", "address", "non-empty string");
+ return .zero;
+ }
+
+ const addr_s = addr_str.getZigString(globalThis).slice();
+ const port: u16 = if (port_value.isNumber()) blk: {
+ break :blk port_value.to(u16);
+ } else {
+ globalThis.throwInvalidArgumentType("lookupService", "port", "invalid port");
+ return .zero;
+ };
+
+ var sa: std.os.sockaddr.storage = std.mem.zeroes(std.os.sockaddr.storage);
+ if (c_ares.getSockaddr(addr_s, port, @as(*std.os.sockaddr, @ptrCast(&sa))) != 0) {
+ globalThis.throwInvalidArgumentType("lookupService", "address", "invalid address");
+ return .zero;
+ }
+
+ var vm = globalThis.bunVM();
+ var resolver = vm.rareData().globalDNSResolver(vm);
+ var channel: *c_ares.Channel = switch (resolver.getChannel()) {
+ .result => |res| res,
+ .err => |err| {
+ const system_error = JSC.SystemError{
+ .errno = -1,
+ .code = bun.String.static(err.code()),
+ .message = bun.String.static(err.label()),
+ };
+
+ globalThis.throwValue(system_error.toErrorInstance(globalThis));
+ return .zero;
+ },
+ };
+
+ // This string will be freed in `CAresNameInfo.deinit`
+ const cache_name = std.fmt.allocPrint(bun.default_allocator, "{s}|{d}", .{ addr_s, port }) catch unreachable;
+
+ const key = GetNameInfoRequest.PendingCacheKey.init(cache_name);
+ var cache = resolver.getOrPutIntoResolvePendingCache(
+ GetNameInfoRequest,
+ key,
+ "pending_nameinfo_cache_cares",
+ );
+
+ if (cache == .inflight) {
+ var info = CAresNameInfo.init(globalThis, globalThis.allocator(), cache_name) catch unreachable;
+ cache.inflight.append(info);
+ return info.promise.value();
+ }
+
+ var request = GetNameInfoRequest.init(
+ cache,
+ resolver,
+ cache_name, // transfer ownership here
+ globalThis,
+ "pending_nameinfo_cache_cares",
+ ) catch unreachable;
+
+ const promise = request.tail.promise.value();
+ channel.getNameInfo(
+ @as(*std.os.sockaddr, @ptrCast(&sa)),
+ GetNameInfoRequest,
+ request,
+ GetNameInfoRequest.onCaresComplete,
+ );
+
+ return promise;
+ }
+
comptime {
@export(
resolve,
@@ -2455,11 +2751,13 @@ pub const DNSResolver = struct {
.name = "Bun__DNSResolver__reverse",
},
);
+ @export(
+ lookupService,
+ .{
+ .name = "Bun__DNSResolver__lookupService",
+ },
+ );
}
- // pub fn lookupService(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
- // const arguments = callframe.arguments(3);
-
- // }
// pub fn cancel(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
// const arguments = callframe.arguments(3);
diff --git a/src/bun.js/bindings/BunObject.cpp b/src/bun.js/bindings/BunObject.cpp
index 91fc810da..9d8ce6674 100644
--- a/src/bun.js/bindings/BunObject.cpp
+++ b/src/bun.js/bindings/BunObject.cpp
@@ -215,6 +215,7 @@ extern "C" EncodedJSValue Bun__DNSResolver__resolvePtr(JSGlobalObject*, JSC::Cal
extern "C" EncodedJSValue Bun__DNSResolver__resolveCname(JSGlobalObject*, JSC::CallFrame*);
extern "C" EncodedJSValue Bun__DNSResolver__getServers(JSGlobalObject*, JSC::CallFrame*);
extern "C" EncodedJSValue Bun__DNSResolver__reverse(JSGlobalObject*, JSC::CallFrame*);
+extern "C" EncodedJSValue Bun__DNSResolver__lookupService(JSGlobalObject*, JSC::CallFrame*);
static JSValue constructDNSObject(VM& vm, JSObject* bunObject)
{
@@ -246,6 +247,8 @@ static JSValue constructDNSObject(VM& vm, JSObject* bunObject)
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "reverse"_s), 2, Bun__DNSResolver__reverse, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
+ dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "lookupService"_s), 2, Bun__DNSResolver__lookupService, ImplementationVisibility::Public, NoIntrinsic,
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
return dnsObject;
}
diff --git a/src/deps/c_ares.zig b/src/deps/c_ares.zig
index 62880c3ed..3c86b0327 100644
--- a/src/deps/c_ares.zig
+++ b/src/deps/c_ares.zig
@@ -284,6 +284,55 @@ pub const struct_hostent = extern struct {
ares_free_hostent(this);
}
};
+
+pub const struct_nameinfo = extern struct {
+ node: [*c]u8,
+ service: [*c]u8,
+
+ pub fn toJSReponse(this: *struct_nameinfo, _: std.mem.Allocator, globalThis: *JSC.JSGlobalObject) JSC.JSValue {
+ const array = JSC.JSValue.createEmptyArray(globalThis, 2); // [node, service]
+
+ if (this.node != null) {
+ const node_len = bun.len(this.node);
+ const node_slice = this.node[0..node_len];
+ array.putIndex(globalThis, 0, JSC.ZigString.fromUTF8(node_slice).toValueGC(globalThis));
+ } else {
+ array.putIndex(globalThis, 0, JSC.JSValue.jsUndefined());
+ }
+
+ if (this.service != null) {
+ const service_len = bun.len(this.service);
+ const service_slice = this.service[0..service_len];
+ array.putIndex(globalThis, 1, JSC.ZigString.fromUTF8(service_slice).toValueGC(globalThis));
+ } else {
+ array.putIndex(globalThis, 1, JSC.JSValue.jsUndefined());
+ }
+
+ return array;
+ }
+
+ pub fn Callback(comptime Type: type) type {
+ return fn (*Type, status: ?Error, timeouts: i32, node: ?struct_nameinfo) void;
+ }
+
+ pub fn CallbackWrapper(
+ comptime Type: type,
+ comptime function: Callback(Type),
+ ) ares_nameinfo_callback {
+ return &struct {
+ pub fn handle(ctx: ?*anyopaque, status: c_int, timeouts: c_int, node: [*c]u8, service: [*c]u8) callconv(.C) void {
+ var this = bun.cast(*Type, ctx.?);
+ if (status != ARES_SUCCESS) {
+ function(this, Error.get(status), timeouts, null);
+ return;
+ }
+ function(this, null, timeouts, .{ node, service });
+ return;
+ }
+ }.handle;
+ }
+};
+
pub const struct_timeval = opaque {};
pub const struct_Channeldata = opaque {};
pub const AddrInfo_cname = extern struct {
@@ -572,6 +621,20 @@ pub const Channel = opaque {
struct_hostent.hostCallbackWrapper(Type, callback).?(ctx, ARES_ENOTIMP, 0, null);
}
+ // https://c-ares.org/ares_getnameinfo.html
+ pub fn getNameInfo(this: *Channel, sa: *std.os.sockaddr, comptime Type: type, ctx: *Type, comptime callback: struct_nameinfo.Callback(Type)) void {
+ return ares_getnameinfo(
+ this,
+ sa,
+ if (sa.*.family == std.os.AF.INET) @sizeOf(std.os.sockaddr.in) else @sizeOf(std.os.sockaddr.in6),
+ // node returns ENOTFOUND for addresses like 255.255.255.255:80
+ // So, it requires setting the ARES_NI_NAMEREQD flag
+ ARES_NI_NAMEREQD | ARES_NI_LOOKUPHOST | ARES_NI_LOOKUPSERVICE,
+ struct_nameinfo.CallbackWrapper(Type, callback),
+ ctx,
+ );
+ }
+
pub inline fn process(this: *Channel, fd: i32, readable: bool, writable: bool) void {
ares_process_fd(
this,
@@ -1471,6 +1534,52 @@ pub export fn Bun__canonicalizeIP(
return .zero;
}
}
+
+/// Creates a sockaddr structure from an address, port.
+///
+/// # Parameters
+/// - `addr`: A byte slice representing the IP address.
+/// - `port`: A 16-bit unsigned integer representing the port number.
+/// - `sa`: A pointer to a sockaddr structure where the result will be stored.
+///
+/// # Returns
+///
+/// This function returns 0 on success.
+pub fn getSockaddr(addr: []const u8, port: u16, sa: *std.os.sockaddr) c_int {
+ const buf_size = 128;
+
+ var buf: [buf_size]u8 = undefined;
+ const addr_ptr: [*:0]const u8 = brk: {
+ if (addr.len == 0 or addr.len >= buf_size) {
+ return -1;
+ }
+ const len = @min(addr.len, buf.len - 1);
+ @memcpy(buf[0..len], addr[0..len]);
+
+ buf[len] = 0;
+ break :brk buf[0..len :0];
+ };
+
+ {
+ const in: *std.os.sockaddr.in = @as(*std.os.sockaddr.in, @alignCast(@ptrCast(sa)));
+ if (ares_inet_pton(std.os.AF.INET, addr_ptr, &in.addr) == 1) {
+ in.*.family = std.os.AF.INET;
+ in.*.port = std.mem.nativeToBig(u16, port);
+ return 0;
+ }
+ }
+ {
+ const in6: *std.os.sockaddr.in6 = @as(*std.os.sockaddr.in6, @alignCast(@ptrCast(sa)));
+ if (ares_inet_pton(std.os.AF.INET6, addr_ptr, &in6.addr) == 1) {
+ in6.*.family = std.os.AF.INET6;
+ in6.*.port = std.mem.nativeToBig(u16, port);
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
comptime {
if (!JSC.is_bindgen) {
_ = Bun__canonicalizeIP;
diff --git a/src/js/node/dns.js b/src/js/node/dns.js
index a6de07351..7e6fc97dd 100644
--- a/src/js/node/dns.js
+++ b/src/js/node/dns.js
@@ -176,7 +176,14 @@ function lookupService(address, port, callback) {
throw new TypeError("callback must be a function");
}
- callback(null, address, port);
+ dns.lookupService(address, port, callback).then(
+ results => {
+ callback(null, ...results);
+ },
+ error => {
+ callback(error);
+ },
+ );
}
function reverse(ip, callback) {
@@ -517,7 +524,7 @@ const promises = {
},
lookupService(address, port) {
- return Promise.resolve([]);
+ return dns.lookupService(address, port);
},
resolve(hostname, rrtype) {
diff --git a/src/js/out/InternalModuleRegistryConstants.h b/src/js/out/InternalModuleRegistryConstants.h
index d0b3dff39..91953b77e 100644
--- a/src/js/out/InternalModuleRegistryConstants.h
+++ b/src/js/out/InternalModuleRegistryConstants.h
@@ -66,7 +66,7 @@ static constexpr ASCIILiteral NodeDiagnosticsChannelCode = "(function (){\"use s
//
//
-static constexpr ASCIILiteral NodeDNSCode = "(function (){\"use strict\";// src/js/out/tmp/node/dns.ts\nvar getServers = function() {\n return dns.getServers();\n}, lookup = function(domain, options, callback) {\n if (typeof options == \"function\")\n callback = options;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n if (typeof options == \"number\")\n options = { family: options };\n dns.lookup(domain, options).then((res) => {\n if (res.sort((a, b) => a.family - b.family), options\?.all)\n callback(null, res.map(mapLookupAll));\n else {\n const [{ address, family }] = res;\n callback(null, address, family);\n }\n }, (error) => {\n callback(error);\n });\n}, resolveSrv = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSrv(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveTxt = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveTxt(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveSoa = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSoa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveNaptr = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNaptr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveMx = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveMx(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveCaa = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCaa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveNs = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNs(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolvePtr = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolvePtr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveCname = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCname(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, lookupService = function(address, port, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n callback(null, address, port);\n}, reverse = function(ip, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.reverse(ip, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolve = function(hostname, rrtype, callback) {\n if (typeof rrtype == \"function\")\n callback = rrtype;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolve(hostname).then((results) => {\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n callback(null, hostname, results.map(({ address }) => address));\n break;\n default:\n callback(null, results);\n break;\n }\n }, (error) => {\n callback(error);\n });\n}, Resolver = function(options) {\n return new InternalResolver(options);\n}, setDefaultResultOrder = function() {\n}, setServers = function() {\n}, $, dns = Bun.dns, InternalResolver = class Resolver2 {\n constructor(options) {\n }\n cancel() {\n }\n getServers() {\n return [];\n }\n resolve(hostname, rrtype, callback) {\n if (typeof rrtype == \"function\")\n callback = rrtype, rrtype = null;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolve(hostname).then((results) => {\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n callback(null, hostname, results.map(mapResolveX));\n break;\n default:\n callback(null, results);\n break;\n }\n }, (error) => {\n callback(error);\n });\n }\n resolve4(hostname, options, callback) {\n if (typeof options == \"function\")\n callback = options, options = null;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.lookup(hostname, { family: 4 }).then((addresses) => {\n callback(null, options\?.ttl \? addresses : addresses.map(mapResolveX));\n }, (error) => {\n callback(error);\n });\n }\n resolve6(hostname, options, callback) {\n if (typeof options == \"function\")\n callback = options, options = null;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.lookup(hostname, { family: 6 }).then((addresses) => {\n callback(null, options\?.ttl \? addresses : addresses.map(({ address }) => address));\n }, (error) => {\n callback(error);\n });\n }\n resolveAny(hostname, callback) {\n callback(null, []);\n }\n resolveCname(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCname(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveMx(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveMx(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveNaptr(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNaptr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveNs(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNs(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolvePtr(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolvePtr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveSrv(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSrv(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveCaa(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCaa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveTxt(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveTxt(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveSoa(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSoa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n reverse(ip, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.reverse(ip, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n setServers(servers) {\n }\n};\nResolver.prototype = {};\nObject.setPrototypeOf(Resolver.prototype, InternalResolver.prototype);\nObject.setPrototypeOf(Resolver, InternalResolver);\nvar {\n resolve,\n resolve4,\n resolve6,\n resolveAny,\n resolveCname,\n resolveCaa,\n resolveMx,\n resolveNaptr,\n resolveNs,\n resolvePtr,\n resolveSoa,\n resolveSrv,\n reverse,\n resolveTxt\n} = InternalResolver.prototype, promisifyLookup = (res) => {\n res.sort((a, b) => a.family - b.family);\n const [{ address, family }] = res;\n return { address, family };\n}, mapLookupAll = (res) => {\n const { address, family } = res;\n return { address, family };\n}, promisifyLookupAll = (res) => {\n return res.sort((a, b) => a.family - b.family), res.map(mapLookupAll);\n}, mapResolveX = (a) => a.address, promisifyResolveX = (res) => {\n return res\?.map(mapResolveX);\n}, promises = {\n lookup(domain, options) {\n if (options\?.all)\n return dns.lookup(domain, options).then(promisifyLookupAll);\n return dns.lookup(domain, options).then(promisifyLookup);\n },\n lookupService(address, port) {\n return @Promise.resolve([]);\n },\n resolve(hostname, rrtype) {\n if (typeof rrtype !== \"string\")\n rrtype = null;\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n return dns.resolve(hostname, rrtype).then(promisifyLookup);\n default:\n return dns.resolve(hostname, rrtype);\n }\n },\n resolve4(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 4 });\n return dns.lookup(hostname, { family: 4 }).then(promisifyResolveX);\n },\n resolve6(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 6 });\n return dns.lookup(hostname, { family: 6 }).then(promisifyResolveX);\n },\n resolveSrv(hostname) {\n return dns.resolveSrv(hostname);\n },\n resolveTxt(hostname) {\n return dns.resolveTxt(hostname);\n },\n resolveSoa(hostname) {\n return dns.resolveSoa(hostname);\n },\n resolveNaptr(hostname) {\n return dns.resolveNaptr(hostname);\n },\n resolveMx(hostname) {\n return dns.resolveMx(hostname);\n },\n resolveCaa(hostname) {\n return dns.resolveCaa(hostname);\n },\n resolveNs(hostname) {\n return dns.resolveNs(hostname);\n },\n resolvePtr(hostname) {\n return dns.resolvePtr(hostname);\n },\n resolveCname(hostname) {\n return dns.resolveCname(hostname);\n },\n reverse(ip) {\n return dns.reverse(ip);\n },\n Resolver: class Resolver3 {\n constructor(options) {\n }\n cancel() {\n }\n getServers() {\n return [];\n }\n resolve(hostname, rrtype) {\n if (typeof rrtype !== \"string\")\n rrtype = null;\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n return dns.resolve(hostname, rrtype).then(promisifyLookup);\n default:\n return dns.resolve(hostname, rrtype);\n }\n }\n resolve4(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 4 });\n return dns.lookup(hostname, { family: 4 }).then(promisifyResolveX);\n }\n resolve6(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 6 });\n return dns.lookup(hostname, { family: 6 }).then(promisifyResolveX);\n }\n resolveAny(hostname) {\n return @Promise.resolve([]);\n }\n resolveCname(hostname) {\n return dns.resolveCname(hostname);\n }\n resolveMx(hostname) {\n return dns.resolveMx(hostname);\n }\n resolveNaptr(hostname) {\n return dns.resolveNaptr(hostname);\n }\n resolveNs(hostname) {\n return dns.resolveNs(hostname);\n }\n resolvePtr(hostname) {\n return dns.resolvePtr(hostname);\n }\n resolveSoa(hostname) {\n return dns.resolveSoa(hostname);\n }\n resolveSrv(hostname) {\n return dns.resolveSrv(hostname);\n }\n resolveCaa(hostname) {\n return dns.resolveCaa(hostname);\n }\n resolveTxt(hostname) {\n return dns.resolveTxt(hostname);\n }\n reverse(ip) {\n return dns.reverse(ip);\n }\n setServers(servers) {\n }\n }\n};\nfor (let key of [\"resolveAny\"])\n promises[key] = () => @Promise.resolve(@undefined);\n$ = {\n ADDRCONFIG: 0,\n ALL: 1,\n V4MAPPED: 2,\n NODATA: \"DNS_ENODATA\",\n FORMERR: \"DNS_EFORMERR\",\n SERVFAIL: \"DNS_ESERVFAIL\",\n NOTFOUND: \"DNS_ENOTFOUND\",\n NOTIMP: \"DNS_ENOTIMP\",\n REFUSED: \"DNS_EREFUSED\",\n BADQUERY: \"DNS_EBADQUERY\",\n BADNAME: \"DNS_EBADNAME\",\n BADFAMILY: \"DNS_EBADFAMILY\",\n BADRESP: \"DNS_EBADRESP\",\n CONNREFUSED: \"DNS_ECONNREFUSED\",\n TIMEOUT: \"DNS_ETIMEOUT\",\n EOF: \"DNS_EEOF\",\n FILE: \"DNS_EFILE\",\n NOMEM: \"DNS_ENOMEM\",\n DESTRUCTION: \"DNS_EDESTRUCTION\",\n BADSTR: \"DNS_EBADSTR\",\n BADFLAGS: \"DNS_EBADFLAGS\",\n NONAME: \"DNS_ENONAME\",\n BADHINTS: \"DNS_EBADHINTS\",\n NOTINITIALIZED: \"DNS_ENOTINITIALIZED\",\n LOADIPHLPAPI: \"DNS_ELOADIPHLPAPI\",\n ADDRGETNETWORKPARAMS: \"DNS_EADDRGETNETWORKPARAMS\",\n CANCELLED: \"DNS_ECANCELLED\",\n lookup,\n lookupService,\n Resolver,\n setServers,\n setDefaultResultOrder,\n resolve,\n reverse,\n resolve4,\n resolve6,\n resolveAny,\n resolveCname,\n resolveCaa,\n resolveMx,\n resolveNs,\n resolvePtr,\n resolveSoa,\n resolveSrv,\n resolveTxt,\n resolveNaptr,\n promises,\n getServers\n};\nreturn $})\n"_s;
+static constexpr ASCIILiteral NodeDNSCode = "(function (){\"use strict\";// src/js/out/tmp/node/dns.ts\nvar getServers = function() {\n return dns.getServers();\n}, lookup = function(domain, options, callback) {\n if (typeof options == \"function\")\n callback = options;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n if (typeof options == \"number\")\n options = { family: options };\n dns.lookup(domain, options).then((res) => {\n if (res.sort((a, b) => a.family - b.family), options\?.all)\n callback(null, res.map(mapLookupAll));\n else {\n const [{ address, family }] = res;\n callback(null, address, family);\n }\n }, (error) => {\n callback(error);\n });\n}, resolveSrv = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSrv(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveTxt = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveTxt(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveSoa = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSoa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveNaptr = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNaptr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveMx = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveMx(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveCaa = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCaa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveNs = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNs(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolvePtr = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolvePtr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveCname = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCname(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, lookupService = function(address, port, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.lookupService(address, port, callback).then((results) => {\n callback(null, ...results);\n }, (error) => {\n callback(error);\n });\n}, reverse = function(ip, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.reverse(ip, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolve = function(hostname, rrtype, callback) {\n if (typeof rrtype == \"function\")\n callback = rrtype;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolve(hostname).then((results) => {\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n callback(null, hostname, results.map(({ address }) => address));\n break;\n default:\n callback(null, results);\n break;\n }\n }, (error) => {\n callback(error);\n });\n}, Resolver = function(options) {\n return new InternalResolver(options);\n}, setDefaultResultOrder = function() {\n}, setServers = function() {\n}, $, dns = Bun.dns, InternalResolver = class Resolver2 {\n constructor(options) {\n }\n cancel() {\n }\n getServers() {\n return [];\n }\n resolve(hostname, rrtype, callback) {\n if (typeof rrtype == \"function\")\n callback = rrtype, rrtype = null;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolve(hostname).then((results) => {\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n callback(null, hostname, results.map(mapResolveX));\n break;\n default:\n callback(null, results);\n break;\n }\n }, (error) => {\n callback(error);\n });\n }\n resolve4(hostname, options, callback) {\n if (typeof options == \"function\")\n callback = options, options = null;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.lookup(hostname, { family: 4 }).then((addresses) => {\n callback(null, options\?.ttl \? addresses : addresses.map(mapResolveX));\n }, (error) => {\n callback(error);\n });\n }\n resolve6(hostname, options, callback) {\n if (typeof options == \"function\")\n callback = options, options = null;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.lookup(hostname, { family: 6 }).then((addresses) => {\n callback(null, options\?.ttl \? addresses : addresses.map(({ address }) => address));\n }, (error) => {\n callback(error);\n });\n }\n resolveAny(hostname, callback) {\n callback(null, []);\n }\n resolveCname(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCname(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveMx(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveMx(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveNaptr(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNaptr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveNs(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNs(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolvePtr(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolvePtr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveSrv(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSrv(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveCaa(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCaa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveTxt(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveTxt(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveSoa(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSoa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n reverse(ip, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.reverse(ip, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n setServers(servers) {\n }\n};\nResolver.prototype = {};\nObject.setPrototypeOf(Resolver.prototype, InternalResolver.prototype);\nObject.setPrototypeOf(Resolver, InternalResolver);\nvar {\n resolve,\n resolve4,\n resolve6,\n resolveAny,\n resolveCname,\n resolveCaa,\n resolveMx,\n resolveNaptr,\n resolveNs,\n resolvePtr,\n resolveSoa,\n resolveSrv,\n reverse,\n resolveTxt\n} = InternalResolver.prototype, promisifyLookup = (res) => {\n res.sort((a, b) => a.family - b.family);\n const [{ address, family }] = res;\n return { address, family };\n}, mapLookupAll = (res) => {\n const { address, family } = res;\n return { address, family };\n}, promisifyLookupAll = (res) => {\n return res.sort((a, b) => a.family - b.family), res.map(mapLookupAll);\n}, mapResolveX = (a) => a.address, promisifyResolveX = (res) => {\n return res\?.map(mapResolveX);\n}, promises = {\n lookup(domain, options) {\n if (options\?.all)\n return dns.lookup(domain, options).then(promisifyLookupAll);\n return dns.lookup(domain, options).then(promisifyLookup);\n },\n lookupService(address, port) {\n return dns.lookupService(address, port);\n },\n resolve(hostname, rrtype) {\n if (typeof rrtype !== \"string\")\n rrtype = null;\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n return dns.resolve(hostname, rrtype).then(promisifyLookup);\n default:\n return dns.resolve(hostname, rrtype);\n }\n },\n resolve4(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 4 });\n return dns.lookup(hostname, { family: 4 }).then(promisifyResolveX);\n },\n resolve6(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 6 });\n return dns.lookup(hostname, { family: 6 }).then(promisifyResolveX);\n },\n resolveSrv(hostname) {\n return dns.resolveSrv(hostname);\n },\n resolveTxt(hostname) {\n return dns.resolveTxt(hostname);\n },\n resolveSoa(hostname) {\n return dns.resolveSoa(hostname);\n },\n resolveNaptr(hostname) {\n return dns.resolveNaptr(hostname);\n },\n resolveMx(hostname) {\n return dns.resolveMx(hostname);\n },\n resolveCaa(hostname) {\n return dns.resolveCaa(hostname);\n },\n resolveNs(hostname) {\n return dns.resolveNs(hostname);\n },\n resolvePtr(hostname) {\n return dns.resolvePtr(hostname);\n },\n resolveCname(hostname) {\n return dns.resolveCname(hostname);\n },\n reverse(ip) {\n return dns.reverse(ip);\n },\n Resolver: class Resolver3 {\n constructor(options) {\n }\n cancel() {\n }\n getServers() {\n return [];\n }\n resolve(hostname, rrtype) {\n if (typeof rrtype !== \"string\")\n rrtype = null;\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n return dns.resolve(hostname, rrtype).then(promisifyLookup);\n default:\n return dns.resolve(hostname, rrtype);\n }\n }\n resolve4(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 4 });\n return dns.lookup(hostname, { family: 4 }).then(promisifyResolveX);\n }\n resolve6(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 6 });\n return dns.lookup(hostname, { family: 6 }).then(promisifyResolveX);\n }\n resolveAny(hostname) {\n return @Promise.resolve([]);\n }\n resolveCname(hostname) {\n return dns.resolveCname(hostname);\n }\n resolveMx(hostname) {\n return dns.resolveMx(hostname);\n }\n resolveNaptr(hostname) {\n return dns.resolveNaptr(hostname);\n }\n resolveNs(hostname) {\n return dns.resolveNs(hostname);\n }\n resolvePtr(hostname) {\n return dns.resolvePtr(hostname);\n }\n resolveSoa(hostname) {\n return dns.resolveSoa(hostname);\n }\n resolveSrv(hostname) {\n return dns.resolveSrv(hostname);\n }\n resolveCaa(hostname) {\n return dns.resolveCaa(hostname);\n }\n resolveTxt(hostname) {\n return dns.resolveTxt(hostname);\n }\n reverse(ip) {\n return dns.reverse(ip);\n }\n setServers(servers) {\n }\n }\n};\nfor (let key of [\"resolveAny\"])\n promises[key] = () => @Promise.resolve(@undefined);\n$ = {\n ADDRCONFIG: 0,\n ALL: 1,\n V4MAPPED: 2,\n NODATA: \"DNS_ENODATA\",\n FORMERR: \"DNS_EFORMERR\",\n SERVFAIL: \"DNS_ESERVFAIL\",\n NOTFOUND: \"DNS_ENOTFOUND\",\n NOTIMP: \"DNS_ENOTIMP\",\n REFUSED: \"DNS_EREFUSED\",\n BADQUERY: \"DNS_EBADQUERY\",\n BADNAME: \"DNS_EBADNAME\",\n BADFAMILY: \"DNS_EBADFAMILY\",\n BADRESP: \"DNS_EBADRESP\",\n CONNREFUSED: \"DNS_ECONNREFUSED\",\n TIMEOUT: \"DNS_ETIMEOUT\",\n EOF: \"DNS_EEOF\",\n FILE: \"DNS_EFILE\",\n NOMEM: \"DNS_ENOMEM\",\n DESTRUCTION: \"DNS_EDESTRUCTION\",\n BADSTR: \"DNS_EBADSTR\",\n BADFLAGS: \"DNS_EBADFLAGS\",\n NONAME: \"DNS_ENONAME\",\n BADHINTS: \"DNS_EBADHINTS\",\n NOTINITIALIZED: \"DNS_ENOTINITIALIZED\",\n LOADIPHLPAPI: \"DNS_ELOADIPHLPAPI\",\n ADDRGETNETWORKPARAMS: \"DNS_EADDRGETNETWORKPARAMS\",\n CANCELLED: \"DNS_ECANCELLED\",\n lookup,\n lookupService,\n Resolver,\n setServers,\n setDefaultResultOrder,\n resolve,\n reverse,\n resolve4,\n resolve6,\n resolveAny,\n resolveCname,\n resolveCaa,\n resolveMx,\n resolveNs,\n resolvePtr,\n resolveSoa,\n resolveSrv,\n resolveTxt,\n resolveNaptr,\n promises,\n getServers\n};\nreturn $})\n"_s;
//
//
@@ -307,7 +307,7 @@ static constexpr ASCIILiteral NodeDiagnosticsChannelCode = "(function (){\"use s
//
//
-static constexpr ASCIILiteral NodeDNSCode = "(function (){\"use strict\";// src/js/out/tmp/node/dns.ts\nvar getServers = function() {\n return dns.getServers();\n}, lookup = function(domain, options, callback) {\n if (typeof options == \"function\")\n callback = options;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n if (typeof options == \"number\")\n options = { family: options };\n dns.lookup(domain, options).then((res) => {\n if (res.sort((a, b) => a.family - b.family), options\?.all)\n callback(null, res.map(mapLookupAll));\n else {\n const [{ address, family }] = res;\n callback(null, address, family);\n }\n }, (error) => {\n callback(error);\n });\n}, resolveSrv = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSrv(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveTxt = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveTxt(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveSoa = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSoa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveNaptr = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNaptr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveMx = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveMx(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveCaa = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCaa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveNs = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNs(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolvePtr = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolvePtr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveCname = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCname(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, lookupService = function(address, port, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n callback(null, address, port);\n}, reverse = function(ip, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.reverse(ip, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolve = function(hostname, rrtype, callback) {\n if (typeof rrtype == \"function\")\n callback = rrtype;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolve(hostname).then((results) => {\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n callback(null, hostname, results.map(({ address }) => address));\n break;\n default:\n callback(null, results);\n break;\n }\n }, (error) => {\n callback(error);\n });\n}, Resolver = function(options) {\n return new InternalResolver(options);\n}, setDefaultResultOrder = function() {\n}, setServers = function() {\n}, $, dns = Bun.dns, InternalResolver = class Resolver2 {\n constructor(options) {\n }\n cancel() {\n }\n getServers() {\n return [];\n }\n resolve(hostname, rrtype, callback) {\n if (typeof rrtype == \"function\")\n callback = rrtype, rrtype = null;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolve(hostname).then((results) => {\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n callback(null, hostname, results.map(mapResolveX));\n break;\n default:\n callback(null, results);\n break;\n }\n }, (error) => {\n callback(error);\n });\n }\n resolve4(hostname, options, callback) {\n if (typeof options == \"function\")\n callback = options, options = null;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.lookup(hostname, { family: 4 }).then((addresses) => {\n callback(null, options\?.ttl \? addresses : addresses.map(mapResolveX));\n }, (error) => {\n callback(error);\n });\n }\n resolve6(hostname, options, callback) {\n if (typeof options == \"function\")\n callback = options, options = null;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.lookup(hostname, { family: 6 }).then((addresses) => {\n callback(null, options\?.ttl \? addresses : addresses.map(({ address }) => address));\n }, (error) => {\n callback(error);\n });\n }\n resolveAny(hostname, callback) {\n callback(null, []);\n }\n resolveCname(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCname(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveMx(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveMx(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveNaptr(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNaptr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveNs(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNs(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolvePtr(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolvePtr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveSrv(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSrv(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveCaa(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCaa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveTxt(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveTxt(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveSoa(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSoa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n reverse(ip, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.reverse(ip, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n setServers(servers) {\n }\n};\nResolver.prototype = {};\nObject.setPrototypeOf(Resolver.prototype, InternalResolver.prototype);\nObject.setPrototypeOf(Resolver, InternalResolver);\nvar {\n resolve,\n resolve4,\n resolve6,\n resolveAny,\n resolveCname,\n resolveCaa,\n resolveMx,\n resolveNaptr,\n resolveNs,\n resolvePtr,\n resolveSoa,\n resolveSrv,\n reverse,\n resolveTxt\n} = InternalResolver.prototype, promisifyLookup = (res) => {\n res.sort((a, b) => a.family - b.family);\n const [{ address, family }] = res;\n return { address, family };\n}, mapLookupAll = (res) => {\n const { address, family } = res;\n return { address, family };\n}, promisifyLookupAll = (res) => {\n return res.sort((a, b) => a.family - b.family), res.map(mapLookupAll);\n}, mapResolveX = (a) => a.address, promisifyResolveX = (res) => {\n return res\?.map(mapResolveX);\n}, promises = {\n lookup(domain, options) {\n if (options\?.all)\n return dns.lookup(domain, options).then(promisifyLookupAll);\n return dns.lookup(domain, options).then(promisifyLookup);\n },\n lookupService(address, port) {\n return @Promise.resolve([]);\n },\n resolve(hostname, rrtype) {\n if (typeof rrtype !== \"string\")\n rrtype = null;\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n return dns.resolve(hostname, rrtype).then(promisifyLookup);\n default:\n return dns.resolve(hostname, rrtype);\n }\n },\n resolve4(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 4 });\n return dns.lookup(hostname, { family: 4 }).then(promisifyResolveX);\n },\n resolve6(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 6 });\n return dns.lookup(hostname, { family: 6 }).then(promisifyResolveX);\n },\n resolveSrv(hostname) {\n return dns.resolveSrv(hostname);\n },\n resolveTxt(hostname) {\n return dns.resolveTxt(hostname);\n },\n resolveSoa(hostname) {\n return dns.resolveSoa(hostname);\n },\n resolveNaptr(hostname) {\n return dns.resolveNaptr(hostname);\n },\n resolveMx(hostname) {\n return dns.resolveMx(hostname);\n },\n resolveCaa(hostname) {\n return dns.resolveCaa(hostname);\n },\n resolveNs(hostname) {\n return dns.resolveNs(hostname);\n },\n resolvePtr(hostname) {\n return dns.resolvePtr(hostname);\n },\n resolveCname(hostname) {\n return dns.resolveCname(hostname);\n },\n reverse(ip) {\n return dns.reverse(ip);\n },\n Resolver: class Resolver3 {\n constructor(options) {\n }\n cancel() {\n }\n getServers() {\n return [];\n }\n resolve(hostname, rrtype) {\n if (typeof rrtype !== \"string\")\n rrtype = null;\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n return dns.resolve(hostname, rrtype).then(promisifyLookup);\n default:\n return dns.resolve(hostname, rrtype);\n }\n }\n resolve4(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 4 });\n return dns.lookup(hostname, { family: 4 }).then(promisifyResolveX);\n }\n resolve6(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 6 });\n return dns.lookup(hostname, { family: 6 }).then(promisifyResolveX);\n }\n resolveAny(hostname) {\n return @Promise.resolve([]);\n }\n resolveCname(hostname) {\n return dns.resolveCname(hostname);\n }\n resolveMx(hostname) {\n return dns.resolveMx(hostname);\n }\n resolveNaptr(hostname) {\n return dns.resolveNaptr(hostname);\n }\n resolveNs(hostname) {\n return dns.resolveNs(hostname);\n }\n resolvePtr(hostname) {\n return dns.resolvePtr(hostname);\n }\n resolveSoa(hostname) {\n return dns.resolveSoa(hostname);\n }\n resolveSrv(hostname) {\n return dns.resolveSrv(hostname);\n }\n resolveCaa(hostname) {\n return dns.resolveCaa(hostname);\n }\n resolveTxt(hostname) {\n return dns.resolveTxt(hostname);\n }\n reverse(ip) {\n return dns.reverse(ip);\n }\n setServers(servers) {\n }\n }\n};\nfor (let key of [\"resolveAny\"])\n promises[key] = () => @Promise.resolve(@undefined);\n$ = {\n ADDRCONFIG: 0,\n ALL: 1,\n V4MAPPED: 2,\n NODATA: \"DNS_ENODATA\",\n FORMERR: \"DNS_EFORMERR\",\n SERVFAIL: \"DNS_ESERVFAIL\",\n NOTFOUND: \"DNS_ENOTFOUND\",\n NOTIMP: \"DNS_ENOTIMP\",\n REFUSED: \"DNS_EREFUSED\",\n BADQUERY: \"DNS_EBADQUERY\",\n BADNAME: \"DNS_EBADNAME\",\n BADFAMILY: \"DNS_EBADFAMILY\",\n BADRESP: \"DNS_EBADRESP\",\n CONNREFUSED: \"DNS_ECONNREFUSED\",\n TIMEOUT: \"DNS_ETIMEOUT\",\n EOF: \"DNS_EEOF\",\n FILE: \"DNS_EFILE\",\n NOMEM: \"DNS_ENOMEM\",\n DESTRUCTION: \"DNS_EDESTRUCTION\",\n BADSTR: \"DNS_EBADSTR\",\n BADFLAGS: \"DNS_EBADFLAGS\",\n NONAME: \"DNS_ENONAME\",\n BADHINTS: \"DNS_EBADHINTS\",\n NOTINITIALIZED: \"DNS_ENOTINITIALIZED\",\n LOADIPHLPAPI: \"DNS_ELOADIPHLPAPI\",\n ADDRGETNETWORKPARAMS: \"DNS_EADDRGETNETWORKPARAMS\",\n CANCELLED: \"DNS_ECANCELLED\",\n lookup,\n lookupService,\n Resolver,\n setServers,\n setDefaultResultOrder,\n resolve,\n reverse,\n resolve4,\n resolve6,\n resolveAny,\n resolveCname,\n resolveCaa,\n resolveMx,\n resolveNs,\n resolvePtr,\n resolveSoa,\n resolveSrv,\n resolveTxt,\n resolveNaptr,\n promises,\n getServers\n};\nreturn $})\n"_s;
+static constexpr ASCIILiteral NodeDNSCode = "(function (){\"use strict\";// src/js/out/tmp/node/dns.ts\nvar getServers = function() {\n return dns.getServers();\n}, lookup = function(domain, options, callback) {\n if (typeof options == \"function\")\n callback = options;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n if (typeof options == \"number\")\n options = { family: options };\n dns.lookup(domain, options).then((res) => {\n if (res.sort((a, b) => a.family - b.family), options\?.all)\n callback(null, res.map(mapLookupAll));\n else {\n const [{ address, family }] = res;\n callback(null, address, family);\n }\n }, (error) => {\n callback(error);\n });\n}, resolveSrv = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSrv(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveTxt = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveTxt(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveSoa = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSoa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveNaptr = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNaptr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveMx = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveMx(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveCaa = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCaa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveNs = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNs(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolvePtr = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolvePtr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveCname = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCname(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, lookupService = function(address, port, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.lookupService(address, port, callback).then((results) => {\n callback(null, ...results);\n }, (error) => {\n callback(error);\n });\n}, reverse = function(ip, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.reverse(ip, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolve = function(hostname, rrtype, callback) {\n if (typeof rrtype == \"function\")\n callback = rrtype;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolve(hostname).then((results) => {\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n callback(null, hostname, results.map(({ address }) => address));\n break;\n default:\n callback(null, results);\n break;\n }\n }, (error) => {\n callback(error);\n });\n}, Resolver = function(options) {\n return new InternalResolver(options);\n}, setDefaultResultOrder = function() {\n}, setServers = function() {\n}, $, dns = Bun.dns, InternalResolver = class Resolver2 {\n constructor(options) {\n }\n cancel() {\n }\n getServers() {\n return [];\n }\n resolve(hostname, rrtype, callback) {\n if (typeof rrtype == \"function\")\n callback = rrtype, rrtype = null;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolve(hostname).then((results) => {\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n callback(null, hostname, results.map(mapResolveX));\n break;\n default:\n callback(null, results);\n break;\n }\n }, (error) => {\n callback(error);\n });\n }\n resolve4(hostname, options, callback) {\n if (typeof options == \"function\")\n callback = options, options = null;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.lookup(hostname, { family: 4 }).then((addresses) => {\n callback(null, options\?.ttl \? addresses : addresses.map(mapResolveX));\n }, (error) => {\n callback(error);\n });\n }\n resolve6(hostname, options, callback) {\n if (typeof options == \"function\")\n callback = options, options = null;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.lookup(hostname, { family: 6 }).then((addresses) => {\n callback(null, options\?.ttl \? addresses : addresses.map(({ address }) => address));\n }, (error) => {\n callback(error);\n });\n }\n resolveAny(hostname, callback) {\n callback(null, []);\n }\n resolveCname(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCname(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveMx(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveMx(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveNaptr(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNaptr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveNs(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNs(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolvePtr(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolvePtr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveSrv(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSrv(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveCaa(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCaa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveTxt(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveTxt(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveSoa(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSoa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n reverse(ip, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.reverse(ip, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n setServers(servers) {\n }\n};\nResolver.prototype = {};\nObject.setPrototypeOf(Resolver.prototype, InternalResolver.prototype);\nObject.setPrototypeOf(Resolver, InternalResolver);\nvar {\n resolve,\n resolve4,\n resolve6,\n resolveAny,\n resolveCname,\n resolveCaa,\n resolveMx,\n resolveNaptr,\n resolveNs,\n resolvePtr,\n resolveSoa,\n resolveSrv,\n reverse,\n resolveTxt\n} = InternalResolver.prototype, promisifyLookup = (res) => {\n res.sort((a, b) => a.family - b.family);\n const [{ address, family }] = res;\n return { address, family };\n}, mapLookupAll = (res) => {\n const { address, family } = res;\n return { address, family };\n}, promisifyLookupAll = (res) => {\n return res.sort((a, b) => a.family - b.family), res.map(mapLookupAll);\n}, mapResolveX = (a) => a.address, promisifyResolveX = (res) => {\n return res\?.map(mapResolveX);\n}, promises = {\n lookup(domain, options) {\n if (options\?.all)\n return dns.lookup(domain, options).then(promisifyLookupAll);\n return dns.lookup(domain, options).then(promisifyLookup);\n },\n lookupService(address, port) {\n return dns.lookupService(address, port);\n },\n resolve(hostname, rrtype) {\n if (typeof rrtype !== \"string\")\n rrtype = null;\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n return dns.resolve(hostname, rrtype).then(promisifyLookup);\n default:\n return dns.resolve(hostname, rrtype);\n }\n },\n resolve4(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 4 });\n return dns.lookup(hostname, { family: 4 }).then(promisifyResolveX);\n },\n resolve6(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 6 });\n return dns.lookup(hostname, { family: 6 }).then(promisifyResolveX);\n },\n resolveSrv(hostname) {\n return dns.resolveSrv(hostname);\n },\n resolveTxt(hostname) {\n return dns.resolveTxt(hostname);\n },\n resolveSoa(hostname) {\n return dns.resolveSoa(hostname);\n },\n resolveNaptr(hostname) {\n return dns.resolveNaptr(hostname);\n },\n resolveMx(hostname) {\n return dns.resolveMx(hostname);\n },\n resolveCaa(hostname) {\n return dns.resolveCaa(hostname);\n },\n resolveNs(hostname) {\n return dns.resolveNs(hostname);\n },\n resolvePtr(hostname) {\n return dns.resolvePtr(hostname);\n },\n resolveCname(hostname) {\n return dns.resolveCname(hostname);\n },\n reverse(ip) {\n return dns.reverse(ip);\n },\n Resolver: class Resolver3 {\n constructor(options) {\n }\n cancel() {\n }\n getServers() {\n return [];\n }\n resolve(hostname, rrtype) {\n if (typeof rrtype !== \"string\")\n rrtype = null;\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n return dns.resolve(hostname, rrtype).then(promisifyLookup);\n default:\n return dns.resolve(hostname, rrtype);\n }\n }\n resolve4(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 4 });\n return dns.lookup(hostname, { family: 4 }).then(promisifyResolveX);\n }\n resolve6(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 6 });\n return dns.lookup(hostname, { family: 6 }).then(promisifyResolveX);\n }\n resolveAny(hostname) {\n return @Promise.resolve([]);\n }\n resolveCname(hostname) {\n return dns.resolveCname(hostname);\n }\n resolveMx(hostname) {\n return dns.resolveMx(hostname);\n }\n resolveNaptr(hostname) {\n return dns.resolveNaptr(hostname);\n }\n resolveNs(hostname) {\n return dns.resolveNs(hostname);\n }\n resolvePtr(hostname) {\n return dns.resolvePtr(hostname);\n }\n resolveSoa(hostname) {\n return dns.resolveSoa(hostname);\n }\n resolveSrv(hostname) {\n return dns.resolveSrv(hostname);\n }\n resolveCaa(hostname) {\n return dns.resolveCaa(hostname);\n }\n resolveTxt(hostname) {\n return dns.resolveTxt(hostname);\n }\n reverse(ip) {\n return dns.reverse(ip);\n }\n setServers(servers) {\n }\n }\n};\nfor (let key of [\"resolveAny\"])\n promises[key] = () => @Promise.resolve(@undefined);\n$ = {\n ADDRCONFIG: 0,\n ALL: 1,\n V4MAPPED: 2,\n NODATA: \"DNS_ENODATA\",\n FORMERR: \"DNS_EFORMERR\",\n SERVFAIL: \"DNS_ESERVFAIL\",\n NOTFOUND: \"DNS_ENOTFOUND\",\n NOTIMP: \"DNS_ENOTIMP\",\n REFUSED: \"DNS_EREFUSED\",\n BADQUERY: \"DNS_EBADQUERY\",\n BADNAME: \"DNS_EBADNAME\",\n BADFAMILY: \"DNS_EBADFAMILY\",\n BADRESP: \"DNS_EBADRESP\",\n CONNREFUSED: \"DNS_ECONNREFUSED\",\n TIMEOUT: \"DNS_ETIMEOUT\",\n EOF: \"DNS_EEOF\",\n FILE: \"DNS_EFILE\",\n NOMEM: \"DNS_ENOMEM\",\n DESTRUCTION: \"DNS_EDESTRUCTION\",\n BADSTR: \"DNS_EBADSTR\",\n BADFLAGS: \"DNS_EBADFLAGS\",\n NONAME: \"DNS_ENONAME\",\n BADHINTS: \"DNS_EBADHINTS\",\n NOTINITIALIZED: \"DNS_ENOTINITIALIZED\",\n LOADIPHLPAPI: \"DNS_ELOADIPHLPAPI\",\n ADDRGETNETWORKPARAMS: \"DNS_EADDRGETNETWORKPARAMS\",\n CANCELLED: \"DNS_ECANCELLED\",\n lookup,\n lookupService,\n Resolver,\n setServers,\n setDefaultResultOrder,\n resolve,\n reverse,\n resolve4,\n resolve6,\n resolveAny,\n resolveCname,\n resolveCaa,\n resolveMx,\n resolveNs,\n resolvePtr,\n resolveSoa,\n resolveSrv,\n resolveTxt,\n resolveNaptr,\n promises,\n getServers\n};\nreturn $})\n"_s;
//
//
@@ -549,7 +549,7 @@ static constexpr ASCIILiteral NodeDiagnosticsChannelCode = "(function (){\"use s
//
//
-static constexpr ASCIILiteral NodeDNSCode = "(function (){\"use strict\";// src/js/out/tmp/node/dns.ts\nvar getServers = function() {\n return dns.getServers();\n}, lookup = function(domain, options, callback) {\n if (typeof options == \"function\")\n callback = options;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n if (typeof options == \"number\")\n options = { family: options };\n dns.lookup(domain, options).then((res) => {\n if (res.sort((a, b) => a.family - b.family), options\?.all)\n callback(null, res.map(mapLookupAll));\n else {\n const [{ address, family }] = res;\n callback(null, address, family);\n }\n }, (error) => {\n callback(error);\n });\n}, resolveSrv = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSrv(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveTxt = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveTxt(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveSoa = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSoa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveNaptr = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNaptr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveMx = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveMx(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveCaa = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCaa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveNs = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNs(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolvePtr = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolvePtr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveCname = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCname(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, lookupService = function(address, port, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n callback(null, address, port);\n}, reverse = function(ip, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.reverse(ip, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolve = function(hostname, rrtype, callback) {\n if (typeof rrtype == \"function\")\n callback = rrtype;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolve(hostname).then((results) => {\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n callback(null, hostname, results.map(({ address }) => address));\n break;\n default:\n callback(null, results);\n break;\n }\n }, (error) => {\n callback(error);\n });\n}, Resolver = function(options) {\n return new InternalResolver(options);\n}, setDefaultResultOrder = function() {\n}, setServers = function() {\n}, $, dns = Bun.dns, InternalResolver = class Resolver2 {\n constructor(options) {\n }\n cancel() {\n }\n getServers() {\n return [];\n }\n resolve(hostname, rrtype, callback) {\n if (typeof rrtype == \"function\")\n callback = rrtype, rrtype = null;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolve(hostname).then((results) => {\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n callback(null, hostname, results.map(mapResolveX));\n break;\n default:\n callback(null, results);\n break;\n }\n }, (error) => {\n callback(error);\n });\n }\n resolve4(hostname, options, callback) {\n if (typeof options == \"function\")\n callback = options, options = null;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.lookup(hostname, { family: 4 }).then((addresses) => {\n callback(null, options\?.ttl \? addresses : addresses.map(mapResolveX));\n }, (error) => {\n callback(error);\n });\n }\n resolve6(hostname, options, callback) {\n if (typeof options == \"function\")\n callback = options, options = null;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.lookup(hostname, { family: 6 }).then((addresses) => {\n callback(null, options\?.ttl \? addresses : addresses.map(({ address }) => address));\n }, (error) => {\n callback(error);\n });\n }\n resolveAny(hostname, callback) {\n callback(null, []);\n }\n resolveCname(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCname(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveMx(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveMx(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveNaptr(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNaptr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveNs(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNs(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolvePtr(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolvePtr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveSrv(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSrv(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveCaa(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCaa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveTxt(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveTxt(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveSoa(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSoa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n reverse(ip, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.reverse(ip, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n setServers(servers) {\n }\n};\nResolver.prototype = {};\nObject.setPrototypeOf(Resolver.prototype, InternalResolver.prototype);\nObject.setPrototypeOf(Resolver, InternalResolver);\nvar {\n resolve,\n resolve4,\n resolve6,\n resolveAny,\n resolveCname,\n resolveCaa,\n resolveMx,\n resolveNaptr,\n resolveNs,\n resolvePtr,\n resolveSoa,\n resolveSrv,\n reverse,\n resolveTxt\n} = InternalResolver.prototype, promisifyLookup = (res) => {\n res.sort((a, b) => a.family - b.family);\n const [{ address, family }] = res;\n return { address, family };\n}, mapLookupAll = (res) => {\n const { address, family } = res;\n return { address, family };\n}, promisifyLookupAll = (res) => {\n return res.sort((a, b) => a.family - b.family), res.map(mapLookupAll);\n}, mapResolveX = (a) => a.address, promisifyResolveX = (res) => {\n return res\?.map(mapResolveX);\n}, promises = {\n lookup(domain, options) {\n if (options\?.all)\n return dns.lookup(domain, options).then(promisifyLookupAll);\n return dns.lookup(domain, options).then(promisifyLookup);\n },\n lookupService(address, port) {\n return @Promise.resolve([]);\n },\n resolve(hostname, rrtype) {\n if (typeof rrtype !== \"string\")\n rrtype = null;\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n return dns.resolve(hostname, rrtype).then(promisifyLookup);\n default:\n return dns.resolve(hostname, rrtype);\n }\n },\n resolve4(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 4 });\n return dns.lookup(hostname, { family: 4 }).then(promisifyResolveX);\n },\n resolve6(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 6 });\n return dns.lookup(hostname, { family: 6 }).then(promisifyResolveX);\n },\n resolveSrv(hostname) {\n return dns.resolveSrv(hostname);\n },\n resolveTxt(hostname) {\n return dns.resolveTxt(hostname);\n },\n resolveSoa(hostname) {\n return dns.resolveSoa(hostname);\n },\n resolveNaptr(hostname) {\n return dns.resolveNaptr(hostname);\n },\n resolveMx(hostname) {\n return dns.resolveMx(hostname);\n },\n resolveCaa(hostname) {\n return dns.resolveCaa(hostname);\n },\n resolveNs(hostname) {\n return dns.resolveNs(hostname);\n },\n resolvePtr(hostname) {\n return dns.resolvePtr(hostname);\n },\n resolveCname(hostname) {\n return dns.resolveCname(hostname);\n },\n reverse(ip) {\n return dns.reverse(ip);\n },\n Resolver: class Resolver3 {\n constructor(options) {\n }\n cancel() {\n }\n getServers() {\n return [];\n }\n resolve(hostname, rrtype) {\n if (typeof rrtype !== \"string\")\n rrtype = null;\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n return dns.resolve(hostname, rrtype).then(promisifyLookup);\n default:\n return dns.resolve(hostname, rrtype);\n }\n }\n resolve4(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 4 });\n return dns.lookup(hostname, { family: 4 }).then(promisifyResolveX);\n }\n resolve6(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 6 });\n return dns.lookup(hostname, { family: 6 }).then(promisifyResolveX);\n }\n resolveAny(hostname) {\n return @Promise.resolve([]);\n }\n resolveCname(hostname) {\n return dns.resolveCname(hostname);\n }\n resolveMx(hostname) {\n return dns.resolveMx(hostname);\n }\n resolveNaptr(hostname) {\n return dns.resolveNaptr(hostname);\n }\n resolveNs(hostname) {\n return dns.resolveNs(hostname);\n }\n resolvePtr(hostname) {\n return dns.resolvePtr(hostname);\n }\n resolveSoa(hostname) {\n return dns.resolveSoa(hostname);\n }\n resolveSrv(hostname) {\n return dns.resolveSrv(hostname);\n }\n resolveCaa(hostname) {\n return dns.resolveCaa(hostname);\n }\n resolveTxt(hostname) {\n return dns.resolveTxt(hostname);\n }\n reverse(ip) {\n return dns.reverse(ip);\n }\n setServers(servers) {\n }\n }\n};\nfor (let key of [\"resolveAny\"])\n promises[key] = () => @Promise.resolve(@undefined);\n$ = {\n ADDRCONFIG: 0,\n ALL: 1,\n V4MAPPED: 2,\n NODATA: \"DNS_ENODATA\",\n FORMERR: \"DNS_EFORMERR\",\n SERVFAIL: \"DNS_ESERVFAIL\",\n NOTFOUND: \"DNS_ENOTFOUND\",\n NOTIMP: \"DNS_ENOTIMP\",\n REFUSED: \"DNS_EREFUSED\",\n BADQUERY: \"DNS_EBADQUERY\",\n BADNAME: \"DNS_EBADNAME\",\n BADFAMILY: \"DNS_EBADFAMILY\",\n BADRESP: \"DNS_EBADRESP\",\n CONNREFUSED: \"DNS_ECONNREFUSED\",\n TIMEOUT: \"DNS_ETIMEOUT\",\n EOF: \"DNS_EEOF\",\n FILE: \"DNS_EFILE\",\n NOMEM: \"DNS_ENOMEM\",\n DESTRUCTION: \"DNS_EDESTRUCTION\",\n BADSTR: \"DNS_EBADSTR\",\n BADFLAGS: \"DNS_EBADFLAGS\",\n NONAME: \"DNS_ENONAME\",\n BADHINTS: \"DNS_EBADHINTS\",\n NOTINITIALIZED: \"DNS_ENOTINITIALIZED\",\n LOADIPHLPAPI: \"DNS_ELOADIPHLPAPI\",\n ADDRGETNETWORKPARAMS: \"DNS_EADDRGETNETWORKPARAMS\",\n CANCELLED: \"DNS_ECANCELLED\",\n lookup,\n lookupService,\n Resolver,\n setServers,\n setDefaultResultOrder,\n resolve,\n reverse,\n resolve4,\n resolve6,\n resolveAny,\n resolveCname,\n resolveCaa,\n resolveMx,\n resolveNs,\n resolvePtr,\n resolveSoa,\n resolveSrv,\n resolveTxt,\n resolveNaptr,\n promises,\n getServers\n};\nreturn $})\n"_s;
+static constexpr ASCIILiteral NodeDNSCode = "(function (){\"use strict\";// src/js/out/tmp/node/dns.ts\nvar getServers = function() {\n return dns.getServers();\n}, lookup = function(domain, options, callback) {\n if (typeof options == \"function\")\n callback = options;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n if (typeof options == \"number\")\n options = { family: options };\n dns.lookup(domain, options).then((res) => {\n if (res.sort((a, b) => a.family - b.family), options\?.all)\n callback(null, res.map(mapLookupAll));\n else {\n const [{ address, family }] = res;\n callback(null, address, family);\n }\n }, (error) => {\n callback(error);\n });\n}, resolveSrv = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSrv(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveTxt = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveTxt(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveSoa = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSoa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveNaptr = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNaptr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveMx = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveMx(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveCaa = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCaa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveNs = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNs(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolvePtr = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolvePtr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolveCname = function(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCname(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, lookupService = function(address, port, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.lookupService(address, port, callback).then((results) => {\n callback(null, ...results);\n }, (error) => {\n callback(error);\n });\n}, reverse = function(ip, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.reverse(ip, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n}, resolve = function(hostname, rrtype, callback) {\n if (typeof rrtype == \"function\")\n callback = rrtype;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolve(hostname).then((results) => {\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n callback(null, hostname, results.map(({ address }) => address));\n break;\n default:\n callback(null, results);\n break;\n }\n }, (error) => {\n callback(error);\n });\n}, Resolver = function(options) {\n return new InternalResolver(options);\n}, setDefaultResultOrder = function() {\n}, setServers = function() {\n}, $, dns = Bun.dns, InternalResolver = class Resolver2 {\n constructor(options) {\n }\n cancel() {\n }\n getServers() {\n return [];\n }\n resolve(hostname, rrtype, callback) {\n if (typeof rrtype == \"function\")\n callback = rrtype, rrtype = null;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolve(hostname).then((results) => {\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n callback(null, hostname, results.map(mapResolveX));\n break;\n default:\n callback(null, results);\n break;\n }\n }, (error) => {\n callback(error);\n });\n }\n resolve4(hostname, options, callback) {\n if (typeof options == \"function\")\n callback = options, options = null;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.lookup(hostname, { family: 4 }).then((addresses) => {\n callback(null, options\?.ttl \? addresses : addresses.map(mapResolveX));\n }, (error) => {\n callback(error);\n });\n }\n resolve6(hostname, options, callback) {\n if (typeof options == \"function\")\n callback = options, options = null;\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.lookup(hostname, { family: 6 }).then((addresses) => {\n callback(null, options\?.ttl \? addresses : addresses.map(({ address }) => address));\n }, (error) => {\n callback(error);\n });\n }\n resolveAny(hostname, callback) {\n callback(null, []);\n }\n resolveCname(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCname(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveMx(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveMx(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveNaptr(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNaptr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveNs(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveNs(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolvePtr(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolvePtr(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveSrv(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSrv(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveCaa(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveCaa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveTxt(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveTxt(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n resolveSoa(hostname, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.resolveSoa(hostname, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n reverse(ip, callback) {\n if (typeof callback != \"function\")\n @throwTypeError(\"callback must be a function\");\n dns.reverse(ip, callback).then((results) => {\n callback(null, results);\n }, (error) => {\n callback(error);\n });\n }\n setServers(servers) {\n }\n};\nResolver.prototype = {};\nObject.setPrototypeOf(Resolver.prototype, InternalResolver.prototype);\nObject.setPrototypeOf(Resolver, InternalResolver);\nvar {\n resolve,\n resolve4,\n resolve6,\n resolveAny,\n resolveCname,\n resolveCaa,\n resolveMx,\n resolveNaptr,\n resolveNs,\n resolvePtr,\n resolveSoa,\n resolveSrv,\n reverse,\n resolveTxt\n} = InternalResolver.prototype, promisifyLookup = (res) => {\n res.sort((a, b) => a.family - b.family);\n const [{ address, family }] = res;\n return { address, family };\n}, mapLookupAll = (res) => {\n const { address, family } = res;\n return { address, family };\n}, promisifyLookupAll = (res) => {\n return res.sort((a, b) => a.family - b.family), res.map(mapLookupAll);\n}, mapResolveX = (a) => a.address, promisifyResolveX = (res) => {\n return res\?.map(mapResolveX);\n}, promises = {\n lookup(domain, options) {\n if (options\?.all)\n return dns.lookup(domain, options).then(promisifyLookupAll);\n return dns.lookup(domain, options).then(promisifyLookup);\n },\n lookupService(address, port) {\n return dns.lookupService(address, port);\n },\n resolve(hostname, rrtype) {\n if (typeof rrtype !== \"string\")\n rrtype = null;\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n return dns.resolve(hostname, rrtype).then(promisifyLookup);\n default:\n return dns.resolve(hostname, rrtype);\n }\n },\n resolve4(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 4 });\n return dns.lookup(hostname, { family: 4 }).then(promisifyResolveX);\n },\n resolve6(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 6 });\n return dns.lookup(hostname, { family: 6 }).then(promisifyResolveX);\n },\n resolveSrv(hostname) {\n return dns.resolveSrv(hostname);\n },\n resolveTxt(hostname) {\n return dns.resolveTxt(hostname);\n },\n resolveSoa(hostname) {\n return dns.resolveSoa(hostname);\n },\n resolveNaptr(hostname) {\n return dns.resolveNaptr(hostname);\n },\n resolveMx(hostname) {\n return dns.resolveMx(hostname);\n },\n resolveCaa(hostname) {\n return dns.resolveCaa(hostname);\n },\n resolveNs(hostname) {\n return dns.resolveNs(hostname);\n },\n resolvePtr(hostname) {\n return dns.resolvePtr(hostname);\n },\n resolveCname(hostname) {\n return dns.resolveCname(hostname);\n },\n reverse(ip) {\n return dns.reverse(ip);\n },\n Resolver: class Resolver3 {\n constructor(options) {\n }\n cancel() {\n }\n getServers() {\n return [];\n }\n resolve(hostname, rrtype) {\n if (typeof rrtype !== \"string\")\n rrtype = null;\n switch (rrtype\?.toLowerCase()) {\n case \"a\":\n case \"aaaa\":\n return dns.resolve(hostname, rrtype).then(promisifyLookup);\n default:\n return dns.resolve(hostname, rrtype);\n }\n }\n resolve4(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 4 });\n return dns.lookup(hostname, { family: 4 }).then(promisifyResolveX);\n }\n resolve6(hostname, options) {\n if (options\?.ttl)\n return dns.lookup(hostname, { family: 6 });\n return dns.lookup(hostname, { family: 6 }).then(promisifyResolveX);\n }\n resolveAny(hostname) {\n return @Promise.resolve([]);\n }\n resolveCname(hostname) {\n return dns.resolveCname(hostname);\n }\n resolveMx(hostname) {\n return dns.resolveMx(hostname);\n }\n resolveNaptr(hostname) {\n return dns.resolveNaptr(hostname);\n }\n resolveNs(hostname) {\n return dns.resolveNs(hostname);\n }\n resolvePtr(hostname) {\n return dns.resolvePtr(hostname);\n }\n resolveSoa(hostname) {\n return dns.resolveSoa(hostname);\n }\n resolveSrv(hostname) {\n return dns.resolveSrv(hostname);\n }\n resolveCaa(hostname) {\n return dns.resolveCaa(hostname);\n }\n resolveTxt(hostname) {\n return dns.resolveTxt(hostname);\n }\n reverse(ip) {\n return dns.reverse(ip);\n }\n setServers(servers) {\n }\n }\n};\nfor (let key of [\"resolveAny\"])\n promises[key] = () => @Promise.resolve(@undefined);\n$ = {\n ADDRCONFIG: 0,\n ALL: 1,\n V4MAPPED: 2,\n NODATA: \"DNS_ENODATA\",\n FORMERR: \"DNS_EFORMERR\",\n SERVFAIL: \"DNS_ESERVFAIL\",\n NOTFOUND: \"DNS_ENOTFOUND\",\n NOTIMP: \"DNS_ENOTIMP\",\n REFUSED: \"DNS_EREFUSED\",\n BADQUERY: \"DNS_EBADQUERY\",\n BADNAME: \"DNS_EBADNAME\",\n BADFAMILY: \"DNS_EBADFAMILY\",\n BADRESP: \"DNS_EBADRESP\",\n CONNREFUSED: \"DNS_ECONNREFUSED\",\n TIMEOUT: \"DNS_ETIMEOUT\",\n EOF: \"DNS_EEOF\",\n FILE: \"DNS_EFILE\",\n NOMEM: \"DNS_ENOMEM\",\n DESTRUCTION: \"DNS_EDESTRUCTION\",\n BADSTR: \"DNS_EBADSTR\",\n BADFLAGS: \"DNS_EBADFLAGS\",\n NONAME: \"DNS_ENONAME\",\n BADHINTS: \"DNS_EBADHINTS\",\n NOTINITIALIZED: \"DNS_ENOTINITIALIZED\",\n LOADIPHLPAPI: \"DNS_ELOADIPHLPAPI\",\n ADDRGETNETWORKPARAMS: \"DNS_EADDRGETNETWORKPARAMS\",\n CANCELLED: \"DNS_ECANCELLED\",\n lookup,\n lookupService,\n Resolver,\n setServers,\n setDefaultResultOrder,\n resolve,\n reverse,\n resolve4,\n resolve6,\n resolveAny,\n resolveCname,\n resolveCaa,\n resolveMx,\n resolveNs,\n resolvePtr,\n resolveSoa,\n resolveSrv,\n resolveTxt,\n resolveNaptr,\n promises,\n getServers\n};\nreturn $})\n"_s;
//
//
diff --git a/test/js/node/dns/node-dns.test.js b/test/js/node/dns/node-dns.test.js
index e6f28da49..d549017b2 100644
--- a/test/js/node/dns/node-dns.test.js
+++ b/test/js/node/dns/node-dns.test.js
@@ -327,4 +327,70 @@ describe("test invalid arguments", () => {
}
});
});
+
+ it("dns.lookupService", async () => {
+ expect(() => {
+ dns.lookupService("", 443, (err, hostname, service) => {});
+ }).toThrow("Expected address to be a non-empty string for 'lookupService'.");
+ expect(() => {
+ dns.lookupService("google.com", 443, (err, hostname, service) => {});
+ }).toThrow("Expected address to be a invalid address for 'lookupService'.");
+ });
+});
+
+describe("dns.lookupService", () => {
+ it.each([
+ ["1.1.1.1", 53, ["one.one.one.one", "domain"]],
+ ["2606:4700:4700::1111", 53, ["one.one.one.one", "domain"]],
+ ["2606:4700:4700::1001", 53, ["one.one.one.one", "domain"]],
+ ["1.1.1.1", 80, ["one.one.one.one", "http"]],
+ ["1.1.1.1", 443, ["one.one.one.one", "https"]],
+ ])("lookupService(%s, %d)", (address, port, expected, done) => {
+ dns.lookupService(address, port, (err, hostname, service) => {
+ try {
+ expect(err).toBeNull();
+ expect(hostname).toStrictEqual(expected[0]);
+ expect(service).toStrictEqual(expected[1]);
+ done();
+ } catch (err) {
+ done(err);
+ }
+ });
+ });
+
+ it("lookupService(255.255.255.255, 443)", done => {
+ dns.lookupService("255.255.255.255", 443, (err, hostname, service) => {
+ if (process.platform == "darwin") {
+ try {
+ expect(err).toBeNull();
+ expect(hostname).toStrictEqual("broadcasthost");
+ expect(service).toStrictEqual("https");
+ done();
+ } catch (err) {
+ done(err);
+ }
+ } else {
+ try {
+ expect(err).not.toBeNull();
+ expect(hostname).toBeUndefined();
+ expect(service).toBeUndefined();
+ done();
+ } catch (err) {
+ done(err);
+ }
+ }
+ });
+ });
+
+ it.each([
+ ["1.1.1.1", 53, ["one.one.one.one", "domain"]],
+ ["2606:4700:4700::1111", 53, ["one.one.one.one", "domain"]],
+ ["2606:4700:4700::1001", 53, ["one.one.one.one", "domain"]],
+ ["1.1.1.1", 80, ["one.one.one.one", "http"]],
+ ["1.1.1.1", 443, ["one.one.one.one", "https"]],
+ ])("promises.lookupService(%s, %d)", async (address, port, expected) => {
+ const [hostname, service] = await dns.promises.lookupService(address, port);
+ expect(hostname).toStrictEqual(expected[0]);
+ expect(service).toStrictEqual(expected[1]);
+ });
});