From c855c3e8ca5142e7b7f4a4e6adbf43e0ab18439b Mon Sep 17 00:00:00 2001 From: James M Snell Date: Tue, 11 Aug 2020 15:46:25 -0700 Subject: [PATCH] quic: use net.BlockList for limiting access to a QuicSocket PR-URL: https://github.com/nodejs/node/pull/34741 Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott --- doc/api/quic.md | 18 ++++++++++ lib/internal/quic/core.js | 11 ++++++ src/quic/node_quic_session.h | 2 +- src/quic/node_quic_socket.cc | 13 +++++++ src/quic/node_quic_socket.h | 1 + test/parallel/test-quic-blocklist.js | 52 ++++++++++++++++++++++++++++ 6 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-quic-blocklist.js diff --git a/doc/api/quic.md b/doc/api/quic.md index 84484357b72fb4..486c8ee6d6848e 100644 --- a/doc/api/quic.md +++ b/doc/api/quic.md @@ -1445,6 +1445,24 @@ error will be thrown if `quicsock.addEndpoint()` is called either after the `QuicSocket` has already started binding to the local ports, or after the `QuicSocket` has been destroyed. +#### `quicsocket.blockList` + + +* Type: {net.BlockList} + +A {net.BlockList} instance used to define rules for remote IPv4 or IPv6 +addresses that this `QuicSocket` is not permitted to interact with. The +rules can be specified as either specific individual addresses, ranges +of addresses, or CIDR subnet ranges. + +When listening as a server, if a packet is received from a blocked address, +the packet will be ignored. + +When connecting as a client, if the remote IP address is blocked, the +connection attempt will be rejected. + #### `quicsocket.bound`