diff options
| author | JJ Liebig <jonathan.liebig@gmail.com> | 2026-09-08 23:08:42 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-09 00:08:42 +0300 |
| commit | 8996fc54fe4596368a1677821b1a390a70c56ab0 (patch) | |
| tree | 65ff0293a3ee17b4acc50539bff382388abaf927 /src/platform/unix_common.rs | |
| parent | 68c7b78ec237034cbb0e21c8666842ed7991641d (diff) | |
fix: support preinstalled windows remote hosts (#3661)
* fix: support windows hosts in saved ssh machines
refs #3651
* fix: keep windows ssh bridge writes blocking
refs #3651
* fix: close saved windows ssh bootstrap input
refs #3651
* refactor: simplify remote bridge helpers
refs #3651
* refactor: isolate remote bridge platform behavior
refs #3651
* fix: close captured ssh input under windows consoles
refs #3651
* test: remove redundant remote command assertions
refs #3651
refs #3701
* test: handle framed ssh commands in machine setup
refs #3651
---------
Co-authored-by: Ogulcan Celik <ogulcancelik@gmail.com>
Diffstat (limited to 'src/platform/unix_common.rs')
| -rw-r--r-- | src/platform/unix_common.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/platform/unix_common.rs b/src/platform/unix_common.rs index 0df215d6..756abc17 100644 --- a/src/platform/unix_common.rs +++ b/src/platform/unix_common.rs @@ -27,6 +27,38 @@ pub(crate) fn wait_client_stream_readable(stream: &crate::ipc::LocalStream) -> s Ok(()) } +pub(crate) fn forward_remote_bridge_stdio(stream: crate::ipc::LocalStream) -> std::io::Result<()> { + use interprocess::TryClone as _; + + let mut stdout = std::io::stdout().lock(); + let mut socket_to_stdout = stream.try_clone()?; + let mut stdin_to_socket = stream; + let _upload = std::thread::spawn(move || { + let mut stdin = std::io::stdin(); + let _ = copy_flush(&mut stdin, &mut stdin_to_socket); + let crate::ipc::LocalStream::UdSocket(stream) = stdin_to_socket; + let _ = stream.inner().shutdown(std::net::Shutdown::Write); + }); + copy_flush(&mut socket_to_stdout, &mut stdout) +} + +fn copy_flush<R: std::io::Read, W: std::io::Write>( + reader: &mut R, + writer: &mut W, +) -> std::io::Result<()> { + let mut buffer = [0_u8; 16 * 1024]; + loop { + let read = match reader.read(&mut buffer) { + Ok(0) => return Ok(()), + Ok(read) => read, + Err(err) if err.kind() == std::io::ErrorKind::Interrupted => continue, + Err(err) => return Err(err), + }; + writer.write_all(&buffer[..read])?; + writer.flush()?; + } +} + pub(crate) struct RemoteBridgeWake { reader: std::os::unix::net::UnixStream, writer: std::os::unix::net::UnixStream, |
