diff --git a/doc/api/cli.md b/doc/api/cli.md index e9357fb1bee5c6..100c4554cfc31a 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -357,6 +357,57 @@ Error: Access to this API has been restricted } ``` +### `--allow-net-udp` + + + +> Stability: 1.1 - Active development + +When using the [Permission Model][], the process will not be able to create, +receive, and send UDP packages by default. Attempts to do so will throw an +`ERR_ACCESS_DENIED` unless the user explicitly passes the `--allow-net-udp` flag +when starting Node.js. + +The argument format is `--allow-net-udp=domain_or_ip[/netmask][:port]`. +The valid arguments are: + +* `*` - To allow all operations. +* `--allow-net-udp=nodejs.org` +* `--allow-net-udp=127.0.0.1` +* `--allow-net-udp=127.0.0.1:8888` +* `--allow-net-udp=127.0.0.1:*` +* `--allow-net-udp=*:9999` +* `--allow-net-udp=127.0.0.1/24:*` +* `--allow-net-udp=127.0.0.1/255.255.255.0:*` +* `--allow-net-udp=127.0.0.1:8080 --allow-net-udp=127.0.0.1:9090` +* `--allow-net-udp=127.0.0.1:8080,localhost:9090` + +Example: + +```js +const dgram = require('node:dgram'); +dgram.createSocket('udp4').bind(9297, '127.0.0.1') +``` + +```console +$ node --experimental-permission --allow-fs-read=./index.js index.js +node:events:498 + throw er; // Unhandled 'error' event + ^ + +Error [ERR_ACCESS_DENIED]: Access to this API has been restricted. Permission: bind to 127.0.0.1/9297 + at node:dgram:379:18 + at process.processTicksAndRejections (node:internal/process/task_queues:77:11) +Emitted 'error' event on Socket instance at: + at afterDns (node:dgram:337:12) + at node:dgram:379:9 + at process.processTicksAndRejections (node:internal/process/task_queues:77:11) { + code: 'ERR_ACCESS_DENIED' +} +``` + ### `--build-snapshot`