Skip to content

Commit 56c8ff6

Browse files
mllkenEugeny
authored andcommitted
initial client support for unix sockets (direct-streamlocal)
1 parent a80fdba commit 56c8ff6

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

russh/src/client/mod.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ pub enum Msg {
168168
originator_port: u32,
169169
sender: UnboundedSender<ChannelMsg>,
170170
},
171+
ChannelOpenDirectStream {
172+
socket_path: String,
173+
sender: UnboundedSender<ChannelMsg>,
174+
},
171175
TcpIpForward {
172176
want_reply: bool,
173177
address: String,
@@ -416,6 +420,21 @@ impl<H: Handler> Handle<H> {
416420
self.wait_channel_confirmation(receiver).await
417421
}
418422

423+
pub async fn channel_open_direct_stream<S: Into<String>>(
424+
&self,
425+
socket_path: S,
426+
) -> Result<Channel<Msg>, crate::Error> {
427+
let (sender, receiver) = unbounded_channel();
428+
self.sender
429+
.send(Msg::ChannelOpenDirectStream {
430+
socket_path: socket_path.into(),
431+
sender,
432+
})
433+
.await
434+
.map_err(|_| crate::Error::SendError)?;
435+
self.wait_channel_confirmation(receiver).await
436+
}
437+
419438
pub async fn tcpip_forward<A: Into<String>>(
420439
&mut self,
421440
address: A,
@@ -779,6 +798,15 @@ impl Session {
779798
)?;
780799
self.channels.insert(id, sender);
781800
}
801+
Msg::ChannelOpenDirectStream {
802+
socket_path,
803+
sender,
804+
} => {
805+
let id = self.channel_open_direct_stream(
806+
&socket_path,
807+
)?;
808+
self.channels.insert(id, sender);
809+
}
782810
Msg::TcpIpForward {
783811
want_reply,
784812
address,

russh/src/client/session.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ impl Session {
7979
})
8080
}
8181

82+
pub fn channel_open_direct_stream(
83+
&mut self,
84+
socket_path: &str
85+
) -> Result<ChannelId, crate::Error> {
86+
self.channel_open_generic(b"direct-streamlocal@openssh.com", |write| {
87+
write.extend_ssh_string(socket_path.as_bytes());
88+
write.extend_ssh_string("".as_bytes()); // reserved
89+
write.push_u32_be(0); // reserved
90+
})
91+
}
92+
8293
#[allow(clippy::too_many_arguments)]
8394
pub fn request_pty(
8495
&mut self,

0 commit comments

Comments
 (0)