From 84c243576f2e010c120f22a457c136031509f2d8 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 22 Aug 2025 16:21:46 -0700 Subject: [PATCH] Minor remote server cleanup --- crates/remote/src/protocol.rs | 10 ++++++++++ crates/remote/src/ssh_session.rs | 8 +------- crates/remote_server/src/unix.rs | 15 +-------------- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/crates/remote/src/protocol.rs b/crates/remote/src/protocol.rs index e5a9c5b7a5..867a31b164 100644 --- a/crates/remote/src/protocol.rs +++ b/crates/remote/src/protocol.rs @@ -51,6 +51,16 @@ pub async fn write_message( Ok(()) } +pub async fn write_size_prefixed_buffer( + stream: &mut S, + buffer: &mut Vec, +) -> Result<()> { + let len = buffer.len() as u32; + stream.write_all(len.to_le_bytes().as_slice()).await?; + stream.write_all(buffer).await?; + Ok(()) +} + pub async fn read_message_raw( stream: &mut S, buffer: &mut Vec, diff --git a/crates/remote/src/ssh_session.rs b/crates/remote/src/ssh_session.rs index 22ba8b20a0..57b7aa3366 100644 --- a/crates/remote/src/ssh_session.rs +++ b/crates/remote/src/ssh_session.rs @@ -53,7 +53,7 @@ use util::{ }; #[derive(Clone)] -pub struct SshSocket { +struct SshSocket { connection_options: SshConnectionOptions, #[cfg(not(target_os = "windows"))] socket_path: PathBuf, @@ -1370,12 +1370,6 @@ impl ConnectionPool { } } -impl From for AnyProtoClient { - fn from(client: SshRemoteClient) -> Self { - AnyProtoClient::new(client.client) - } -} - #[async_trait(?Send)] trait RemoteConnection: Send + Sync { fn start_proxy( diff --git a/crates/remote_server/src/unix.rs b/crates/remote_server/src/unix.rs index b8a7351552..716350d065 100644 --- a/crates/remote_server/src/unix.rs +++ b/crates/remote_server/src/unix.rs @@ -762,34 +762,21 @@ where R: AsyncRead + Unpin, W: AsyncWrite + Unpin, { - use remote::protocol::read_message_raw; + use remote::protocol::{read_message_raw, write_size_prefixed_buffer}; let mut buffer = Vec::new(); loop { read_message_raw(&mut reader, &mut buffer) .await .with_context(|| format!("failed to read message from {}", socket_name))?; - write_size_prefixed_buffer(&mut writer, &mut buffer) .await .with_context(|| format!("failed to write message to {}", socket_name))?; - writer.flush().await?; - buffer.clear(); } } -async fn write_size_prefixed_buffer( - stream: &mut S, - buffer: &mut Vec, -) -> Result<()> { - let len = buffer.len() as u32; - stream.write_all(len.to_le_bytes().as_slice()).await?; - stream.write_all(buffer).await?; - Ok(()) -} - fn initialize_settings( session: AnyProtoClient, fs: Arc,