From a6644f41257b0cf946978c8e3fbadc024fec4210 Mon Sep 17 00:00:00 2001 From: Lu Yang Date: Sat, 19 Oct 2024 09:25:08 +0100 Subject: [PATCH] add x11 support to ssh proxy --- lapdev-proxy-ssh/src/proxy.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lapdev-proxy-ssh/src/proxy.rs b/lapdev-proxy-ssh/src/proxy.rs index a2a603d..0b90600 100644 --- a/lapdev-proxy-ssh/src/proxy.rs +++ b/lapdev-proxy-ssh/src/proxy.rs @@ -233,6 +233,31 @@ impl russh::server::Handler for SshProxyHandler { Ok(true) } + + async fn channel_open_x11( + &mut self, + channel: Channel, + originator_address: &str, + originator_port: u32, + session: &mut Session, + ) -> Result { + let ws_session = self + .ws_session + .as_mut() + .ok_or_else(|| anyhow!("don't have ws session"))?; + let ws_channel = ws_session + .handle + .channel_open_x11(originator_address, originator_port) + .await?; + + let server_handle = session.handle(); + + tokio::spawn(async move { + let _ = forward_server_client(channel, ws_channel, server_handle).await; + }); + + Ok(true) + } } async fn forward_server_client(