File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 1
1
use ssh2:: Channel ;
2
2
use std:: io:: prelude:: * ;
3
3
use std:: net:: { TcpListener , TcpStream } ;
4
+ use std:: os:: unix:: net:: UnixListener ;
4
5
use std:: thread;
5
6
6
7
/// Consume all available stdout and stderr data.
@@ -170,6 +171,29 @@ fn direct() {
170
171
t. join ( ) . ok ( ) . unwrap ( ) ;
171
172
}
172
173
174
+ #[ test]
175
+ fn direct_stream_local ( ) {
176
+ let d = tempfile:: tempdir ( ) . unwrap ( ) ;
177
+ let path = d. path ( ) . join ( "ssh2-rs-test.sock" ) ;
178
+ let a = UnixListener :: bind ( & path) . unwrap ( ) ;
179
+ let t = thread:: spawn ( move || {
180
+ let mut s = a. accept ( ) . unwrap ( ) . 0 ;
181
+ let mut b = [ 0 , 0 , 0 ] ;
182
+ s. read ( & mut b) . unwrap ( ) ;
183
+ assert_eq ! ( b, [ 1 , 2 , 3 ] ) ;
184
+ s. write_all ( & [ 4 , 5 , 6 ] ) . unwrap ( ) ;
185
+ } ) ;
186
+ let sess = :: authed_session ( ) ;
187
+ let mut channel = sess
188
+ . channel_direct_streamlocal ( path. to_str ( ) . unwrap ( ) , None )
189
+ . unwrap ( ) ;
190
+ channel. write_all ( & [ 1 , 2 , 3 ] ) . unwrap ( ) ;
191
+ let mut r = [ 0 , 0 , 0 ] ;
192
+ channel. read ( & mut r) . unwrap ( ) ;
193
+ assert_eq ! ( r, [ 4 , 5 , 6 ] ) ;
194
+ t. join ( ) . ok ( ) . unwrap ( ) ;
195
+ }
196
+
173
197
#[ test]
174
198
fn forward ( ) {
175
199
let sess = :: authed_session ( ) ;
You can’t perform that action at this time.
0 commit comments