From 2277f9634d23325e734a524e57504d8265673204 Mon Sep 17 00:00:00 2001 From: Chip Senkbeil Date: Sat, 18 Sep 2021 21:49:21 -0500 Subject: [PATCH] Replace DISTANT_AUTH_KEY with DISTANT_KEY for environment variable parsing --- core/README.md | 2 +- core/src/client/session/info.rs | 8 ++++---- src/opt.rs | 10 +++++----- tests/cli/fixtures.rs | 8 ++++---- tests/cli/utils.rs | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/core/README.md b/core/README.md index 861d42b..eb6b1d1 100644 --- a/core/README.md +++ b/core/README.md @@ -47,7 +47,7 @@ use std::path::PathBuf; // // DISTANT_HOST = "..." // DISTANT_PORT = "..." -// DISTANT_AUTH_KEY = "..." +// DISTANT_KEY = "..." let mut session = Session::tcp_connect(SessionInfo::from_environment()?).await.unwrap(); // Send a request under a specific name and wait for a response diff --git a/core/src/client/session/info.rs b/core/src/client/session/info.rs index c71e83d..7c0ccb9 100644 --- a/core/src/client/session/info.rs +++ b/core/src/client/session/info.rs @@ -100,8 +100,8 @@ impl SessionInfo { let host = env::var("DISTANT_HOST").map_err(to_err)?; let port = env::var("DISTANT_PORT").map_err(to_err)?; - let auth_key = env::var("DISTANT_AUTH_KEY").map_err(to_err)?; - Ok(format!("DISTANT DATA {} {} {}", host, port, auth_key).parse()?) + let key = env::var("DISTANT_KEY").map_err(to_err)?; + Ok(format!("DISTANT DATA {} {} {}", host, port, key).parse()?) } /// Loads session from the next line available in this program's stdin @@ -137,8 +137,8 @@ impl SessionInfo { Ok(SocketAddr::from((addr, self.port))) } - /// Converts to unprotected string that exposes the auth key in the form of - /// `DISTANT DATA ` + /// Converts to unprotected string that exposes the key in the form of + /// `DISTANT DATA ` pub fn to_unprotected_string(&self) -> String { format!( "DISTANT DATA {} {} {}", diff --git a/src/opt.rs b/src/opt.rs index 24f70cf..733bb1c 100644 --- a/src/opt.rs +++ b/src/opt.rs @@ -297,7 +297,7 @@ impl FromStr for BindAddress { )] #[strum(serialize_all = "snake_case")] pub enum SessionOutput { - /// Session is in a file in the form of `DISTANT DATA ` + /// Session is in a file in the form of `DISTANT DATA ` File, /// Special scenario where the session is not shared but is instead kept within the @@ -306,7 +306,7 @@ pub enum SessionOutput { Keep, /// Session is stored and retrieved over anonymous pipes (stdout/stdin) - /// in form of `DISTANT DATA ` + /// in form of `DISTANT DATA ` Pipe, /// Special scenario where the session is not shared but is instead kept within the @@ -348,14 +348,14 @@ pub enum SessionInput { /// /// * `DISTANT_HOST=` /// * `DISTANT_PORT=` - /// * `DISTANT_AUTH_KEY=` + /// * `DISTANT_KEY=` Environment, - /// Session is in a file in the form of `DISTANT DATA ` + /// Session is in a file in the form of `DISTANT DATA ` File, /// Session is stored and retrieved over anonymous pipes (stdout/stdin) - /// in form of `DISTANT DATA ` + /// in form of `DISTANT DATA ` Pipe, /// Session is stored and retrieved from the initializeOptions of the initialize request diff --git a/tests/cli/fixtures.rs b/tests/cli/fixtures.rs index 09f1f23..609792d 100644 --- a/tests/cli/fixtures.rs +++ b/tests/cli/fixtures.rs @@ -10,7 +10,7 @@ const LOG_PATH: &str = "/tmp/test.distant.server.log"; /// Context for some listening distant server pub struct DistantServerCtx { pub addr: SocketAddr, - pub auth_key: String, + pub key: String, done_tx: mpsc::Sender<()>, } @@ -55,11 +55,11 @@ impl DistantServerCtx { }); // Extract our server startup data if we succeeded - let (port, auth_key) = started_rx.blocking_recv().unwrap().unwrap(); + let (port, key) = started_rx.blocking_recv().unwrap().unwrap(); Self { addr: SocketAddr::new(ip_addr, port), - auth_key, + key, done_tx, } } @@ -72,7 +72,7 @@ impl DistantServerCtx { .args(&["--session", "environment"]) .env("DISTANT_HOST", self.addr.ip().to_string()) .env("DISTANT_PORT", self.addr.port().to_string()) - .env("DISTANT_AUTH_KEY", self.auth_key.as_str()); + .env("DISTANT_KEY", self.key.as_str()); cmd } } diff --git a/tests/cli/utils.rs b/tests/cli/utils.rs index 683aa80..dd477d6 100644 --- a/tests/cli/utils.rs +++ b/tests/cli/utils.rs @@ -109,7 +109,7 @@ pub fn distant_subcommand(ctx: &DistantServerCtx, subcommand: &str) -> Command { .args(&["--session", "environment"]) .env("DISTANT_HOST", ctx.addr.ip().to_string()) .env("DISTANT_PORT", ctx.addr.port().to_string()) - .env("DISTANT_AUTH_KEY", ctx.auth_key.as_str()) + .env("DISTANT_KEY", ctx.key.as_str()) .stdin(Stdio::piped()) .stdout(Stdio::piped()) .stderr(Stdio::piped());