@@ -189,6 +189,50 @@ object. Each rate limiter has a corresponding counter
189189were dropped. A non-zero value indicates the rate limiter is actively
190190protecting the endpoint.
191191
192+ #### Block lists
193+
194+ Endpoints can filter incoming packets by source address using a
195+ [ ` net.BlockList ` ] [ ] . The block list is checked before any QUIC processing
196+ occurs, so blocked packets consume no resources beyond the check itself.
197+
198+ In ** deny** mode (the default), packets from addresses in the list are dropped:
199+
200+ ``` mjs
201+ import { BlockList } from ' node:net' ;
202+ import { listen } from ' node:quic' ;
203+
204+ const blocked = new BlockList ();
205+ blocked .addSubnet (' 192.168.1.0' , 24 ); // Block an entire subnet
206+ blocked .addAddress (' 10.0.0.5' ); // Block a specific address
207+
208+ const endpoint = await listen (onSession, {
209+ endpoint: {
210+ blockList: blocked,
211+ blockListPolicy: ' deny' ,
212+ },
213+ // ...
214+ });
215+ ```
216+
217+ In ** allow** mode, only packets from addresses in the list are accepted:
218+
219+ ``` mjs
220+ const trusted = new BlockList ();
221+ trusted .addSubnet (' 10.0.0.0' , 8 );
222+
223+ const endpoint = await listen (onSession, {
224+ endpoint: {
225+ blockList: trusted,
226+ blockListPolicy: ' allow' ,
227+ },
228+ // ...
229+ });
230+ ```
231+
232+ The block list is evaluated live — rules added or removed after the endpoint
233+ is created take effect immediately. The ` endpoint.stats.packetsBlocked `
234+ counter tracks how many packets have been dropped by the filter.
235+
192236### Applications
193237
194238Every ` QuicSession ` is associated with a single application protocol, negotiated
@@ -851,6 +895,11 @@ added: v23.8.0
851895 per-host rate limiter. Read only. A non-zero value indicates one or more
852896 remote addresses are creating sessions faster than the configured rate allows.
853897
898+ ### ` endpointStats.packetsBlocked `
899+
900+ * Type: {bigint} The total number of incoming packets dropped by the
901+ block list filter. Read only.
902+
854903## Class: ` QuicSession `
855904
856905<!-- YAML
@@ -2449,6 +2498,34 @@ added: v23.8.0
24492498
24502499If not specified the endpoint will bind to IPv4 ` localhost ` on a random port.
24512500
2501+ #### ` endpointOptions.blockList `
2502+
2503+ * Type: {net.BlockList}
2504+
2505+ An optional [ ` net.BlockList ` ] [ ] instance for filtering incoming packets by
2506+ source address. When configured, every received UDP packet is checked against
2507+ the block list before any QUIC processing occurs, minimizing resource
2508+ expenditure on blocked sources. The block list is evaluated live — rules
2509+ added to the ` BlockList ` object after the endpoint is created take effect
2510+ immediately.
2511+
2512+ See [ ` endpointOptions.blockListPolicy ` ] [ ] for how matches are interpreted.
2513+
2514+ #### ` endpointOptions.blockListPolicy `
2515+
2516+ * Type: {string} One of ` 'deny' ` or ` 'allow' ` .
2517+ * ** Default:** ` 'deny' `
2518+
2519+ Controls how the [ ` endpointOptions.blockList ` ] [ ] is interpreted:
2520+
2521+ * ` 'deny' ` — Packets from addresses matching the block list are dropped.
2522+ All other addresses are accepted. This is the typical blocklist mode.
2523+ * ` 'allow' ` — Only packets from addresses matching the block list are
2524+ accepted. All other addresses are dropped. This is an allowlist mode
2525+ for restricting access to known clients.
2526+
2527+ If no block list is configured, this option has no effect.
2528+
24522529#### ` endpointOptions.addressLRUSize `
24532530
24542531<!-- YAML
@@ -4303,6 +4380,8 @@ throughput issues caused by flow control.
43034380[`endpoint.busy`]: #endpointbusy
43044381[`endpoint.maxConnectionsPerHost`]: #endpointmaxconnectionsperhost
43054382[`endpoint.maxConnectionsTotal`]: #endpointmaxconnectionstotal
4383+ [`endpointOptions.blockListPolicy`]: #endpointoptionsblocklistpolicy
4384+ [`endpointOptions.blockList`]: #endpointoptionsblocklist
43064385[`endpointOptions.immediateCloseBurst`]: #endpointoptionsimmediatecloseburst
43074386[`endpointOptions.immediateCloseRate`]: #endpointoptionsimmediatecloserate
43084387[`endpointOptions.retryBurst`]: #endpointoptionsretryburst
@@ -4316,6 +4395,7 @@ throughput issues caused by flow control.
43164395[`error.errorCode`]: #errorerrorcode
43174396[`fs.promises.open(path, ' r' )`]: fs.md#fspromisesopenpath-flags-mode
43184397[`maxDatagramFrameSize`]: #transportparamsmaxdatagramframesize
4398+ [`net.BlockList`]: net.md#class-netblocklist
43194399[`quic.connect()`]: #quicconnectaddress-options
43204400[`quic.listen()`]: #quiclistenonsession-options
43214401[`session.close()`]: #sessioncloseoptions
0 commit comments