diff --git a/Cargo.lock b/Cargo.lock index e3f1581..fadd6ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1030,7 +1030,7 @@ dependencies = [ [[package]] name = "playit-cli" -version = "0.15.19" +version = "0.15.20" dependencies = [ "clap", "crossterm", diff --git a/Cargo.toml b/Cargo.toml index dd9afb4..290082e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ members = [ ] [workspace.package] -version = "0.15.19" +version = "0.15.20" [workspace.dependencies] tokio = { version = "1.39", features = ["full"] } diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 99ab6ee..5d86f77 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -10,4 +10,4 @@ if [ -z "${SECRET_KEY}" ]; then fi fi -playit --secret "${SECRET_KEY}" run +playit -s --secret "${SECRET_KEY}" start diff --git a/linux/playit.service b/linux/playit.service index 182235b..1f16474 100644 --- a/linux/playit.service +++ b/linux/playit.service @@ -5,7 +5,7 @@ Wants=network-pre.target After=network-pre.target NetworkManager.service systemd-resolved.service [Service] -ExecStart=/opt/playit/playit --secret_wait --secret_path /etc/playit/playit.toml -l /var/log/playit/playit.log +ExecStart=/opt/playit/playit --secret_wait --secret_path /etc/playit/playit.toml -l /var/log/playit/playit.log start Restart=on-failure [Install] diff --git a/packages/agent_cli/src/main.rs b/packages/agent_cli/src/main.rs index 131468e..c2250a5 100644 --- a/packages/agent_cli/src/main.rs +++ b/packages/agent_cli/src/main.rs @@ -89,6 +89,9 @@ async fn main() -> Result { tokio::time::sleep(Duration::from_secs(1)).await; autorun(&mut ui, secret).await?; } + Some(("start", _)) => { + autorun(&mut ui, secret).await?; + } Some(("version", _)) => println!("{}", env!("CARGO_PKG_VERSION")), #[cfg(target_os = "linux")] Some(("setup", _)) => { @@ -179,7 +182,7 @@ async fn main() -> Result { _ => return Err(CliError::NotImplemented.into()) } Some(("run", m)) => { - let _ = tracing_subscriber::fmt().try_init(); + tracing::error!("run is depreciated and will be removed in a future version of the CLI"); let secret_key = secret.get().await?; let api = PlayitApi::create(API_BASE.to_string(), Some(secret_key.clone())); @@ -587,6 +590,10 @@ fn cli() -> Command { .arg(arg!(--wait "number of seconds to wait 0=infinite").default_value("0")) ) ) + .subcommand( + Command::new("start") + .about("Start the playit agent") + ) .subcommand( Command::new("tunnels") .subcommand_required(true) @@ -608,7 +615,7 @@ fn cli() -> Command { ) .subcommand( Command::new("run") - .about("Run the playit agent") + .about("(depreciated will be removed) Run the playit agent with manual port mappings") .arg(arg!([MAPPING_OVERRIDE] "(format \"=[:] [, ..]\")").required(false).value_delimiter(',')) ) .subcommand( diff --git a/packages/agent_cli/src/playit_secret.rs b/packages/agent_cli/src/playit_secret.rs index 700a409..adae2d1 100644 --- a/packages/agent_cli/src/playit_secret.rs +++ b/packages/agent_cli/src/playit_secret.rs @@ -64,11 +64,17 @@ impl PlayitSecret { pub async fn ensure_valid(&mut self, ui: &mut UI) -> Result<&mut Self, CliError> { let api = match self.create_api().await { Ok(v) => v, - Err(_) => { + Err(error) => { + if !self.allow_path_read { + tracing::warn!("invalid secret, not reading secret from path"); + return Err(error); + } + { let mut secret = self.secret.write().await; let _ = secret.take(); } + return Ok(self); } }; @@ -92,7 +98,7 @@ impl PlayitSecret { tokio::time::sleep(Duration::from_secs(3)).await; } Err(ApiErrorNoFail::ApiError(ApiResponseError::Auth(AuthError::InvalidAgentKey))) => { - if !self.path.is_some() { + if !self.path.is_some() || !self.allow_path_read { return Err(CliError::InvalidSecret); } diff --git a/packages/agent_core/src/agent_control/platform.rs b/packages/agent_core/src/agent_control/platform.rs index 1bcae03..f79f049 100644 --- a/packages/agent_core/src/agent_control/platform.rs +++ b/packages/agent_core/src/agent_control/platform.rs @@ -1,7 +1,7 @@ use crate::api::api::Platform; pub fn get_platform() -> Platform { - #[cfg(target_os = "window")] + #[cfg(target_os = "windows")] return Platform::Windows; #[cfg(target_os = "linux")] diff --git a/packages/agent_proto/src/control_messages.rs b/packages/agent_proto/src/control_messages.rs index 61630a8..b594d6d 100644 --- a/packages/agent_proto/src/control_messages.rs +++ b/packages/agent_proto/src/control_messages.rs @@ -1,3 +1,4 @@ +use std::fmt::Debug; use std::io::{Read, Write}; use std::net::SocketAddr; use std::sync::Arc; @@ -289,12 +290,21 @@ impl MessageEncoding for AgentPortMappingFound { } } -#[derive(Debug, Eq, PartialEq, Clone)] +#[derive(Eq, PartialEq, Clone)] pub struct UdpChannelDetails { pub tunnel_addr: SocketAddr, pub token: Arc>, } +impl Debug for UdpChannelDetails { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("UdpChannelDetails") + .field("tunnel_addr", &self.tunnel_addr) + .field("token", &hex::encode(&self.token[..])) + .finish() + } +} + impl MessageEncoding for UdpChannelDetails { fn write_to(&self, out: &mut T) -> std::io::Result { let mut sum = 0;