File tree Expand file tree Collapse file tree 5 files changed +25
-2
lines changed Expand file tree Collapse file tree 5 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -26,8 +26,13 @@ const {
2626} = require ( 'internal/errors' ) . codes ;
2727
2828class BlockList {
29- constructor ( ) {
30- this [ kHandle ] = new BlockListHandle ( ) ;
29+ constructor ( handle = new BlockListHandle ( ) ) {
30+ // The handle argument is an intentionally undocumented
31+ // internal API. User code will not be able to create
32+ // a BlockListHandle object directly.
33+ if ( ! ( handle instanceof BlockListHandle ) )
34+ throw new ERR_INVALID_ARG_TYPE ( 'handle' , 'BlockListHandle' , handle ) ;
35+ this [ kHandle ] = handle ;
3136 this [ kHandle ] [ owner_symbol ] = this ;
3237 }
3338
Original file line number Diff line number Diff line change @@ -179,6 +179,7 @@ constexpr size_t kFsStatsBufferLength =
179179 V (asn1curve_string, " asn1Curve" ) \
180180 V (async_ids_stack_string, " async_ids_stack" ) \
181181 V (bits_string, " bits" ) \
182+ V (block_list_string, " blockList" ) \
182183 V (buffer_string, " buffer" ) \
183184 V (bytes_parsed_string, " bytesParsed" ) \
184185 V (bytes_read_string, " bytesRead" ) \
@@ -410,6 +411,7 @@ constexpr size_t kFsStatsBufferLength =
410411 V (async_wrap_object_ctor_template, v8::FunctionTemplate) \
411412 V (base_object_ctor_template, v8::FunctionTemplate) \
412413 V (binding_data_ctor_template, v8::FunctionTemplate) \
414+ V (blocklist_instance_template, v8::ObjectTemplate) \
413415 V (compiled_fn_entry_template, v8::ObjectTemplate) \
414416 V (dir_instance_template, v8::ObjectTemplate) \
415417 V (fd_constructor_template, v8::ObjectTemplate) \
Original file line number Diff line number Diff line change @@ -524,6 +524,19 @@ SocketAddressBlockListWrap::SocketAddressBlockListWrap(
524524 MakeWeak ();
525525}
526526
527+ BaseObjectPtr<SocketAddressBlockListWrap> SocketAddressBlockListWrap::New (
528+ Environment* env) {
529+ Local<Object> obj;
530+ if (!env->blocklist_instance_template ()
531+ ->NewInstance (env->context ()).ToLocal (&obj)) {
532+ return {};
533+ }
534+ BaseObjectPtr<SocketAddressBlockListWrap> wrap =
535+ MakeDetachedBaseObject<SocketAddressBlockListWrap>(env, obj);
536+ CHECK (wrap);
537+ return wrap;
538+ }
539+
527540void SocketAddressBlockListWrap::New (
528541 const FunctionCallbackInfo<Value>& args) {
529542 CHECK (args.IsConstructCall ());
@@ -673,6 +686,7 @@ void SocketAddressBlockListWrap::Initialize(
673686 env->SetProtoMethod (t, " check" , SocketAddressBlockListWrap::Check);
674687 env->SetProtoMethod (t, " getRules" , SocketAddressBlockListWrap::GetRules);
675688
689+ env->set_blocklist_instance_template (t->InstanceTemplate ());
676690 target->Set (env->context (), name,
677691 t->GetFunction (env->context ()).ToLocalChecked ()).FromJust ();
678692
Original file line number Diff line number Diff line change @@ -280,6 +280,7 @@ class SocketAddressBlockListWrap :
280280 v8::Local<v8::Context> context,
281281 void * priv);
282282
283+ static BaseObjectPtr<SocketAddressBlockListWrap> New (Environment* env);
283284 static void New (const v8::FunctionCallbackInfo<v8::Value>& args);
284285 static void AddAddress (const v8::FunctionCallbackInfo<v8::Value>& args);
285286 static void AddRange (const v8::FunctionCallbackInfo<v8::Value>& args);
Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ const customTypesMap = {
122122 'require' : 'modules.html#modules_require_id' ,
123123
124124 'Handle' : 'net.html#net_server_listen_handle_backlog_callback' ,
125+ 'net.BlockList' : 'net.html#net_class_net_blocklist' ,
125126 'net.Server' : 'net.html#net_class_net_server' ,
126127 'net.Socket' : 'net.html#net_class_net_socket' ,
127128
You can’t perform that action at this time.
0 commit comments