File tree 5 files changed +25
-2
lines changed
5 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -26,8 +26,13 @@ const {
26
26
} = require ( 'internal/errors' ) . codes ;
27
27
28
28
class 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 ;
31
36
this [ kHandle ] [ owner_symbol ] = this ;
32
37
}
33
38
Original file line number Diff line number Diff line change @@ -182,6 +182,7 @@ constexpr size_t kFsStatsBufferLength =
182
182
V (asn1curve_string, " asn1Curve" ) \
183
183
V (async_ids_stack_string, " async_ids_stack" ) \
184
184
V (bits_string, " bits" ) \
185
+ V (block_list_string, " blockList" ) \
185
186
V (buffer_string, " buffer" ) \
186
187
V (bytes_parsed_string, " bytesParsed" ) \
187
188
V (bytes_read_string, " bytesRead" ) \
@@ -423,6 +424,7 @@ constexpr size_t kFsStatsBufferLength =
423
424
V (async_wrap_object_ctor_template, v8::FunctionTemplate) \
424
425
V (base_object_ctor_template, v8::FunctionTemplate) \
425
426
V (binding_data_ctor_template, v8::FunctionTemplate) \
427
+ V (blocklist_instance_template, v8::ObjectTemplate) \
426
428
V (compiled_fn_entry_template, v8::ObjectTemplate) \
427
429
V (dir_instance_template, v8::ObjectTemplate) \
428
430
V (fd_constructor_template, v8::ObjectTemplate) \
Original file line number Diff line number Diff line change @@ -524,6 +524,19 @@ SocketAddressBlockListWrap::SocketAddressBlockListWrap(
524
524
MakeWeak ();
525
525
}
526
526
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
+
527
540
void SocketAddressBlockListWrap::New (
528
541
const FunctionCallbackInfo<Value>& args) {
529
542
CHECK (args.IsConstructCall ());
@@ -673,6 +686,7 @@ void SocketAddressBlockListWrap::Initialize(
673
686
env->SetProtoMethod (t, " check" , SocketAddressBlockListWrap::Check);
674
687
env->SetProtoMethod (t, " getRules" , SocketAddressBlockListWrap::GetRules);
675
688
689
+ env->set_blocklist_instance_template (t->InstanceTemplate ());
676
690
target->Set (env->context (), name,
677
691
t->GetFunction (env->context ()).ToLocalChecked ()).FromJust ();
678
692
Original file line number Diff line number Diff line change @@ -280,6 +280,7 @@ class SocketAddressBlockListWrap :
280
280
v8::Local<v8::Context> context,
281
281
void * priv);
282
282
283
+ static BaseObjectPtr<SocketAddressBlockListWrap> New (Environment* env);
283
284
static void New (const v8::FunctionCallbackInfo<v8::Value>& args);
284
285
static void AddAddress (const v8::FunctionCallbackInfo<v8::Value>& args);
285
286
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 = {
122
122
'require' : 'modules.html#modules_require_id' ,
123
123
124
124
'Handle' : 'net.html#net_server_listen_handle_backlog_callback' ,
125
+ 'net.BlockList' : 'net.html#net_class_net_blocklist' ,
125
126
'net.Server' : 'net.html#net_class_net_server' ,
126
127
'net.Socket' : 'net.html#net_class_net_socket' ,
127
128
You can’t perform that action at this time.
0 commit comments