@@ -160,6 +160,16 @@ pub enum Msg {
160160 address : String ,
161161 port : u32 ,
162162 } ,
163+ StreamLocalForward {
164+ /// Provide a channel for the reply result to request a reply from the server
165+ reply_channel : Option < oneshot:: Sender < bool > > ,
166+ socket_path : String ,
167+ } ,
168+ CancelStreamLocalForward {
169+ /// Provide a channel for the reply result to request a reply from the server
170+ reply_channel : Option < oneshot:: Sender < bool > > ,
171+ socket_path : String ,
172+ } ,
163173 Close {
164174 id : ChannelId ,
165175 } ,
@@ -571,6 +581,7 @@ impl<H: Handler> Handle<H> {
571581 }
572582 }
573583
584+ // Requests the server to close a TCP/IP forward channel
574585 pub async fn cancel_tcpip_forward < A : Into < String > > (
575586 & self ,
576587 address : A ,
@@ -596,6 +607,54 @@ impl<H: Handler> Handle<H> {
596607 }
597608 }
598609
610+ // Requests the server to open a UDS forward channel
611+ pub async fn streamlocal_forward < A : Into < String > > (
612+ & mut self ,
613+ socket_path : A ,
614+ ) -> Result < ( ) , crate :: Error > {
615+ let ( reply_send, reply_recv) = oneshot:: channel ( ) ;
616+ self . sender
617+ . send ( Msg :: StreamLocalForward {
618+ reply_channel : Some ( reply_send) ,
619+ socket_path : socket_path. into ( ) ,
620+ } )
621+ . await
622+ . map_err ( |_| crate :: Error :: SendError ) ?;
623+
624+ match reply_recv. await {
625+ Ok ( true ) => Ok ( ( ) ) ,
626+ Ok ( false ) => Err ( crate :: Error :: RequestDenied ) ,
627+ Err ( e) => {
628+ error ! ( "Unable to receive StreamLocalForward result: {e:?}" ) ;
629+ Err ( crate :: Error :: Disconnect )
630+ }
631+ }
632+ }
633+
634+ // Requests the server to close a UDS forward channel
635+ pub async fn cancel_streamlocal_forward < A : Into < String > > (
636+ & self ,
637+ socket_path : A ,
638+ ) -> Result < ( ) , crate :: Error > {
639+ let ( reply_send, reply_recv) = oneshot:: channel ( ) ;
640+ self . sender
641+ . send ( Msg :: CancelStreamLocalForward {
642+ reply_channel : Some ( reply_send) ,
643+ socket_path : socket_path. into ( ) ,
644+ } )
645+ . await
646+ . map_err ( |_| crate :: Error :: SendError ) ?;
647+
648+ match reply_recv. await {
649+ Ok ( true ) => Ok ( ( ) ) ,
650+ Ok ( false ) => Err ( crate :: Error :: RequestDenied ) ,
651+ Err ( e) => {
652+ error ! ( "Unable to receive CancelStreamLocalForward result: {e:?}" ) ;
653+ Err ( crate :: Error :: Disconnect )
654+ }
655+ }
656+ }
657+
599658 /// Sends a disconnect message.
600659 pub async fn disconnect (
601660 & self ,
@@ -1050,6 +1109,14 @@ impl Session {
10501109 address,
10511110 port,
10521111 } => self . cancel_tcpip_forward ( reply_channel, & address, port) ,
1112+ Msg :: StreamLocalForward {
1113+ reply_channel,
1114+ socket_path,
1115+ } => self . streamlocal_forward ( reply_channel, & socket_path) ,
1116+ Msg :: CancelStreamLocalForward {
1117+ reply_channel,
1118+ socket_path,
1119+ } => self . cancel_streamlocal_forward ( reply_channel, & socket_path) ,
10531120 Msg :: Disconnect {
10541121 reason,
10551122 description,
@@ -1551,6 +1618,17 @@ pub trait Handler: Sized + Send {
15511618 Ok ( ( ) )
15521619 }
15531620
1621+ // Called when the server opens a channel for a new remote UDS forwarding connection
1622+ #[ allow( unused_variables) ]
1623+ async fn server_channel_open_forwarded_streamlocal (
1624+ & mut self ,
1625+ channel : Channel < Msg > ,
1626+ socket_path : & str ,
1627+ session : & mut Session ,
1628+ ) -> Result < ( ) , Self :: Error > {
1629+ Ok ( ( ) )
1630+ }
1631+
15541632 /// Called when the server opens an agent forwarding channel
15551633 #[ allow( unused_variables) ]
15561634 async fn server_channel_open_agent_forward (
0 commit comments