From 54605697fa0fff69186fea638ef57b3ff297723b Mon Sep 17 00:00:00 2001 From: alphaleadership <47387699+alphaleadership@users.noreply.github.com> Date: Wed, 30 Apr 2025 16:05:39 +0200 Subject: [PATCH] net: update net.blocklist to allow file save and file management --- doc/api/net.md | 32 +++++++ lib/internal/blocklist.js | 126 +++++++++++++++++++++++++++- test/parallel/test-blocklist.js | 72 ++++++++++++++++ test/parallel/test-net-blocklist.js | 1 - 4 files changed, 229 insertions(+), 2 deletions(-) diff --git a/doc/api/net.md b/doc/api/net.md index 5b0a5dfee2e52f..ebab15ace61191 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -181,6 +181,38 @@ added: * `value` {any} Any JS value * Returns `true` if the `value` is a `net.BlockList`. +### `blockList.fromJSON(value)` + +> Stability: 1 - Experimental + + + +```js +const blockList = new net.BlockList(); +const data = [ + 'Subnet: IPv4 192.168.1.0/24', + 'Address: IPv4 10.0.0.5', + 'Range: IPv4 192.168.2.1-192.168.2.10', + 'Range: IPv4 10.0.0.1-10.0.0.10', +]; +blockList.fromJSON(data); +blockList.fromJSON(JSON.stringify(data)); +``` + +* `value` Blocklist.rules + +### `blockList.toJSON()` + +> Stability: 1 - Experimental + + + +* Returns Blocklist.rules + ## Class: `net.SocketAddress`