diff options
Diffstat (limited to 'runtime/ops/net.rs')
-rw-r--r-- | runtime/ops/net.rs | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/runtime/ops/net.rs b/runtime/ops/net.rs index 4c38d2293..934ff7926 100644 --- a/runtime/ops/net.rs +++ b/runtime/ops/net.rs @@ -224,8 +224,8 @@ async fn op_datagram_send( transport_args: ArgsEnum::Ip(args), } if transport == "udp" => { { - let s = state.borrow(); - s.borrow::<Permissions>() + let mut s = state.borrow_mut(); + s.borrow_mut::<Permissions>() .net .check(&(&args.hostname, Some(args.port)))?; } @@ -251,8 +251,8 @@ async fn op_datagram_send( } if transport == "unixpacket" => { let address_path = Path::new(&args.path); { - let s = state.borrow(); - s.borrow::<Permissions>().write.check(&address_path)?; + let mut s = state.borrow_mut(); + s.borrow_mut::<Permissions>().write.check(&address_path)?; } let resource = state .borrow() @@ -289,9 +289,9 @@ async fn op_connect( transport_args: ArgsEnum::Ip(args), } if transport == "tcp" => { { - let state_ = state.borrow(); + let mut state_ = state.borrow_mut(); state_ - .borrow::<Permissions>() + .borrow_mut::<Permissions>() .net .check(&(&args.hostname, Some(args.port)))?; } @@ -327,9 +327,15 @@ async fn op_connect( let address_path = Path::new(&args.path); super::check_unstable2(&state, "Deno.connect"); { - let state_ = state.borrow(); - state_.borrow::<Permissions>().read.check(&address_path)?; - state_.borrow::<Permissions>().write.check(&address_path)?; + let mut state_ = state.borrow_mut(); + state_ + .borrow_mut::<Permissions>() + .read + .check(&address_path)?; + state_ + .borrow_mut::<Permissions>() + .write + .check(&address_path)?; } let path = args.path; let unix_stream = net_unix::UnixStream::connect(Path::new(&path)).await?; @@ -443,7 +449,6 @@ fn op_listen( args: ListenArgs, _zero_copy: Option<ZeroCopyBuf>, ) -> Result<OpConn, AnyError> { - let permissions = state.borrow::<Permissions>(); match args { ListenArgs { transport, @@ -453,7 +458,10 @@ fn op_listen( if transport == "udp" { super::check_unstable(state, "Deno.listenDatagram"); } - permissions.net.check(&(&args.hostname, Some(args.port)))?; + state + .borrow_mut::<Permissions>() + .net + .check(&(&args.hostname, Some(args.port)))?; } let addr = resolve_addr_sync(&args.hostname, args.port)? .next() @@ -497,6 +505,7 @@ fn op_listen( if transport == "unixpacket" { super::check_unstable(state, "Deno.listenDatagram"); } + let permissions = state.borrow_mut::<Permissions>(); permissions.read.check(&address_path)?; permissions.write.check(&address_path)?; } @@ -604,8 +613,8 @@ async fn op_dns_resolve( }; { - let s = state.borrow(); - let perm = s.borrow::<Permissions>(); + let mut s = state.borrow_mut(); + let perm = s.borrow_mut::<Permissions>(); // Checks permission against the name servers which will be actually queried. for ns in config.name_servers() { |