mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 21:01:52 +00:00
Isolated resolution
This commit is contained in:
@@ -2281,7 +2281,13 @@ pub const DNSResolver = struct {
|
||||
});
|
||||
};
|
||||
|
||||
pub fn resolve(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
pub fn globalResolve(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
const vm = globalThis.bunVM();
|
||||
const resolver = vm.rareData().globalDNSResolver(vm);
|
||||
return resolver.resolve(globalThis, callframe);
|
||||
}
|
||||
|
||||
pub fn resolve(resolver: *DNSResolver, globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
const arguments = callframe.arguments_old(3);
|
||||
if (arguments.len < 1) {
|
||||
return globalThis.throwNotEnoughArguments("resolve", 3, arguments.len);
|
||||
@@ -2324,8 +2330,6 @@ pub const DNSResolver = struct {
|
||||
|
||||
const name = name_str.toSliceClone(globalThis, bun.default_allocator);
|
||||
|
||||
var vm = globalThis.bunVM();
|
||||
var resolver = vm.rareData().globalDNSResolver(vm);
|
||||
//TODO: ANY CASE
|
||||
switch (record_type) {
|
||||
RecordType.A => {
|
||||
@@ -2362,7 +2366,7 @@ pub const DNSResolver = struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reverse(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
pub fn globalReverse(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
const arguments = callframe.arguments_old(2);
|
||||
if (arguments.len < 1) {
|
||||
return globalThis.throwNotEnoughArguments("reverse", 2, arguments.len);
|
||||
@@ -2423,7 +2427,7 @@ pub const DNSResolver = struct {
|
||||
return promise;
|
||||
}
|
||||
|
||||
pub fn lookup(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
pub fn globalLookup(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
const arguments = callframe.arguments_old(2);
|
||||
if (arguments.len < 1) {
|
||||
return globalThis.throwNotEnoughArguments("lookup", 2, arguments.len);
|
||||
@@ -2504,7 +2508,7 @@ pub const DNSResolver = struct {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn resolveSrv(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
pub fn globalResolveSrv(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
const arguments = callframe.arguments_old(2);
|
||||
if (arguments.len < 1) {
|
||||
return globalThis.throwNotEnoughArguments("resolveSrv", 2, arguments.len);
|
||||
@@ -2532,7 +2536,7 @@ pub const DNSResolver = struct {
|
||||
return resolver.doResolveCAres(c_ares.struct_ares_srv_reply, "srv", name.slice(), globalThis);
|
||||
}
|
||||
|
||||
pub fn resolveSoa(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
pub fn globalResolveSoa(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
const arguments = callframe.arguments_old(2);
|
||||
if (arguments.len < 1) {
|
||||
return globalThis.throwNotEnoughArguments("resolveSoa", 2, arguments.len);
|
||||
@@ -2556,7 +2560,7 @@ pub const DNSResolver = struct {
|
||||
return resolver.doResolveCAres(c_ares.struct_ares_soa_reply, "soa", name.slice(), globalThis);
|
||||
}
|
||||
|
||||
pub fn resolveCaa(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
pub fn globalResolveCaa(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
const arguments = callframe.arguments_old(2);
|
||||
if (arguments.len < 1) {
|
||||
return globalThis.throwNotEnoughArguments("resolveCaa", 2, arguments.len);
|
||||
@@ -2584,7 +2588,7 @@ pub const DNSResolver = struct {
|
||||
return resolver.doResolveCAres(c_ares.struct_ares_caa_reply, "caa", name.slice(), globalThis);
|
||||
}
|
||||
|
||||
pub fn resolveNs(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
pub fn globalResolveNs(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
const arguments = callframe.arguments_old(2);
|
||||
if (arguments.len < 1) {
|
||||
return globalThis.throwNotEnoughArguments("resolveNs", 2, arguments.len);
|
||||
@@ -2608,7 +2612,7 @@ pub const DNSResolver = struct {
|
||||
return resolver.doResolveCAres(c_ares.struct_hostent, "ns", name.slice(), globalThis);
|
||||
}
|
||||
|
||||
pub fn resolvePtr(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
pub fn globalResolvePtr(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
const arguments = callframe.arguments_old(2);
|
||||
if (arguments.len < 1) {
|
||||
return globalThis.throwNotEnoughArguments("resolvePtr", 2, arguments.len);
|
||||
@@ -2636,7 +2640,7 @@ pub const DNSResolver = struct {
|
||||
return resolver.doResolveCAres(c_ares.struct_hostent, "ptr", name.slice(), globalThis);
|
||||
}
|
||||
|
||||
pub fn resolveCname(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
pub fn globalResolveCname(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
const arguments = callframe.arguments_old(2);
|
||||
if (arguments.len < 1) {
|
||||
return globalThis.throwNotEnoughArguments("resolveCname", 2, arguments.len);
|
||||
@@ -2664,7 +2668,7 @@ pub const DNSResolver = struct {
|
||||
return resolver.doResolveCAres(c_ares.struct_hostent, "cname", name.slice(), globalThis);
|
||||
}
|
||||
|
||||
pub fn resolveMx(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
pub fn globalResolveMx(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
const arguments = callframe.arguments_old(2);
|
||||
if (arguments.len < 1) {
|
||||
return globalThis.throwNotEnoughArguments("resolveMx", 2, arguments.len);
|
||||
@@ -2692,7 +2696,7 @@ pub const DNSResolver = struct {
|
||||
return resolver.doResolveCAres(c_ares.struct_ares_mx_reply, "mx", name.slice(), globalThis);
|
||||
}
|
||||
|
||||
pub fn resolveNaptr(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
pub fn globalResolveNaptr(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
const arguments = callframe.arguments_old(2);
|
||||
if (arguments.len < 1) {
|
||||
return globalThis.throwNotEnoughArguments("resolveNaptr", 2, arguments.len);
|
||||
@@ -2720,7 +2724,7 @@ pub const DNSResolver = struct {
|
||||
return resolver.doResolveCAres(c_ares.struct_ares_naptr_reply, "naptr", name.slice(), globalThis);
|
||||
}
|
||||
|
||||
pub fn resolveTxt(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
pub fn globalResolveTxt(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
const arguments = callframe.arguments_old(2);
|
||||
if (arguments.len < 1) {
|
||||
return globalThis.throwNotEnoughArguments("resolveTxt", 2, arguments.len);
|
||||
@@ -3020,7 +3024,7 @@ pub const DNSResolver = struct {
|
||||
// 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) bun.JSError!JSC.JSValue {
|
||||
pub fn globalLookupService(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
const arguments = callframe.arguments_old(3);
|
||||
if (arguments.len < 2) {
|
||||
return globalThis.throwNotEnoughArguments("lookupService", 3, arguments.len);
|
||||
@@ -3113,40 +3117,40 @@ pub const DNSResolver = struct {
|
||||
}
|
||||
|
||||
comptime {
|
||||
const js_resolve = JSC.toJSHostFunction(resolve);
|
||||
const js_resolve = JSC.toJSHostFunction(globalResolve);
|
||||
@export(js_resolve, .{ .name = "Bun__DNS__resolve" });
|
||||
const js_lookup = JSC.toJSHostFunction(lookup);
|
||||
@export(js_lookup, .{ .name = "Bun__DNSResolver__lookup" });
|
||||
const js_resolveTxt = JSC.toJSHostFunction(resolveTxt);
|
||||
@export(js_resolveTxt, .{ .name = "Bun__DNSResolver__resolveTxt" });
|
||||
const js_resolveSoa = JSC.toJSHostFunction(resolveSoa);
|
||||
@export(js_resolveSoa, .{ .name = "Bun__DNSResolver__resolveSoa" });
|
||||
const js_resolveMx = JSC.toJSHostFunction(resolveMx);
|
||||
@export(js_resolveMx, .{ .name = "Bun__DNSResolver__resolveMx" });
|
||||
const js_resolveNaptr = JSC.toJSHostFunction(resolveNaptr);
|
||||
@export(js_resolveNaptr, .{ .name = "Bun__DNSResolver__resolveNaptr" });
|
||||
const js_resolveSrv = JSC.toJSHostFunction(resolveSrv);
|
||||
@export(js_resolveSrv, .{ .name = "Bun__DNSResolver__resolveSrv" });
|
||||
const js_resolveCaa = JSC.toJSHostFunction(resolveCaa);
|
||||
@export(js_resolveCaa, .{ .name = "Bun__DNSResolver__resolveCaa" });
|
||||
const js_resolveNs = JSC.toJSHostFunction(resolveNs);
|
||||
@export(js_resolveNs, .{ .name = "Bun__DNSResolver__resolveNs" });
|
||||
const js_resolvePtr = JSC.toJSHostFunction(resolvePtr);
|
||||
@export(js_resolvePtr, .{ .name = "Bun__DNSResolver__resolvePtr" });
|
||||
const js_resolveCname = JSC.toJSHostFunction(resolveCname);
|
||||
@export(js_resolveCname, .{ .name = "Bun__DNSResolver__resolveCname" });
|
||||
const js_lookup = JSC.toJSHostFunction(globalLookup);
|
||||
@export(js_lookup, .{ .name = "Bun__DNS__lookup" });
|
||||
const js_resolveTxt = JSC.toJSHostFunction(globalResolveTxt);
|
||||
@export(js_resolveTxt, .{ .name = "Bun__DNS__resolveTxt" });
|
||||
const js_resolveSoa = JSC.toJSHostFunction(globalResolveSoa);
|
||||
@export(js_resolveSoa, .{ .name = "Bun__DNS__resolveSoa" });
|
||||
const js_resolveMx = JSC.toJSHostFunction(globalResolveMx);
|
||||
@export(js_resolveMx, .{ .name = "Bun__DNS__resolveMx" });
|
||||
const js_resolveNaptr = JSC.toJSHostFunction(globalResolveNaptr);
|
||||
@export(js_resolveNaptr, .{ .name = "Bun__DNS__resolveNaptr" });
|
||||
const js_resolveSrv = JSC.toJSHostFunction(globalResolveSrv);
|
||||
@export(js_resolveSrv, .{ .name = "Bun__DNS__resolveSrv" });
|
||||
const js_resolveCaa = JSC.toJSHostFunction(globalResolveCaa);
|
||||
@export(js_resolveCaa, .{ .name = "Bun__DNS__resolveCaa" });
|
||||
const js_resolveNs = JSC.toJSHostFunction(globalResolveNs);
|
||||
@export(js_resolveNs, .{ .name = "Bun__DNS__resolveNs" });
|
||||
const js_resolvePtr = JSC.toJSHostFunction(globalResolvePtr);
|
||||
@export(js_resolvePtr, .{ .name = "Bun__DNS__resolvePtr" });
|
||||
const js_resolveCname = JSC.toJSHostFunction(globalResolveCname);
|
||||
@export(js_resolveCname, .{ .name = "Bun__DNS__resolveCname" });
|
||||
const js_getGlobalServers = JSC.toJSHostFunction(getGlobalServers);
|
||||
@export(js_getGlobalServers, .{ .name = "Bun__DNS__getServers" });
|
||||
const js_setGlobalServers = JSC.toJSHostFunction(setGlobalServers);
|
||||
@export(js_setGlobalServers, .{ .name = "Bun__DNS__setServers" });
|
||||
const js_reverse = JSC.toJSHostFunction(reverse);
|
||||
@export(js_reverse, .{ .name = "Bun__DNSResolver__reverse" });
|
||||
const js_lookupService = JSC.toJSHostFunction(lookupService);
|
||||
@export(js_lookupService, .{ .name = "Bun__DNSResolver__lookupService" });
|
||||
const js_reverse = JSC.toJSHostFunction(globalReverse);
|
||||
@export(js_reverse, .{ .name = "Bun__DNS__reverse" });
|
||||
const js_lookupService = JSC.toJSHostFunction(globalLookupService);
|
||||
@export(js_lookupService, .{ .name = "Bun__DNS__lookupService" });
|
||||
const js_prefetchFromJS = JSC.toJSHostFunction(InternalDNS.prefetchFromJS);
|
||||
@export(js_prefetchFromJS, .{ .name = "Bun__DNSResolver__prefetch" });
|
||||
@export(js_prefetchFromJS, .{ .name = "Bun__DNS__prefetch" });
|
||||
const js_getDNSCacheStats = JSC.toJSHostFunction(InternalDNS.getDNSCacheStats);
|
||||
@export(js_getDNSCacheStats, .{ .name = "Bun__DNSResolver__getCacheStats" });
|
||||
@export(js_getDNSCacheStats, .{ .name = "Bun__DNS__getCacheStats" });
|
||||
const js_newResolver = JSC.toJSHostFunction(newResolver);
|
||||
@export(js_newResolver, .{ .name = "Bun__DNSResolver__new" });
|
||||
}
|
||||
|
||||
@@ -35,24 +35,24 @@
|
||||
#include "GeneratedBunObject.h"
|
||||
#include <netdb.h>
|
||||
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNSResolver__lookup);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__lookup);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolve);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNSResolver__resolve);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNSResolver__resolveSrv);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNSResolver__resolveTxt);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNSResolver__resolveSoa);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNSResolver__resolveNaptr);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNSResolver__resolveMx);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNSResolver__resolveCaa);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNSResolver__resolveNs);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNSResolver__resolvePtr);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNSResolver__resolveCname);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolve);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolveSrv);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolveTxt);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolveSoa);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolveNaptr);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolveMx);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolveCaa);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolveNs);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolvePtr);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolveCname);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__getServers);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__setServers);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNSResolver__reverse);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNSResolver__lookupService);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNSResolver__prefetch);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNSResolver__getCacheStats);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__reverse);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__lookupService);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__prefetch);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__getCacheStats);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__DNSResolver__new);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__fetch);
|
||||
BUN_DECLARE_HOST_FUNCTION(Bun__fetchPreconnect);
|
||||
@@ -340,39 +340,39 @@ static JSValue constructDNSObject(VM& vm, JSObject* bunObject)
|
||||
{
|
||||
JSGlobalObject* globalObject = bunObject->globalObject();
|
||||
JSC::JSObject* dnsObject = JSC::constructEmptyObject(globalObject);
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "lookup"_s), 2, Bun__DNSResolver__lookup, ImplementationVisibility::Public, NoIntrinsic,
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "lookup"_s), 2, Bun__DNS__lookup, ImplementationVisibility::Public, NoIntrinsic,
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, vm.propertyNames->resolve, 2, Bun__DNS__resolve, ImplementationVisibility::Public, NoIntrinsic,
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveSrv"_s), 2, Bun__DNSResolver__resolveSrv, ImplementationVisibility::Public, NoIntrinsic,
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveSrv"_s), 2, Bun__DNS__resolveSrv, ImplementationVisibility::Public, NoIntrinsic,
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveTxt"_s), 2, Bun__DNSResolver__resolveTxt, ImplementationVisibility::Public, NoIntrinsic,
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveTxt"_s), 2, Bun__DNS__resolveTxt, ImplementationVisibility::Public, NoIntrinsic,
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveSoa"_s), 2, Bun__DNSResolver__resolveSoa, ImplementationVisibility::Public, NoIntrinsic,
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveSoa"_s), 2, Bun__DNS__resolveSoa, ImplementationVisibility::Public, NoIntrinsic,
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveNaptr"_s), 2, Bun__DNSResolver__resolveNaptr, ImplementationVisibility::Public, NoIntrinsic,
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveNaptr"_s), 2, Bun__DNS__resolveNaptr, ImplementationVisibility::Public, NoIntrinsic,
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveMx"_s), 2, Bun__DNSResolver__resolveMx, ImplementationVisibility::Public, NoIntrinsic,
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveMx"_s), 2, Bun__DNS__resolveMx, ImplementationVisibility::Public, NoIntrinsic,
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveCaa"_s), 2, Bun__DNSResolver__resolveCaa, ImplementationVisibility::Public, NoIntrinsic,
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveCaa"_s), 2, Bun__DNS__resolveCaa, ImplementationVisibility::Public, NoIntrinsic,
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveNs"_s), 2, Bun__DNSResolver__resolveNs, ImplementationVisibility::Public, NoIntrinsic,
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveNs"_s), 2, Bun__DNS__resolveNs, ImplementationVisibility::Public, NoIntrinsic,
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolvePtr"_s), 2, Bun__DNSResolver__resolvePtr, ImplementationVisibility::Public, NoIntrinsic,
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolvePtr"_s), 2, Bun__DNS__resolvePtr, ImplementationVisibility::Public, NoIntrinsic,
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveCname"_s), 2, Bun__DNSResolver__resolveCname, ImplementationVisibility::Public, NoIntrinsic,
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveCname"_s), 2, Bun__DNS__resolveCname, ImplementationVisibility::Public, NoIntrinsic,
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "getServers"_s), 2, Bun__DNS__getServers, ImplementationVisibility::Public, NoIntrinsic,
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "setServers"_s), 2, Bun__DNS__setServers, ImplementationVisibility::Public, NoIntrinsic,
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "reverse"_s), 2, Bun__DNSResolver__reverse, ImplementationVisibility::Public, NoIntrinsic,
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "reverse"_s), 2, Bun__DNS__reverse, ImplementationVisibility::Public, NoIntrinsic,
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "lookupService"_s), 2, Bun__DNSResolver__lookupService, ImplementationVisibility::Public, NoIntrinsic,
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "lookupService"_s), 2, Bun__DNS__lookupService, ImplementationVisibility::Public, NoIntrinsic,
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "prefetch"_s), 2, Bun__DNSResolver__prefetch, ImplementationVisibility::Public, NoIntrinsic,
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "prefetch"_s), 2, Bun__DNS__prefetch, ImplementationVisibility::Public, NoIntrinsic,
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "getCacheStats"_s), 0, Bun__DNSResolver__getCacheStats, ImplementationVisibility::Public, NoIntrinsic,
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "getCacheStats"_s), 0, Bun__DNS__getCacheStats, ImplementationVisibility::Public, NoIntrinsic,
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "newResolver"_s), 0, Bun__DNSResolver__new, ImplementationVisibility::Public, NoIntrinsic,
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
|
||||
@@ -17,6 +17,10 @@ export default [
|
||||
fn: "getServers",
|
||||
length: 0,
|
||||
},
|
||||
resolve: {
|
||||
fn: "resolve",
|
||||
length: 3,
|
||||
},
|
||||
},
|
||||
}),
|
||||
define({
|
||||
|
||||
@@ -155,8 +155,12 @@ var InternalResolver = class Resolver {
|
||||
|
||||
cancel() {}
|
||||
|
||||
#getResolver() {
|
||||
return this instanceof Resolver ? this.#resolver : dns;
|
||||
}
|
||||
|
||||
getServers() {
|
||||
return this.#resolver.getServers();
|
||||
return this.#getResolver().getServers();
|
||||
}
|
||||
|
||||
resolve(hostname, rrtype, callback) {
|
||||
@@ -171,22 +175,24 @@ var InternalResolver = class Resolver {
|
||||
throw $ERR_INVALID_ARG_TYPE("callback", "function", typeof callback);
|
||||
}
|
||||
|
||||
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(withTranslatedError(error));
|
||||
},
|
||||
);
|
||||
this.#getResolver()
|
||||
.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(withTranslatedError(error));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
resolve4(hostname, options, callback) {
|
||||
@@ -510,6 +516,9 @@ const promises = {
|
||||
return translateErrorCode(dns.lookup(hostname, { family: 6 }).then(promisifyResolveX));
|
||||
},
|
||||
|
||||
resolveAny(hostname) {
|
||||
return translateErrorCode(dns.resolveAny(hostname));
|
||||
},
|
||||
resolveSrv(hostname) {
|
||||
return translateErrorCode(dns.resolveSrv(hostname));
|
||||
},
|
||||
@@ -522,7 +531,6 @@ const promises = {
|
||||
resolveNaptr(hostname) {
|
||||
return translateErrorCode(dns.resolveNaptr(hostname));
|
||||
},
|
||||
|
||||
resolveMx(hostname) {
|
||||
return translateErrorCode(dns.resolveMx(hostname));
|
||||
},
|
||||
@@ -625,9 +633,6 @@ const promises = {
|
||||
setServers(servers) {}
|
||||
},
|
||||
};
|
||||
for (const key of ["resolveAny"]) {
|
||||
promises[key] = () => Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
// Compatibility with util.promisify(dns[method])
|
||||
for (const [method, pMethod] of [
|
||||
|
||||
Reference in New Issue
Block a user