| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 87c7106 commit 85af15a
5 files 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 | |
|---|---|---|---|
@@ -179,6 +179,7 @@ constexpr size_t kFsStatsBufferLength = | |||
| 179 | 179 | V(asn1curve_string, "asn1Curve") \ | |
| 180 | 180 | V(async_ids_stack_string, "async_ids_stack") \ | |
| 181 | 181 | V(bits_string, "bits") \ | |
| 182 | + V(block_list_string, "blockList") \ | ||
| 182 | 183 | V(buffer_string, "buffer") \ | |
| 183 | 184 | V(bytes_parsed_string, "bytesParsed") \ | |
| 184 | 185 | V(bytes_read_string, "bytesRead") \ | |
@@ -410,6 +411,7 @@ constexpr size_t kFsStatsBufferLength = | |||
| 410 | 411 | V(async_wrap_object_ctor_template, v8::FunctionTemplate) \ | |
| 411 | 412 | V(base_object_ctor_template, v8::FunctionTemplate) \ | |
| 412 | 413 | V(binding_data_ctor_template, v8::FunctionTemplate) \ | |
| 414 | + V(blocklist_instance_template, v8::ObjectTemplate) \ | ||
| 413 | 415 | V(compiled_fn_entry_template, v8::ObjectTemplate) \ | |
| 414 | 416 | V(dir_instance_template, v8::ObjectTemplate) \ | |
| 415 | 417 | 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 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments