diff options
author | 2023-08-06 21:16:54 +0800 | |
---|---|---|
committer | 2023-08-06 06:16:54 -0700 | |
commit | ecdf2ffa6c615d8a431c2919c0b9bdc4cbe2c4f0 (patch) | |
tree | a9bb787b1efc382ed37e8fe99cdda8cdb0f7fe92 | |
parent | cd0774cd89f44ae3880ae5d3840787012d9df603 (diff) | |
download | bun-ecdf2ffa6c615d8a431c2919c0b9bdc4cbe2c4f0.tar.gz bun-ecdf2ffa6c615d8a431c2919c0b9bdc4cbe2c4f0.tar.zst bun-ecdf2ffa6c615d8a431c2919c0b9bdc4cbe2c4f0.zip |
feat: impl `dns.getServers` (#3982)
* feat: impl `dns.getServers`
Close: #3981
* check return value of `ares_inet_ntop`
-rw-r--r-- | src/bun.js/api/bun/dns_resolver.zig | 91 | ||||
-rw-r--r-- | src/bun.js/bindings/ZigGlobalObject.cpp | 3 | ||||
-rw-r--r-- | src/js/node/dns.js | 5 | ||||
-rw-r--r-- | src/js/out/InternalModuleRegistryConstants.h | 6 | ||||
-rw-r--r-- | test/js/node/dns/node-dns.test.js | 33 |
5 files changed, 135 insertions, 3 deletions
diff --git a/src/bun.js/api/bun/dns_resolver.zig b/src/bun.js/api/bun/dns_resolver.zig index 4d961b54c..ed76dc777 100644 --- a/src/bun.js/api/bun/dns_resolver.zig +++ b/src/bun.js/api/bun/dns_resolver.zig @@ -16,6 +16,8 @@ const JSGlobalObject = JSC.JSGlobalObject; const c_ares = bun.c_ares; const GetAddrInfoAsyncCallback = fn (i32, ?*std.c.addrinfo, ?*anyopaque) callconv(.C) void; +const INET6_ADDRSTRLEN = if (bun.Environment.isWindows) 65 else 46; +const IANA_DNS_PORT = 53; const LibInfo = struct { // static int32_t (*getaddrinfo_async_start)(mach_port_t*, @@ -2015,6 +2017,89 @@ pub const DNSResolver = struct { return promise; } + pub fn getServers(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue { + _ = callframe; + + 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; + }, + }; + + var servers: [*c]c_ares.struct_ares_addr_port_node = undefined; + const r = c_ares.ares_get_servers_ports(channel, &servers); + if (r != c_ares.ARES_SUCCESS) { + const err = c_ares.Error.get(r).?; + globalThis.throwValue(globalThis.createErrorInstance("ares_get_servers_ports error: {s}", .{err.label()})); + return .zero; + } + defer c_ares.ares_free_data(servers); + + const values = JSC.JSValue.createEmptyArray(globalThis, 0); + + var i: u32 = 0; + var cur = servers; + while (cur != null) : ({ + i += 1; + cur = cur.*.next; + }) { + // Formatting reference: https://nodejs.org/api/dns.html#dnsgetservers + // Brackets '[' and ']' consume 2 bytes, used for IPv6 format (e.g., '[2001:4860:4860::8888]:1053'). + // Port range is 6 bytes (e.g., ':65535'). + // Null terminator '\0' uses 1 byte. + var buf: [INET6_ADDRSTRLEN + 2 + 6 + 1]u8 = undefined; + const family = cur.*.family; + + const ip = if (family == std.os.AF.INET6) blk: { + break :blk c_ares.ares_inet_ntop(family, &cur.*.addr.addr6, buf[1..], @sizeOf(@TypeOf(buf)) - 1); + } else blk: { + break :blk c_ares.ares_inet_ntop(family, &cur.*.addr.addr4, buf[1..], @sizeOf(@TypeOf(buf)) - 1); + }; + if (ip == null) { + globalThis.throwValue(globalThis.createErrorInstance( + "ares_inet_ntop error: no more space to convert a network format address", + .{}, + )); + return .zero; + } + + var port = cur.*.tcp_port; + if (port == 0) { + port = cur.*.udp_port; + } + if (port == 0) { + port = IANA_DNS_PORT; + } + + const size = bun.len(bun.cast([*:0]u8, &buf)); + if (port == IANA_DNS_PORT) { + values.putIndex(globalThis, i, JSC.ZigString.init(buf[1..size]).withEncoding().toValueGC(globalThis)); + } else { + if (family == std.os.AF.INET6) { + buf[0] = '['; + buf[size] = ']'; + const port_slice = std.fmt.bufPrint(buf[size + 1 ..], ":{d}", .{port}) catch unreachable; + values.putIndex(globalThis, i, JSC.ZigString.init(buf[0 .. size + 1 + port_slice.len]).withEncoding().toValueGC(globalThis)); + } else { + const port_slice = std.fmt.bufPrint(buf[size..], ":{d}", .{port}) catch unreachable; + values.putIndex(globalThis, i, JSC.ZigString.init(buf[1 .. size + port_slice.len]).withEncoding().toValueGC(globalThis)); + } + } + } + + return values; + } + comptime { @export( resolve, @@ -2082,6 +2167,12 @@ pub const DNSResolver = struct { .name = "Bun__DNSResolver__resolveCname", }, ); + @export( + getServers, + .{ + .name = "Bun__DNSResolver__getServers", + }, + ); } // pub fn lookupService(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue { // const arguments = callframe.arguments(3); diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index d2e3416fc..3dec4ff68 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -2860,6 +2860,7 @@ extern "C" EncodedJSValue Bun__DNSResolver__resolveCaa(JSGlobalObject*, JSC::Cal extern "C" EncodedJSValue Bun__DNSResolver__resolveNs(JSGlobalObject*, JSC::CallFrame*); extern "C" EncodedJSValue Bun__DNSResolver__resolvePtr(JSGlobalObject*, JSC::CallFrame*); extern "C" EncodedJSValue Bun__DNSResolver__resolveCname(JSGlobalObject*, JSC::CallFrame*); +extern "C" EncodedJSValue Bun__DNSResolver__getServers(JSGlobalObject*, JSC::CallFrame*); JSC_DEFINE_HOST_FUNCTION(jsFunctionPerformMicrotaskVariadic, (JSGlobalObject * globalObject, CallFrame* callframe)) { @@ -3251,6 +3252,8 @@ void GlobalObject::finishCreation(VM& vm) JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveCname"_s), 2, Bun__DNSResolver__resolveCname, ImplementationVisibility::Public, NoIntrinsic, JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); + dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "getServers"_s), 2, Bun__DNSResolver__getServers, ImplementationVisibility::Public, NoIntrinsic, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); init.set(dnsObject); }); diff --git a/src/js/node/dns.js b/src/js/node/dns.js index ef28b0e3b..f8e5366f9 100644 --- a/src/js/node/dns.js +++ b/src/js/node/dns.js @@ -2,6 +2,10 @@ // only resolve4, resolve, lookup, resolve6 and resolveSrv are implemented. const dns = Bun.dns; +function getServers() { + return dns.getServers(); +} + function lookup(domain, options, callback) { if (typeof options == "function") { callback = options; @@ -685,4 +689,5 @@ export default { resolveTxt, resolveNaptr, promises, + getServers, }; diff --git a/src/js/out/InternalModuleRegistryConstants.h b/src/js/out/InternalModuleRegistryConstants.h index 02c00f62c..5cd010c12 100644 --- a/src/js/out/InternalModuleRegistryConstants.h +++ b/src/js/out/InternalModuleRegistryConstants.h @@ -53,7 +53,7 @@ static constexpr ASCIILiteral NodeDiagnosticsChannelCode = "(function (){\"use s // // -static constexpr ASCIILiteral NodeDNSCode = "(function (){\"use strict\";const dns=Bun.dns;function lookup(domain,options,callback){if(typeof options==\"function\")callback=options;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");if(typeof options==\"number\")options={family:options};dns.lookup(domain,options).then((res)=>{if(res.sort((a,b)=>a.family-b.family),options\?.all)callback(null,res.map(mapLookupAll));else{const[{address,family}]=res;callback(null,address,family)}},(error)=>{callback(error)})}function resolveSrv(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSrv(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveTxt(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveTxt(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveSoa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSoa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveNaptr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNaptr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveMx(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveMx(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveCaa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCaa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveNs(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNs(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolvePtr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolvePtr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveCname(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCname(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function lookupService(address,port,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");callback(null,address,port)}var InternalResolver=class Resolver2{constructor(options){}cancel(){}getServers(){return[]}resolve(hostname,rrtype,callback){if(typeof rrtype==\"function\")callback=rrtype,rrtype=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolve(hostname).then((results)=>{switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":callback(null,hostname,results.map(mapResolveX));break;default:callback(null,results);break}},(error)=>{callback(error)})}resolve4(hostname,options,callback){if(typeof options==\"function\")callback=options,options=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.lookup(hostname,{family:4}).then((addresses)=>{callback(null,options\?.ttl\?addresses:addresses.map(mapResolveX))},(error)=>{callback(error)})}resolve6(hostname,options,callback){if(typeof options==\"function\")callback=options,options=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.lookup(hostname,{family:6}).then((addresses)=>{callback(null,options\?.ttl\?addresses:addresses.map(({address})=>address))},(error)=>{callback(error)})}resolveAny(hostname,callback){callback(null,[])}resolveCname(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCname(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveMx(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveMx(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveNaptr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNaptr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveNs(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNs(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolvePtr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolvePtr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveSrv(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSrv(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveCaa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCaa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveTxt(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveTxt(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveSoa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSoa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}reverse(ip,callback){callback(null,[])}setServers(servers){}};function resolve(hostname,rrtype,callback){if(typeof rrtype==\"function\")callback=rrtype;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolve(hostname).then((results)=>{switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":callback(null,hostname,results.map(({address})=>address));break;default:callback(null,results);break}},(error)=>{callback(error)})}function Resolver(options){return new InternalResolver(options)}Resolver.prototype={},Object.setPrototypeOf(Resolver.prototype,InternalResolver.prototype),Object.setPrototypeOf(Resolver,InternalResolver);var{resolve,resolve4,resolve6,resolveAny,resolveCname,resolveCaa,resolveMx,resolveNaptr,resolveNs,resolvePtr,resolveSoa,resolveSrv,reverse,resolveTxt}=InternalResolver.prototype;function setDefaultResultOrder(){}function setServers(){}const promisifyLookup=(res)=>{res.sort((a,b)=>a.family-b.family);const[{address,family}]=res;return{address,family}},mapLookupAll=(res)=>{const{address,family}=res;return{address,family}},promisifyLookupAll=(res)=>{return res.sort((a,b)=>a.family-b.family),res.map(mapLookupAll)},mapResolveX=(a)=>a.address,promisifyResolveX=(res)=>{return res\?.map(mapResolveX)},promises={lookup(domain,options){if(options\?.all)return dns.lookup(domain,options).then(promisifyLookupAll);return dns.lookup(domain,options).then(promisifyLookup)},lookupService(address,port){return Promise.resolve([])},resolve(hostname,rrtype){if(typeof rrtype!==\"string\")rrtype=null;switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":return dns.resolve(hostname,rrtype).then(promisifyLookup);default:return dns.resolve(hostname,rrtype)}},resolve4(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:4});return dns.lookup(hostname,{family:4}).then(promisifyResolveX)},resolve6(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:6});return dns.lookup(hostname,{family:6}).then(promisifyResolveX)},resolveSrv(hostname){return dns.resolveSrv(hostname)},resolveTxt(hostname){return dns.resolveTxt(hostname)},resolveSoa(hostname){return dns.resolveSoa(hostname)},resolveNaptr(hostname){return dns.resolveNaptr(hostname)},resolveMx(hostname){return dns.resolveMx(hostname)},resolveCaa(hostname){return dns.resolveCaa(hostname)},resolveNs(hostname){return dns.resolveNs(hostname)},resolvePtr(hostname){return dns.resolvePtr(hostname)},resolveCname(hostname){return dns.resolveCname(hostname)},Resolver:class Resolver2{constructor(options){}cancel(){}getServers(){return[]}resolve(hostname,rrtype){if(typeof rrtype!==\"string\")rrtype=null;switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":return dns.resolve(hostname,rrtype).then(promisifyLookup);default:return dns.resolve(hostname,rrtype)}}resolve4(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:4});return dns.lookup(hostname,{family:4}).then(promisifyResolveX)}resolve6(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:6});return dns.lookup(hostname,{family:6}).then(promisifyResolveX)}resolveAny(hostname){return Promise.resolve([])}resolveCname(hostname){return dns.resolveCname(hostname)}resolveMx(hostname){return dns.resolveMx(hostname)}resolveNaptr(hostname){return dns.resolveNaptr(hostname)}resolveNs(hostname){return dns.resolveNs(hostname)}resolvePtr(hostname){return dns.resolvePtr(hostname)}resolveSoa(hostname){return dns.resolveSoa(hostname)}resolveSrv(hostname){return dns.resolveSrv(hostname)}resolveCaa(hostname){return dns.resolveCaa(hostname)}resolveTxt(hostname){return dns.resolveTxt(hostname)}reverse(ip){return Promise.resolve([])}setServers(servers){}}};for(let key of[\"resolveAny\",\"reverse\"])promises[key]=()=>Promise.resolve(void 0);return{ADDRCONFIG:0,ALL:1,V4MAPPED:2,NODATA:\"DNS_ENODATA\",FORMERR:\"DNS_EFORMERR\",SERVFAIL:\"DNS_ESERVFAIL\",NOTFOUND:\"DNS_ENOTFOUND\",NOTIMP:\"DNS_ENOTIMP\",REFUSED:\"DNS_EREFUSED\",BADQUERY:\"DNS_EBADQUERY\",BADNAME:\"DNS_EBADNAME\",BADFAMILY:\"DNS_EBADFAMILY\",BADRESP:\"DNS_EBADRESP\",CONNREFUSED:\"DNS_ECONNREFUSED\",TIMEOUT:\"DNS_ETIMEOUT\",EOF:\"DNS_EEOF\",FILE:\"DNS_EFILE\",NOMEM:\"DNS_ENOMEM\",DESTRUCTION:\"DNS_EDESTRUCTION\",BADSTR:\"DNS_EBADSTR\",BADFLAGS:\"DNS_EBADFLAGS\",NONAME:\"DNS_ENONAME\",BADHINTS:\"DNS_EBADHINTS\",NOTINITIALIZED:\"DNS_ENOTINITIALIZED\",LOADIPHLPAPI:\"DNS_ELOADIPHLPAPI\",ADDRGETNETWORKPARAMS:\"DNS_EADDRGETNETWORKPARAMS\",CANCELLED:\"DNS_ECANCELLED\",lookup,lookupService,Resolver,setServers,setDefaultResultOrder,resolve,reverse,resolve4,resolve6,resolveAny,resolveCname,resolveCaa,resolveMx,resolveNs,resolvePtr,resolveSoa,resolveSrv,resolveTxt,resolveNaptr,promises}})\n"_s; +static constexpr ASCIILiteral NodeDNSCode = "(function (){\"use strict\";const dns=Bun.dns;function getServers(){return dns.getServers()}function lookup(domain,options,callback){if(typeof options==\"function\")callback=options;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");if(typeof options==\"number\")options={family:options};dns.lookup(domain,options).then((res)=>{if(res.sort((a,b)=>a.family-b.family),options\?.all)callback(null,res.map(mapLookupAll));else{const[{address,family}]=res;callback(null,address,family)}},(error)=>{callback(error)})}function resolveSrv(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSrv(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveTxt(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveTxt(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveSoa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSoa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveNaptr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNaptr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveMx(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveMx(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveCaa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCaa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveNs(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNs(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolvePtr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolvePtr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveCname(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCname(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function lookupService(address,port,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");callback(null,address,port)}var InternalResolver=class Resolver2{constructor(options){}cancel(){}getServers(){return[]}resolve(hostname,rrtype,callback){if(typeof rrtype==\"function\")callback=rrtype,rrtype=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolve(hostname).then((results)=>{switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":callback(null,hostname,results.map(mapResolveX));break;default:callback(null,results);break}},(error)=>{callback(error)})}resolve4(hostname,options,callback){if(typeof options==\"function\")callback=options,options=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.lookup(hostname,{family:4}).then((addresses)=>{callback(null,options\?.ttl\?addresses:addresses.map(mapResolveX))},(error)=>{callback(error)})}resolve6(hostname,options,callback){if(typeof options==\"function\")callback=options,options=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.lookup(hostname,{family:6}).then((addresses)=>{callback(null,options\?.ttl\?addresses:addresses.map(({address})=>address))},(error)=>{callback(error)})}resolveAny(hostname,callback){callback(null,[])}resolveCname(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCname(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveMx(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveMx(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveNaptr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNaptr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveNs(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNs(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolvePtr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolvePtr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveSrv(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSrv(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveCaa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCaa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveTxt(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveTxt(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveSoa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSoa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}reverse(ip,callback){callback(null,[])}setServers(servers){}};function resolve(hostname,rrtype,callback){if(typeof rrtype==\"function\")callback=rrtype;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolve(hostname).then((results)=>{switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":callback(null,hostname,results.map(({address})=>address));break;default:callback(null,results);break}},(error)=>{callback(error)})}function Resolver(options){return new InternalResolver(options)}Resolver.prototype={},Object.setPrototypeOf(Resolver.prototype,InternalResolver.prototype),Object.setPrototypeOf(Resolver,InternalResolver);var{resolve,resolve4,resolve6,resolveAny,resolveCname,resolveCaa,resolveMx,resolveNaptr,resolveNs,resolvePtr,resolveSoa,resolveSrv,reverse,resolveTxt}=InternalResolver.prototype;function setDefaultResultOrder(){}function setServers(){}const promisifyLookup=(res)=>{res.sort((a,b)=>a.family-b.family);const[{address,family}]=res;return{address,family}},mapLookupAll=(res)=>{const{address,family}=res;return{address,family}},promisifyLookupAll=(res)=>{return res.sort((a,b)=>a.family-b.family),res.map(mapLookupAll)},mapResolveX=(a)=>a.address,promisifyResolveX=(res)=>{return res\?.map(mapResolveX)},promises={lookup(domain,options){if(options\?.all)return dns.lookup(domain,options).then(promisifyLookupAll);return dns.lookup(domain,options).then(promisifyLookup)},lookupService(address,port){return Promise.resolve([])},resolve(hostname,rrtype){if(typeof rrtype!==\"string\")rrtype=null;switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":return dns.resolve(hostname,rrtype).then(promisifyLookup);default:return dns.resolve(hostname,rrtype)}},resolve4(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:4});return dns.lookup(hostname,{family:4}).then(promisifyResolveX)},resolve6(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:6});return dns.lookup(hostname,{family:6}).then(promisifyResolveX)},resolveSrv(hostname){return dns.resolveSrv(hostname)},resolveTxt(hostname){return dns.resolveTxt(hostname)},resolveSoa(hostname){return dns.resolveSoa(hostname)},resolveNaptr(hostname){return dns.resolveNaptr(hostname)},resolveMx(hostname){return dns.resolveMx(hostname)},resolveCaa(hostname){return dns.resolveCaa(hostname)},resolveNs(hostname){return dns.resolveNs(hostname)},resolvePtr(hostname){return dns.resolvePtr(hostname)},resolveCname(hostname){return dns.resolveCname(hostname)},Resolver:class Resolver2{constructor(options){}cancel(){}getServers(){return[]}resolve(hostname,rrtype){if(typeof rrtype!==\"string\")rrtype=null;switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":return dns.resolve(hostname,rrtype).then(promisifyLookup);default:return dns.resolve(hostname,rrtype)}}resolve4(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:4});return dns.lookup(hostname,{family:4}).then(promisifyResolveX)}resolve6(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:6});return dns.lookup(hostname,{family:6}).then(promisifyResolveX)}resolveAny(hostname){return Promise.resolve([])}resolveCname(hostname){return dns.resolveCname(hostname)}resolveMx(hostname){return dns.resolveMx(hostname)}resolveNaptr(hostname){return dns.resolveNaptr(hostname)}resolveNs(hostname){return dns.resolveNs(hostname)}resolvePtr(hostname){return dns.resolvePtr(hostname)}resolveSoa(hostname){return dns.resolveSoa(hostname)}resolveSrv(hostname){return dns.resolveSrv(hostname)}resolveCaa(hostname){return dns.resolveCaa(hostname)}resolveTxt(hostname){return dns.resolveTxt(hostname)}reverse(ip){return Promise.resolve([])}setServers(servers){}}};for(let key of[\"resolveAny\",\"reverse\"])promises[key]=()=>Promise.resolve(void 0);return{ADDRCONFIG:0,ALL:1,V4MAPPED:2,NODATA:\"DNS_ENODATA\",FORMERR:\"DNS_EFORMERR\",SERVFAIL:\"DNS_ESERVFAIL\",NOTFOUND:\"DNS_ENOTFOUND\",NOTIMP:\"DNS_ENOTIMP\",REFUSED:\"DNS_EREFUSED\",BADQUERY:\"DNS_EBADQUERY\",BADNAME:\"DNS_EBADNAME\",BADFAMILY:\"DNS_EBADFAMILY\",BADRESP:\"DNS_EBADRESP\",CONNREFUSED:\"DNS_ECONNREFUSED\",TIMEOUT:\"DNS_ETIMEOUT\",EOF:\"DNS_EEOF\",FILE:\"DNS_EFILE\",NOMEM:\"DNS_ENOMEM\",DESTRUCTION:\"DNS_EDESTRUCTION\",BADSTR:\"DNS_EBADSTR\",BADFLAGS:\"DNS_EBADFLAGS\",NONAME:\"DNS_ENONAME\",BADHINTS:\"DNS_EBADHINTS\",NOTINITIALIZED:\"DNS_ENOTINITIALIZED\",LOADIPHLPAPI:\"DNS_ELOADIPHLPAPI\",ADDRGETNETWORKPARAMS:\"DNS_EADDRGETNETWORKPARAMS\",CANCELLED:\"DNS_ECANCELLED\",lookup,lookupService,Resolver,setServers,setDefaultResultOrder,resolve,reverse,resolve4,resolve6,resolveAny,resolveCname,resolveCaa,resolveMx,resolveNs,resolvePtr,resolveSoa,resolveSrv,resolveTxt,resolveNaptr,promises,getServers}})\n"_s; // // @@ -278,7 +278,7 @@ static constexpr ASCIILiteral NodeDiagnosticsChannelCode = "(function (){\"use s // // -static constexpr ASCIILiteral NodeDNSCode = "(function (){\"use strict\";const dns=Bun.dns;function lookup(domain,options,callback){if(typeof options==\"function\")callback=options;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");if(typeof options==\"number\")options={family:options};dns.lookup(domain,options).then((res)=>{if(res.sort((a,b)=>a.family-b.family),options\?.all)callback(null,res.map(mapLookupAll));else{const[{address,family}]=res;callback(null,address,family)}},(error)=>{callback(error)})}function resolveSrv(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSrv(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveTxt(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveTxt(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveSoa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSoa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveNaptr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNaptr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveMx(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveMx(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveCaa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCaa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveNs(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNs(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolvePtr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolvePtr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveCname(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCname(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function lookupService(address,port,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");callback(null,address,port)}var InternalResolver=class Resolver2{constructor(options){}cancel(){}getServers(){return[]}resolve(hostname,rrtype,callback){if(typeof rrtype==\"function\")callback=rrtype,rrtype=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolve(hostname).then((results)=>{switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":callback(null,hostname,results.map(mapResolveX));break;default:callback(null,results);break}},(error)=>{callback(error)})}resolve4(hostname,options,callback){if(typeof options==\"function\")callback=options,options=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.lookup(hostname,{family:4}).then((addresses)=>{callback(null,options\?.ttl\?addresses:addresses.map(mapResolveX))},(error)=>{callback(error)})}resolve6(hostname,options,callback){if(typeof options==\"function\")callback=options,options=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.lookup(hostname,{family:6}).then((addresses)=>{callback(null,options\?.ttl\?addresses:addresses.map(({address})=>address))},(error)=>{callback(error)})}resolveAny(hostname,callback){callback(null,[])}resolveCname(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCname(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveMx(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveMx(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveNaptr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNaptr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveNs(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNs(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolvePtr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolvePtr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveSrv(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSrv(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveCaa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCaa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveTxt(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveTxt(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveSoa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSoa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}reverse(ip,callback){callback(null,[])}setServers(servers){}};function resolve(hostname,rrtype,callback){if(typeof rrtype==\"function\")callback=rrtype;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolve(hostname).then((results)=>{switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":callback(null,hostname,results.map(({address})=>address));break;default:callback(null,results);break}},(error)=>{callback(error)})}function Resolver(options){return new InternalResolver(options)}Resolver.prototype={},Object.setPrototypeOf(Resolver.prototype,InternalResolver.prototype),Object.setPrototypeOf(Resolver,InternalResolver);var{resolve,resolve4,resolve6,resolveAny,resolveCname,resolveCaa,resolveMx,resolveNaptr,resolveNs,resolvePtr,resolveSoa,resolveSrv,reverse,resolveTxt}=InternalResolver.prototype;function setDefaultResultOrder(){}function setServers(){}const promisifyLookup=(res)=>{res.sort((a,b)=>a.family-b.family);const[{address,family}]=res;return{address,family}},mapLookupAll=(res)=>{const{address,family}=res;return{address,family}},promisifyLookupAll=(res)=>{return res.sort((a,b)=>a.family-b.family),res.map(mapLookupAll)},mapResolveX=(a)=>a.address,promisifyResolveX=(res)=>{return res\?.map(mapResolveX)},promises={lookup(domain,options){if(options\?.all)return dns.lookup(domain,options).then(promisifyLookupAll);return dns.lookup(domain,options).then(promisifyLookup)},lookupService(address,port){return Promise.resolve([])},resolve(hostname,rrtype){if(typeof rrtype!==\"string\")rrtype=null;switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":return dns.resolve(hostname,rrtype).then(promisifyLookup);default:return dns.resolve(hostname,rrtype)}},resolve4(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:4});return dns.lookup(hostname,{family:4}).then(promisifyResolveX)},resolve6(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:6});return dns.lookup(hostname,{family:6}).then(promisifyResolveX)},resolveSrv(hostname){return dns.resolveSrv(hostname)},resolveTxt(hostname){return dns.resolveTxt(hostname)},resolveSoa(hostname){return dns.resolveSoa(hostname)},resolveNaptr(hostname){return dns.resolveNaptr(hostname)},resolveMx(hostname){return dns.resolveMx(hostname)},resolveCaa(hostname){return dns.resolveCaa(hostname)},resolveNs(hostname){return dns.resolveNs(hostname)},resolvePtr(hostname){return dns.resolvePtr(hostname)},resolveCname(hostname){return dns.resolveCname(hostname)},Resolver:class Resolver2{constructor(options){}cancel(){}getServers(){return[]}resolve(hostname,rrtype){if(typeof rrtype!==\"string\")rrtype=null;switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":return dns.resolve(hostname,rrtype).then(promisifyLookup);default:return dns.resolve(hostname,rrtype)}}resolve4(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:4});return dns.lookup(hostname,{family:4}).then(promisifyResolveX)}resolve6(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:6});return dns.lookup(hostname,{family:6}).then(promisifyResolveX)}resolveAny(hostname){return Promise.resolve([])}resolveCname(hostname){return dns.resolveCname(hostname)}resolveMx(hostname){return dns.resolveMx(hostname)}resolveNaptr(hostname){return dns.resolveNaptr(hostname)}resolveNs(hostname){return dns.resolveNs(hostname)}resolvePtr(hostname){return dns.resolvePtr(hostname)}resolveSoa(hostname){return dns.resolveSoa(hostname)}resolveSrv(hostname){return dns.resolveSrv(hostname)}resolveCaa(hostname){return dns.resolveCaa(hostname)}resolveTxt(hostname){return dns.resolveTxt(hostname)}reverse(ip){return Promise.resolve([])}setServers(servers){}}};for(let key of[\"resolveAny\",\"reverse\"])promises[key]=()=>Promise.resolve(void 0);return{ADDRCONFIG:0,ALL:1,V4MAPPED:2,NODATA:\"DNS_ENODATA\",FORMERR:\"DNS_EFORMERR\",SERVFAIL:\"DNS_ESERVFAIL\",NOTFOUND:\"DNS_ENOTFOUND\",NOTIMP:\"DNS_ENOTIMP\",REFUSED:\"DNS_EREFUSED\",BADQUERY:\"DNS_EBADQUERY\",BADNAME:\"DNS_EBADNAME\",BADFAMILY:\"DNS_EBADFAMILY\",BADRESP:\"DNS_EBADRESP\",CONNREFUSED:\"DNS_ECONNREFUSED\",TIMEOUT:\"DNS_ETIMEOUT\",EOF:\"DNS_EEOF\",FILE:\"DNS_EFILE\",NOMEM:\"DNS_ENOMEM\",DESTRUCTION:\"DNS_EDESTRUCTION\",BADSTR:\"DNS_EBADSTR\",BADFLAGS:\"DNS_EBADFLAGS\",NONAME:\"DNS_ENONAME\",BADHINTS:\"DNS_EBADHINTS\",NOTINITIALIZED:\"DNS_ENOTINITIALIZED\",LOADIPHLPAPI:\"DNS_ELOADIPHLPAPI\",ADDRGETNETWORKPARAMS:\"DNS_EADDRGETNETWORKPARAMS\",CANCELLED:\"DNS_ECANCELLED\",lookup,lookupService,Resolver,setServers,setDefaultResultOrder,resolve,reverse,resolve4,resolve6,resolveAny,resolveCname,resolveCaa,resolveMx,resolveNs,resolvePtr,resolveSoa,resolveSrv,resolveTxt,resolveNaptr,promises}})\n"_s; +static constexpr ASCIILiteral NodeDNSCode = "(function (){\"use strict\";const dns=Bun.dns;function getServers(){return dns.getServers()}function lookup(domain,options,callback){if(typeof options==\"function\")callback=options;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");if(typeof options==\"number\")options={family:options};dns.lookup(domain,options).then((res)=>{if(res.sort((a,b)=>a.family-b.family),options\?.all)callback(null,res.map(mapLookupAll));else{const[{address,family}]=res;callback(null,address,family)}},(error)=>{callback(error)})}function resolveSrv(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSrv(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveTxt(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveTxt(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveSoa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSoa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveNaptr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNaptr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveMx(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveMx(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveCaa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCaa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveNs(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNs(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolvePtr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolvePtr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveCname(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCname(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function lookupService(address,port,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");callback(null,address,port)}var InternalResolver=class Resolver2{constructor(options){}cancel(){}getServers(){return[]}resolve(hostname,rrtype,callback){if(typeof rrtype==\"function\")callback=rrtype,rrtype=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolve(hostname).then((results)=>{switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":callback(null,hostname,results.map(mapResolveX));break;default:callback(null,results);break}},(error)=>{callback(error)})}resolve4(hostname,options,callback){if(typeof options==\"function\")callback=options,options=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.lookup(hostname,{family:4}).then((addresses)=>{callback(null,options\?.ttl\?addresses:addresses.map(mapResolveX))},(error)=>{callback(error)})}resolve6(hostname,options,callback){if(typeof options==\"function\")callback=options,options=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.lookup(hostname,{family:6}).then((addresses)=>{callback(null,options\?.ttl\?addresses:addresses.map(({address})=>address))},(error)=>{callback(error)})}resolveAny(hostname,callback){callback(null,[])}resolveCname(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCname(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveMx(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveMx(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveNaptr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNaptr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveNs(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNs(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolvePtr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolvePtr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveSrv(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSrv(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveCaa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCaa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveTxt(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveTxt(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveSoa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSoa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}reverse(ip,callback){callback(null,[])}setServers(servers){}};function resolve(hostname,rrtype,callback){if(typeof rrtype==\"function\")callback=rrtype;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolve(hostname).then((results)=>{switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":callback(null,hostname,results.map(({address})=>address));break;default:callback(null,results);break}},(error)=>{callback(error)})}function Resolver(options){return new InternalResolver(options)}Resolver.prototype={},Object.setPrototypeOf(Resolver.prototype,InternalResolver.prototype),Object.setPrototypeOf(Resolver,InternalResolver);var{resolve,resolve4,resolve6,resolveAny,resolveCname,resolveCaa,resolveMx,resolveNaptr,resolveNs,resolvePtr,resolveSoa,resolveSrv,reverse,resolveTxt}=InternalResolver.prototype;function setDefaultResultOrder(){}function setServers(){}const promisifyLookup=(res)=>{res.sort((a,b)=>a.family-b.family);const[{address,family}]=res;return{address,family}},mapLookupAll=(res)=>{const{address,family}=res;return{address,family}},promisifyLookupAll=(res)=>{return res.sort((a,b)=>a.family-b.family),res.map(mapLookupAll)},mapResolveX=(a)=>a.address,promisifyResolveX=(res)=>{return res\?.map(mapResolveX)},promises={lookup(domain,options){if(options\?.all)return dns.lookup(domain,options).then(promisifyLookupAll);return dns.lookup(domain,options).then(promisifyLookup)},lookupService(address,port){return Promise.resolve([])},resolve(hostname,rrtype){if(typeof rrtype!==\"string\")rrtype=null;switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":return dns.resolve(hostname,rrtype).then(promisifyLookup);default:return dns.resolve(hostname,rrtype)}},resolve4(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:4});return dns.lookup(hostname,{family:4}).then(promisifyResolveX)},resolve6(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:6});return dns.lookup(hostname,{family:6}).then(promisifyResolveX)},resolveSrv(hostname){return dns.resolveSrv(hostname)},resolveTxt(hostname){return dns.resolveTxt(hostname)},resolveSoa(hostname){return dns.resolveSoa(hostname)},resolveNaptr(hostname){return dns.resolveNaptr(hostname)},resolveMx(hostname){return dns.resolveMx(hostname)},resolveCaa(hostname){return dns.resolveCaa(hostname)},resolveNs(hostname){return dns.resolveNs(hostname)},resolvePtr(hostname){return dns.resolvePtr(hostname)},resolveCname(hostname){return dns.resolveCname(hostname)},Resolver:class Resolver2{constructor(options){}cancel(){}getServers(){return[]}resolve(hostname,rrtype){if(typeof rrtype!==\"string\")rrtype=null;switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":return dns.resolve(hostname,rrtype).then(promisifyLookup);default:return dns.resolve(hostname,rrtype)}}resolve4(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:4});return dns.lookup(hostname,{family:4}).then(promisifyResolveX)}resolve6(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:6});return dns.lookup(hostname,{family:6}).then(promisifyResolveX)}resolveAny(hostname){return Promise.resolve([])}resolveCname(hostname){return dns.resolveCname(hostname)}resolveMx(hostname){return dns.resolveMx(hostname)}resolveNaptr(hostname){return dns.resolveNaptr(hostname)}resolveNs(hostname){return dns.resolveNs(hostname)}resolvePtr(hostname){return dns.resolvePtr(hostname)}resolveSoa(hostname){return dns.resolveSoa(hostname)}resolveSrv(hostname){return dns.resolveSrv(hostname)}resolveCaa(hostname){return dns.resolveCaa(hostname)}resolveTxt(hostname){return dns.resolveTxt(hostname)}reverse(ip){return Promise.resolve([])}setServers(servers){}}};for(let key of[\"resolveAny\",\"reverse\"])promises[key]=()=>Promise.resolve(void 0);return{ADDRCONFIG:0,ALL:1,V4MAPPED:2,NODATA:\"DNS_ENODATA\",FORMERR:\"DNS_EFORMERR\",SERVFAIL:\"DNS_ESERVFAIL\",NOTFOUND:\"DNS_ENOTFOUND\",NOTIMP:\"DNS_ENOTIMP\",REFUSED:\"DNS_EREFUSED\",BADQUERY:\"DNS_EBADQUERY\",BADNAME:\"DNS_EBADNAME\",BADFAMILY:\"DNS_EBADFAMILY\",BADRESP:\"DNS_EBADRESP\",CONNREFUSED:\"DNS_ECONNREFUSED\",TIMEOUT:\"DNS_ETIMEOUT\",EOF:\"DNS_EEOF\",FILE:\"DNS_EFILE\",NOMEM:\"DNS_ENOMEM\",DESTRUCTION:\"DNS_EDESTRUCTION\",BADSTR:\"DNS_EBADSTR\",BADFLAGS:\"DNS_EBADFLAGS\",NONAME:\"DNS_ENONAME\",BADHINTS:\"DNS_EBADHINTS\",NOTINITIALIZED:\"DNS_ENOTINITIALIZED\",LOADIPHLPAPI:\"DNS_ELOADIPHLPAPI\",ADDRGETNETWORKPARAMS:\"DNS_EADDRGETNETWORKPARAMS\",CANCELLED:\"DNS_ECANCELLED\",lookup,lookupService,Resolver,setServers,setDefaultResultOrder,resolve,reverse,resolve4,resolve6,resolveAny,resolveCname,resolveCaa,resolveMx,resolveNs,resolvePtr,resolveSoa,resolveSrv,resolveTxt,resolveNaptr,promises,getServers}})\n"_s; // // @@ -504,7 +504,7 @@ static constexpr ASCIILiteral NodeDiagnosticsChannelCode = "(function (){\"use s // // -static constexpr ASCIILiteral NodeDNSCode = "(function (){\"use strict\";const dns=Bun.dns;function lookup(domain,options,callback){if(typeof options==\"function\")callback=options;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");if(typeof options==\"number\")options={family:options};dns.lookup(domain,options).then((res)=>{if(res.sort((a,b)=>a.family-b.family),options\?.all)callback(null,res.map(mapLookupAll));else{const[{address,family}]=res;callback(null,address,family)}},(error)=>{callback(error)})}function resolveSrv(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSrv(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveTxt(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveTxt(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveSoa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSoa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveNaptr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNaptr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveMx(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveMx(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveCaa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCaa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveNs(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNs(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolvePtr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolvePtr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveCname(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCname(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function lookupService(address,port,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");callback(null,address,port)}var InternalResolver=class Resolver2{constructor(options){}cancel(){}getServers(){return[]}resolve(hostname,rrtype,callback){if(typeof rrtype==\"function\")callback=rrtype,rrtype=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolve(hostname).then((results)=>{switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":callback(null,hostname,results.map(mapResolveX));break;default:callback(null,results);break}},(error)=>{callback(error)})}resolve4(hostname,options,callback){if(typeof options==\"function\")callback=options,options=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.lookup(hostname,{family:4}).then((addresses)=>{callback(null,options\?.ttl\?addresses:addresses.map(mapResolveX))},(error)=>{callback(error)})}resolve6(hostname,options,callback){if(typeof options==\"function\")callback=options,options=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.lookup(hostname,{family:6}).then((addresses)=>{callback(null,options\?.ttl\?addresses:addresses.map(({address})=>address))},(error)=>{callback(error)})}resolveAny(hostname,callback){callback(null,[])}resolveCname(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCname(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveMx(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveMx(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveNaptr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNaptr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveNs(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNs(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolvePtr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolvePtr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveSrv(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSrv(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveCaa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCaa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveTxt(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveTxt(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveSoa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSoa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}reverse(ip,callback){callback(null,[])}setServers(servers){}};function resolve(hostname,rrtype,callback){if(typeof rrtype==\"function\")callback=rrtype;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolve(hostname).then((results)=>{switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":callback(null,hostname,results.map(({address})=>address));break;default:callback(null,results);break}},(error)=>{callback(error)})}function Resolver(options){return new InternalResolver(options)}Resolver.prototype={},Object.setPrototypeOf(Resolver.prototype,InternalResolver.prototype),Object.setPrototypeOf(Resolver,InternalResolver);var{resolve,resolve4,resolve6,resolveAny,resolveCname,resolveCaa,resolveMx,resolveNaptr,resolveNs,resolvePtr,resolveSoa,resolveSrv,reverse,resolveTxt}=InternalResolver.prototype;function setDefaultResultOrder(){}function setServers(){}const promisifyLookup=(res)=>{res.sort((a,b)=>a.family-b.family);const[{address,family}]=res;return{address,family}},mapLookupAll=(res)=>{const{address,family}=res;return{address,family}},promisifyLookupAll=(res)=>{return res.sort((a,b)=>a.family-b.family),res.map(mapLookupAll)},mapResolveX=(a)=>a.address,promisifyResolveX=(res)=>{return res\?.map(mapResolveX)},promises={lookup(domain,options){if(options\?.all)return dns.lookup(domain,options).then(promisifyLookupAll);return dns.lookup(domain,options).then(promisifyLookup)},lookupService(address,port){return Promise.resolve([])},resolve(hostname,rrtype){if(typeof rrtype!==\"string\")rrtype=null;switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":return dns.resolve(hostname,rrtype).then(promisifyLookup);default:return dns.resolve(hostname,rrtype)}},resolve4(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:4});return dns.lookup(hostname,{family:4}).then(promisifyResolveX)},resolve6(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:6});return dns.lookup(hostname,{family:6}).then(promisifyResolveX)},resolveSrv(hostname){return dns.resolveSrv(hostname)},resolveTxt(hostname){return dns.resolveTxt(hostname)},resolveSoa(hostname){return dns.resolveSoa(hostname)},resolveNaptr(hostname){return dns.resolveNaptr(hostname)},resolveMx(hostname){return dns.resolveMx(hostname)},resolveCaa(hostname){return dns.resolveCaa(hostname)},resolveNs(hostname){return dns.resolveNs(hostname)},resolvePtr(hostname){return dns.resolvePtr(hostname)},resolveCname(hostname){return dns.resolveCname(hostname)},Resolver:class Resolver2{constructor(options){}cancel(){}getServers(){return[]}resolve(hostname,rrtype){if(typeof rrtype!==\"string\")rrtype=null;switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":return dns.resolve(hostname,rrtype).then(promisifyLookup);default:return dns.resolve(hostname,rrtype)}}resolve4(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:4});return dns.lookup(hostname,{family:4}).then(promisifyResolveX)}resolve6(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:6});return dns.lookup(hostname,{family:6}).then(promisifyResolveX)}resolveAny(hostname){return Promise.resolve([])}resolveCname(hostname){return dns.resolveCname(hostname)}resolveMx(hostname){return dns.resolveMx(hostname)}resolveNaptr(hostname){return dns.resolveNaptr(hostname)}resolveNs(hostname){return dns.resolveNs(hostname)}resolvePtr(hostname){return dns.resolvePtr(hostname)}resolveSoa(hostname){return dns.resolveSoa(hostname)}resolveSrv(hostname){return dns.resolveSrv(hostname)}resolveCaa(hostname){return dns.resolveCaa(hostname)}resolveTxt(hostname){return dns.resolveTxt(hostname)}reverse(ip){return Promise.resolve([])}setServers(servers){}}};for(let key of[\"resolveAny\",\"reverse\"])promises[key]=()=>Promise.resolve(void 0);return{ADDRCONFIG:0,ALL:1,V4MAPPED:2,NODATA:\"DNS_ENODATA\",FORMERR:\"DNS_EFORMERR\",SERVFAIL:\"DNS_ESERVFAIL\",NOTFOUND:\"DNS_ENOTFOUND\",NOTIMP:\"DNS_ENOTIMP\",REFUSED:\"DNS_EREFUSED\",BADQUERY:\"DNS_EBADQUERY\",BADNAME:\"DNS_EBADNAME\",BADFAMILY:\"DNS_EBADFAMILY\",BADRESP:\"DNS_EBADRESP\",CONNREFUSED:\"DNS_ECONNREFUSED\",TIMEOUT:\"DNS_ETIMEOUT\",EOF:\"DNS_EEOF\",FILE:\"DNS_EFILE\",NOMEM:\"DNS_ENOMEM\",DESTRUCTION:\"DNS_EDESTRUCTION\",BADSTR:\"DNS_EBADSTR\",BADFLAGS:\"DNS_EBADFLAGS\",NONAME:\"DNS_ENONAME\",BADHINTS:\"DNS_EBADHINTS\",NOTINITIALIZED:\"DNS_ENOTINITIALIZED\",LOADIPHLPAPI:\"DNS_ELOADIPHLPAPI\",ADDRGETNETWORKPARAMS:\"DNS_EADDRGETNETWORKPARAMS\",CANCELLED:\"DNS_ECANCELLED\",lookup,lookupService,Resolver,setServers,setDefaultResultOrder,resolve,reverse,resolve4,resolve6,resolveAny,resolveCname,resolveCaa,resolveMx,resolveNs,resolvePtr,resolveSoa,resolveSrv,resolveTxt,resolveNaptr,promises}})\n"_s; +static constexpr ASCIILiteral NodeDNSCode = "(function (){\"use strict\";const dns=Bun.dns;function getServers(){return dns.getServers()}function lookup(domain,options,callback){if(typeof options==\"function\")callback=options;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");if(typeof options==\"number\")options={family:options};dns.lookup(domain,options).then((res)=>{if(res.sort((a,b)=>a.family-b.family),options\?.all)callback(null,res.map(mapLookupAll));else{const[{address,family}]=res;callback(null,address,family)}},(error)=>{callback(error)})}function resolveSrv(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSrv(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveTxt(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveTxt(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveSoa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSoa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveNaptr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNaptr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveMx(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveMx(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveCaa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCaa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveNs(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNs(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolvePtr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolvePtr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveCname(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCname(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function lookupService(address,port,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");callback(null,address,port)}var InternalResolver=class Resolver2{constructor(options){}cancel(){}getServers(){return[]}resolve(hostname,rrtype,callback){if(typeof rrtype==\"function\")callback=rrtype,rrtype=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolve(hostname).then((results)=>{switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":callback(null,hostname,results.map(mapResolveX));break;default:callback(null,results);break}},(error)=>{callback(error)})}resolve4(hostname,options,callback){if(typeof options==\"function\")callback=options,options=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.lookup(hostname,{family:4}).then((addresses)=>{callback(null,options\?.ttl\?addresses:addresses.map(mapResolveX))},(error)=>{callback(error)})}resolve6(hostname,options,callback){if(typeof options==\"function\")callback=options,options=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.lookup(hostname,{family:6}).then((addresses)=>{callback(null,options\?.ttl\?addresses:addresses.map(({address})=>address))},(error)=>{callback(error)})}resolveAny(hostname,callback){callback(null,[])}resolveCname(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCname(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveMx(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveMx(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveNaptr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNaptr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveNs(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNs(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolvePtr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolvePtr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveSrv(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSrv(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveCaa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCaa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveTxt(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveTxt(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveSoa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSoa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}reverse(ip,callback){callback(null,[])}setServers(servers){}};function resolve(hostname,rrtype,callback){if(typeof rrtype==\"function\")callback=rrtype;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolve(hostname).then((results)=>{switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":callback(null,hostname,results.map(({address})=>address));break;default:callback(null,results);break}},(error)=>{callback(error)})}function Resolver(options){return new InternalResolver(options)}Resolver.prototype={},Object.setPrototypeOf(Resolver.prototype,InternalResolver.prototype),Object.setPrototypeOf(Resolver,InternalResolver);var{resolve,resolve4,resolve6,resolveAny,resolveCname,resolveCaa,resolveMx,resolveNaptr,resolveNs,resolvePtr,resolveSoa,resolveSrv,reverse,resolveTxt}=InternalResolver.prototype;function setDefaultResultOrder(){}function setServers(){}const promisifyLookup=(res)=>{res.sort((a,b)=>a.family-b.family);const[{address,family}]=res;return{address,family}},mapLookupAll=(res)=>{const{address,family}=res;return{address,family}},promisifyLookupAll=(res)=>{return res.sort((a,b)=>a.family-b.family),res.map(mapLookupAll)},mapResolveX=(a)=>a.address,promisifyResolveX=(res)=>{return res\?.map(mapResolveX)},promises={lookup(domain,options){if(options\?.all)return dns.lookup(domain,options).then(promisifyLookupAll);return dns.lookup(domain,options).then(promisifyLookup)},lookupService(address,port){return Promise.resolve([])},resolve(hostname,rrtype){if(typeof rrtype!==\"string\")rrtype=null;switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":return dns.resolve(hostname,rrtype).then(promisifyLookup);default:return dns.resolve(hostname,rrtype)}},resolve4(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:4});return dns.lookup(hostname,{family:4}).then(promisifyResolveX)},resolve6(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:6});return dns.lookup(hostname,{family:6}).then(promisifyResolveX)},resolveSrv(hostname){return dns.resolveSrv(hostname)},resolveTxt(hostname){return dns.resolveTxt(hostname)},resolveSoa(hostname){return dns.resolveSoa(hostname)},resolveNaptr(hostname){return dns.resolveNaptr(hostname)},resolveMx(hostname){return dns.resolveMx(hostname)},resolveCaa(hostname){return dns.resolveCaa(hostname)},resolveNs(hostname){return dns.resolveNs(hostname)},resolvePtr(hostname){return dns.resolvePtr(hostname)},resolveCname(hostname){return dns.resolveCname(hostname)},Resolver:class Resolver2{constructor(options){}cancel(){}getServers(){return[]}resolve(hostname,rrtype){if(typeof rrtype!==\"string\")rrtype=null;switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":return dns.resolve(hostname,rrtype).then(promisifyLookup);default:return dns.resolve(hostname,rrtype)}}resolve4(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:4});return dns.lookup(hostname,{family:4}).then(promisifyResolveX)}resolve6(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:6});return dns.lookup(hostname,{family:6}).then(promisifyResolveX)}resolveAny(hostname){return Promise.resolve([])}resolveCname(hostname){return dns.resolveCname(hostname)}resolveMx(hostname){return dns.resolveMx(hostname)}resolveNaptr(hostname){return dns.resolveNaptr(hostname)}resolveNs(hostname){return dns.resolveNs(hostname)}resolvePtr(hostname){return dns.resolvePtr(hostname)}resolveSoa(hostname){return dns.resolveSoa(hostname)}resolveSrv(hostname){return dns.resolveSrv(hostname)}resolveCaa(hostname){return dns.resolveCaa(hostname)}resolveTxt(hostname){return dns.resolveTxt(hostname)}reverse(ip){return Promise.resolve([])}setServers(servers){}}};for(let key of[\"resolveAny\",\"reverse\"])promises[key]=()=>Promise.resolve(void 0);return{ADDRCONFIG:0,ALL:1,V4MAPPED:2,NODATA:\"DNS_ENODATA\",FORMERR:\"DNS_EFORMERR\",SERVFAIL:\"DNS_ESERVFAIL\",NOTFOUND:\"DNS_ENOTFOUND\",NOTIMP:\"DNS_ENOTIMP\",REFUSED:\"DNS_EREFUSED\",BADQUERY:\"DNS_EBADQUERY\",BADNAME:\"DNS_EBADNAME\",BADFAMILY:\"DNS_EBADFAMILY\",BADRESP:\"DNS_EBADRESP\",CONNREFUSED:\"DNS_ECONNREFUSED\",TIMEOUT:\"DNS_ETIMEOUT\",EOF:\"DNS_EEOF\",FILE:\"DNS_EFILE\",NOMEM:\"DNS_ENOMEM\",DESTRUCTION:\"DNS_EDESTRUCTION\",BADSTR:\"DNS_EBADSTR\",BADFLAGS:\"DNS_EBADFLAGS\",NONAME:\"DNS_ENONAME\",BADHINTS:\"DNS_EBADHINTS\",NOTINITIALIZED:\"DNS_ENOTINITIALIZED\",LOADIPHLPAPI:\"DNS_ELOADIPHLPAPI\",ADDRGETNETWORKPARAMS:\"DNS_EADDRGETNETWORKPARAMS\",CANCELLED:\"DNS_ECANCELLED\",lookup,lookupService,Resolver,setServers,setDefaultResultOrder,resolve,reverse,resolve4,resolve6,resolveAny,resolveCname,resolveCaa,resolveMx,resolveNs,resolvePtr,resolveSoa,resolveSrv,resolveTxt,resolveNaptr,promises,getServers}})\n"_s; // // diff --git a/test/js/node/dns/node-dns.test.js b/test/js/node/dns/node-dns.test.js index 5de840146..f905a2885 100644 --- a/test/js/node/dns/node-dns.test.js +++ b/test/js/node/dns/node-dns.test.js @@ -1,6 +1,8 @@ import { expect, test } from "bun:test"; import * as dns from "node:dns"; import * as dns_promises from "node:dns/promises"; +import * as fs from "node:fs"; +import * as os from "node:os"; // TODO: test("it exists", () => { @@ -190,3 +192,34 @@ test("dns.lookup (localhost)", done => { done(err); }); }); + +test("dns.getServers", done => { + function parseResolvConf() { + let servers = []; + try { + const content = fs.readFileSync("/etc/resolv.conf", "utf-8"); + const lines = content.split(os.EOL); + + for (const line of lines) { + const parts = line.trim().split(/\s+/); + if (parts.length >= 2 && parts[0] === "nameserver") { + servers.push(parts[1]); + } + } + } catch (err) { + done(err); + } + return servers; + } + + const expectServers = parseResolvConf(); + const actualServers = dns.getServers(); + try { + for (const server of expectServers) { + expect(actualServers).toContain(server); + } + } catch (err) { + return done(err); + } + done(); +}); |