diff options
| author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-11-10 22:03:28 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-10 22:03:28 +0100 |
| commit | 8d5c0112fbbed188f97218ace2357feba3a8746f (patch) | |
| tree | cf08da990c8bf90da116e8db3ac6332cd37578a1 /ext/net/ops_unix.rs | |
| parent | 53e974b276b095faf52918c4c6e988e9d2788cef (diff) | |
feat: don't require --unstable flag for npm programs (#16520)
This PR adds copies of several unstable APIs that are available
in "Deno[Deno.internal].nodeUnstable" namespace.
These copies do not perform unstable check (ie. don't require
"--unstable" flag to be present). Otherwise they work exactly
the same, including permission checks.
These APIs are not meant to be used by users directly and
can change at any time.
Copies of following APIs are available in that namespace:
- Deno.spawnChild
- Deno.spawn
- Deno.spawnSync
- Deno.serve
- Deno.upgradeHttpRaw
- Deno.listenDatagram
Diffstat (limited to 'ext/net/ops_unix.rs')
| -rw-r--r-- | ext/net/ops_unix.rs | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/ext/net/ops_unix.rs b/ext/net/ops_unix.rs index b45b02343..bf03f4015 100644 --- a/ext/net/ops_unix.rs +++ b/ext/net/ops_unix.rs @@ -209,8 +209,7 @@ where Ok((rid, pathname)) } -#[op] -pub fn op_net_listen_unixpacket<NP>( +pub fn net_listen_unixpacket<NP>( state: &mut OpState, path: String, ) -> Result<(ResourceId, Option<String>), AnyError> @@ -218,7 +217,6 @@ where NP: NetPermissions + 'static, { let address_path = Path::new(&path); - super::check_unstable(state, "Deno.listenDatagram"); let permissions = state.borrow_mut::<NP>(); permissions.check_read(address_path, "Deno.listenDatagram()")?; permissions.check_write(address_path, "Deno.listenDatagram()")?; @@ -233,6 +231,29 @@ where Ok((rid, pathname)) } +#[op] +pub fn op_net_listen_unixpacket<NP>( + state: &mut OpState, + path: String, +) -> Result<(ResourceId, Option<String>), AnyError> +where + NP: NetPermissions + 'static, +{ + super::check_unstable(state, "Deno.listenDatagram"); + net_listen_unixpacket::<NP>(state, path) +} + +#[op] +pub fn op_node_unstable_net_listen_unixpacket<NP>( + state: &mut OpState, + path: String, +) -> Result<(ResourceId, Option<String>), AnyError> +where + NP: NetPermissions + 'static, +{ + net_listen_unixpacket::<NP>(state, path) +} + pub fn pathstring(pathname: &Path) -> Result<String, AnyError> { into_string(pathname.into()) } |
