cleanup
This commit is contained in:
+4
-2
@@ -65,7 +65,7 @@ async fn process_messages(
|
||||
let mut ping_interval =
|
||||
tokio::time::interval_at(Instant::now() + config.ping_interval, config.ping_interval);
|
||||
|
||||
let pong_timer = tokio::time::sleep(Duration::from_secs(0));
|
||||
let pong_timer = tokio::time::sleep(std::time::Duration::ZERO);
|
||||
tokio::pin!(pong_timer);
|
||||
let mut awaiting_pong = false;
|
||||
|
||||
@@ -88,7 +88,9 @@ async fn process_messages(
|
||||
return Err("Server did not respond to ping".into());
|
||||
}
|
||||
next_message = stream.next() => {
|
||||
if handle_stream_message(next_message, &outgoing_tx, config.max_output_bytes).await? {
|
||||
if handle_stream_message(next_message, &outgoing_tx, config.max_output_bytes)
|
||||
.await?
|
||||
{
|
||||
awaiting_pong = false;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -5,10 +5,10 @@ use tokio::{
|
||||
process::Command,
|
||||
};
|
||||
|
||||
pub async fn execute(command: &str, max_output_bytes: u64) -> (i32, String, String) {
|
||||
pub async fn execute(command_line: &str, max_output_bytes: u64) -> (i32, String, String) {
|
||||
let mut child = match Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg(command)
|
||||
.arg(command_line)
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.spawn()
|
||||
|
||||
@@ -21,11 +21,9 @@ impl Config {
|
||||
pub fn from_env() -> Result<Self, String> {
|
||||
let token = std::env::var("TOKEN")
|
||||
.map_err(|_| "TOKEN environment variable is required".to_string())?;
|
||||
|
||||
let device_id =
|
||||
std::env::var("DEVICE_ID").unwrap_or_else(|_| Self::DEFAULT_DEVICE_ID.to_string());
|
||||
validate_device_id(&device_id).map_err(|e| format!("Invalid DEVICE_ID: {e}"))?;
|
||||
|
||||
let base_url =
|
||||
std::env::var("BASE_URL").unwrap_or_else(|_| Self::DEFAULT_BASE_URL.to_string());
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ use crate::app::{config::Config, protocol::ClientMsg};
|
||||
pub type Socket =
|
||||
tokio_tungstenite::WebSocketStream<tokio_tungstenite::MaybeTlsStream<tokio::net::TcpStream>>;
|
||||
pub type SocketReader = SplitStream<Socket>;
|
||||
type SocketWriter = SplitSink<Socket, Message>;
|
||||
pub type SocketWriter = SplitSink<Socket, Message>;
|
||||
|
||||
pub enum OutgoingMessage {
|
||||
Application(ClientMsg),
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
pub mod client;
|
||||
pub mod command;
|
||||
pub mod config;
|
||||
pub mod connection;
|
||||
pub mod protocol;
|
||||
+7
-1
@@ -1,4 +1,10 @@
|
||||
mod app;
|
||||
mod app {
|
||||
pub mod client;
|
||||
pub mod command;
|
||||
pub mod config;
|
||||
pub mod connection;
|
||||
pub mod protocol;
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
|
||||
Reference in New Issue
Block a user