@@ -1400,9 +1400,11 @@ int ReverseTraits::Parse(
14001400}
14011401
14021402namespace {
1403- template <class Wrap >
1403+ template <class Wrap , const char * name >
14041404static void Query (const FunctionCallbackInfo<Value>& args) {
14051405 Environment* env = Environment::GetCurrent (args);
1406+ THROW_IF_INSUFFICIENT_PERMISSIONS (
1407+ env, permission::PermissionScope::kNetDNS , name);
14061408 ChannelWrap* channel;
14071409 ASSIGN_OR_RETURN_UNWRAP (&channel, args.Holder ());
14081410
@@ -1568,7 +1570,8 @@ void CanonicalizeIP(const FunctionCallbackInfo<Value>& args) {
15681570
15691571void GetAddrInfo (const FunctionCallbackInfo<Value>& args) {
15701572 Environment* env = Environment::GetCurrent (args);
1571-
1573+ THROW_IF_INSUFFICIENT_PERMISSIONS (
1574+ env, permission::PermissionScope::kNetDNS , " lookup" );
15721575 CHECK (args[0 ]->IsObject ());
15731576 CHECK (args[1 ]->IsString ());
15741577 CHECK (args[2 ]->IsInt32 ());
@@ -1631,7 +1634,8 @@ void GetAddrInfo(const FunctionCallbackInfo<Value>& args) {
16311634
16321635void GetNameInfo (const FunctionCallbackInfo<Value>& args) {
16331636 Environment* env = Environment::GetCurrent (args);
1634-
1637+ THROW_IF_INSUFFICIENT_PERMISSIONS (
1638+ env, permission::PermissionScope::kNetDNS , " lookupService" );
16351639 CHECK (args[0 ]->IsObject ());
16361640 CHECK (args[1 ]->IsString ());
16371641 CHECK (args[2 ]->IsUint32 ());
@@ -1967,20 +1971,20 @@ void Initialize(Local<Object> target,
19671971 ChannelWrap::kInternalFieldCount );
19681972 channel_wrap->Inherit (AsyncWrap::GetConstructorTemplate (env));
19691973
1970- SetProtoMethod (isolate, channel_wrap, " queryAny" , Query<QueryAnyWrap>);
1971- SetProtoMethod (isolate, channel_wrap, " queryA" , Query<QueryAWrap>);
1972- SetProtoMethod (isolate, channel_wrap, " queryAaaa" , Query<QueryAaaaWrap>);
1973- SetProtoMethod (isolate, channel_wrap, " queryCaa" , Query<QueryCaaWrap>);
1974- SetProtoMethod (isolate, channel_wrap, " queryCname" , Query<QueryCnameWrap>);
1975- SetProtoMethod (isolate, channel_wrap, " queryMx" , Query<QueryMxWrap>);
1976- SetProtoMethod (isolate, channel_wrap, " queryNs" , Query<QueryNsWrap>);
1977- SetProtoMethod (isolate, channel_wrap, " queryTxt" , Query<QueryTxtWrap>);
1978- SetProtoMethod (isolate, channel_wrap, " querySrv" , Query<QuerySrvWrap>);
1979- SetProtoMethod (isolate, channel_wrap, " queryPtr" , Query<QueryPtrWrap>);
1980- SetProtoMethod (isolate, channel_wrap, " queryNaptr" , Query<QueryNaptrWrap>);
1981- SetProtoMethod (isolate, channel_wrap, " querySoa" , Query<QuerySoaWrap>);
1974+ SetProtoMethod (isolate, channel_wrap, " queryAny" , Query<QueryAnyWrap, AnyTraits::name >);
1975+ SetProtoMethod (isolate, channel_wrap, " queryA" , Query<QueryAWrap, ATraits::name >);
1976+ SetProtoMethod (isolate, channel_wrap, " queryAaaa" , Query<QueryAaaaWrap, AaaaTraits::name >);
1977+ SetProtoMethod (isolate, channel_wrap, " queryCaa" , Query<QueryCaaWrap, CaaTraits::name >);
1978+ SetProtoMethod (isolate, channel_wrap, " queryCname" , Query<QueryCnameWrap, CnameTraits::name >);
1979+ SetProtoMethod (isolate, channel_wrap, " queryMx" , Query<QueryMxWrap, MxTraits::name >);
1980+ SetProtoMethod (isolate, channel_wrap, " queryNs" , Query<QueryNsWrap, NsTraits::name >);
1981+ SetProtoMethod (isolate, channel_wrap, " queryTxt" , Query<QueryTxtWrap, TxtTraits::name >);
1982+ SetProtoMethod (isolate, channel_wrap, " querySrv" , Query<QuerySrvWrap, SrvTraits::name >);
1983+ SetProtoMethod (isolate, channel_wrap, " queryPtr" , Query<QueryPtrWrap, PtrTraits::name >);
1984+ SetProtoMethod (isolate, channel_wrap, " queryNaptr" , Query<QueryNaptrWrap, NaptrTraits::name >);
1985+ SetProtoMethod (isolate, channel_wrap, " querySoa" , Query<QuerySoaWrap, SoaTraits::name >);
19821986 SetProtoMethod (
1983- isolate, channel_wrap, " getHostByAddr" , Query<GetHostByAddrWrap>);
1987+ isolate, channel_wrap, " getHostByAddr" , Query<GetHostByAddrWrap, ReverseTraits::name >);
19841988
19851989 SetProtoMethodNoSideEffect (isolate, channel_wrap, " getServers" , GetServers);
19861990 SetProtoMethod (isolate, channel_wrap, " setServers" , SetServers);
0 commit comments