Skip to content

Commit 816c252

Browse files
committed
Use interprocess for synchronous pipes on Windows
See: <mid:O-HTpA2--3-9@dos.cafe> Signed-off-by: Wiktor Kwapisiewicz <wiktor@metacode.biz>
1 parent 9d49f17 commit 816c252

File tree

3 files changed

+46
-10
lines changed

3 files changed

+46
-10
lines changed

Cargo.lock

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,4 @@ secrecy = "0.8.0"
5757
retainer = "0.3.0"
5858
pgp = "0.12.0-alpha.3"
5959
chrono = "0.4.38"
60+
interprocess = "2.2.0"

examples/ssh-agent-client-blocking.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
mod extensions;
22

33
#[cfg(unix)]
4-
fn main() -> testresult::TestResult {
5-
use std::os::unix::net::UnixStream;
4+
use std::os::unix::net::UnixStream;
65

7-
use extensions::{DecryptIdentities, RequestDecryptIdentities};
8-
use ssh_agent_lib::{blocking::Client, proto::Extension};
6+
use extensions::{DecryptIdentities, RequestDecryptIdentities};
7+
#[cfg(windows)]
8+
use interprocess::os::windows::named_pipe::*;
9+
use ssh_agent_lib::{blocking::Client, proto::Extension};
910

10-
let mut client = Client::new(UnixStream::connect(std::env::var("SSH_AUTH_SOCK")?)?);
11+
fn main() -> testresult::TestResult {
12+
let socket = std::env::var("SSH_AUTH_SOCK")?;
13+
#[cfg(unix)]
14+
let mut client = Client::new(UnixStream::connect(socket)?);
15+
#[cfg(windows)]
16+
let mut client = Client::new(DuplexPipeStream::<pipe_mode::Bytes>::connect_by_path(
17+
socket,
18+
)?);
1119

1220
eprintln!(
1321
"Identities that this agent knows of: {:#?}",
@@ -25,8 +33,3 @@ fn main() -> testresult::TestResult {
2533

2634
Ok(())
2735
}
28-
29-
#[cfg(windows)]
30-
fn main() {
31-
eprintln!("Sadly, there are no high-quality sync named pipe crates as of 2024");
32-
}

0 commit comments

Comments
 (0)