Replace DISTANT_AUTH_KEY with DISTANT_KEY for environment variable parsing

pull/55/head
Chip Senkbeil 3 years ago
parent 3c15a90886
commit 2277f9634d
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -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

@ -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 <host> <port> <auth key>`
/// Converts to unprotected string that exposes the key in the form of
/// `DISTANT DATA <host> <port> <key>`
pub fn to_unprotected_string(&self) -> String {
format!(
"DISTANT DATA {} {} {}",

@ -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 <host> <port> <auth key>`
/// Session is in a file in the form of `DISTANT DATA <host> <port> <key>`
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 <host> <port> <auth key>`
/// in form of `DISTANT DATA <host> <port> <key>`
Pipe,
/// Special scenario where the session is not shared but is instead kept within the
@ -348,14 +348,14 @@ pub enum SessionInput {
///
/// * `DISTANT_HOST=<host>`
/// * `DISTANT_PORT=<port>`
/// * `DISTANT_AUTH_KEY=<auth key>`
/// * `DISTANT_KEY=<key>`
Environment,
/// Session is in a file in the form of `DISTANT DATA <host> <port> <auth key>`
/// Session is in a file in the form of `DISTANT DATA <host> <port> <key>`
File,
/// Session is stored and retrieved over anonymous pipes (stdout/stdin)
/// in form of `DISTANT DATA <host> <port> <auth key>`
/// in form of `DISTANT DATA <host> <port> <key>`
Pipe,
/// Session is stored and retrieved from the initializeOptions of the initialize request

@ -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
}
}

@ -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());

Loading…
Cancel
Save