summaryrefslogtreecommitdiff
path: root/cli/ops/tls.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-09-20 01:17:35 +0200
committerGitHub <noreply@github.com>2020-09-20 01:17:35 +0200
commitb657d743a22802b8232fbf558f2f00bf2942096f (patch)
treee3a3047e78b6bd9c9e3f551f99f5e80e32de079d /cli/ops/tls.rs
parentaaa5e6613a739f8e2ff7579b69c2504bcdc37d4f (diff)
refactor: remove CliState, use OpState, add CliModuleLoader (#7588)
- remove "CliState.workers" and "CliState.next_worker_id", instead store them on "OpState" using type aliases. - remove "CliState.global_timer" and "CliState.start_time", instead store them on "OpState" using type aliases. - remove "CliState.is_internal", instead pass it to Worker::new - move "CliState::permissions" to "OpState" - move "CliState::main_module" to "OpState" - move "CliState::global_state" to "OpState" - move "CliState::check_unstable()" to "GlobalState" - change "cli_state()" to "global_state()" - change "deno_core::ModuleLoader" trait to pass "OpState" to callbacks - rename "CliState" to "CliModuleLoader"
Diffstat (limited to 'cli/ops/tls.rs')
-rw-r--r--cli/ops/tls.rs24
1 files changed, 14 insertions, 10 deletions
diff --git a/cli/ops/tls.rs b/cli/ops/tls.rs
index 38b18077d..448e33a9d 100644
--- a/cli/ops/tls.rs
+++ b/cli/ops/tls.rs
@@ -1,6 +1,7 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
use super::io::{StreamResource, StreamResourceHolder};
+use crate::permissions::Permissions;
use crate::resolve_addr::resolve_addr;
use deno_core::error::bad_resource;
use deno_core::error::bad_resource_id;
@@ -72,11 +73,13 @@ async fn op_start_tls(
domain.push_str("localhost");
}
{
- let cli_state = super::cli_state2(&state);
+ let cli_state = super::global_state2(&state);
cli_state.check_unstable("Deno.startTls");
- cli_state.check_net(&domain, 0)?;
+ let s = state.borrow();
+ let permissions = s.borrow::<Permissions>();
+ permissions.check_net(&domain, 0)?;
if let Some(path) = cert_file.clone() {
- cli_state.check_read(Path::new(&path))?;
+ permissions.check_read(Path::new(&path))?;
}
}
let mut resource_holder = {
@@ -143,10 +146,11 @@ async fn op_connect_tls(
let args: ConnectTLSArgs = serde_json::from_value(args)?;
let cert_file = args.cert_file.clone();
{
- let cli_state = super::cli_state2(&state);
- cli_state.check_net(&args.hostname, args.port)?;
+ let s = state.borrow();
+ let permissions = s.borrow::<Permissions>();
+ permissions.check_net(&args.hostname, args.port)?;
if let Some(path) = cert_file.clone() {
- cli_state.check_read(Path::new(&path))?;
+ permissions.check_read(Path::new(&path))?;
}
}
let mut domain = args.hostname.clone();
@@ -318,10 +322,10 @@ fn op_listen_tls(
let cert_file = args.cert_file;
let key_file = args.key_file;
{
- let cli_state = super::cli_state(state);
- cli_state.check_net(&args.hostname, args.port)?;
- cli_state.check_read(Path::new(&cert_file))?;
- cli_state.check_read(Path::new(&key_file))?;
+ let permissions = state.borrow::<Permissions>();
+ permissions.check_net(&args.hostname, args.port)?;
+ permissions.check_read(Path::new(&cert_file))?;
+ permissions.check_read(Path::new(&key_file))?;
}
let mut config = ServerConfig::new(NoClientAuth::new());
config