@@ -124,6 +124,10 @@ fn parse_alpn(alpn: &str) -> Result<Vec<u8>> {
124
124
125
125
#[ derive( Parser , Debug ) ]
126
126
pub struct ListenArgs {
127
+ /// Immediately close our sending side, indicating that we will not transmit any data
128
+ #[ clap( long) ]
129
+ pub recv_only : bool ,
130
+
127
131
#[ clap( flatten) ]
128
132
pub common : CommonArgs ,
129
133
}
@@ -157,6 +161,10 @@ pub struct ConnectArgs {
157
161
/// The node to connect to
158
162
pub ticket : NodeTicket ,
159
163
164
+ /// Immediately close our sending side, indicating that we will not transmit any data
165
+ #[ clap( long) ]
166
+ pub recv_only : bool ,
167
+
160
168
#[ clap( flatten) ]
161
169
pub common : CommonArgs ,
162
170
}
@@ -323,7 +331,11 @@ async fn listen_stdio(args: ListenArgs) -> Result<()> {
323
331
snafu:: ensure_whatever!( buf == dumbpipe:: HANDSHAKE , "invalid handshake" ) ;
324
332
}
325
333
tracing:: info!( "forwarding stdin/stdout to {}" , remote_node_id) ;
326
- forward_bidi ( tokio:: io:: stdin ( ) , tokio:: io:: stdout ( ) , r, s) . await ?;
334
+ if args. recv_only {
335
+ forward_bidi ( tokio:: io:: empty ( ) , tokio:: io:: stdout ( ) , r, s) . await ?;
336
+ } else {
337
+ forward_bidi ( tokio:: io:: stdin ( ) , tokio:: io:: stdout ( ) , r, s) . await ?;
338
+ }
327
339
// stop accepting connections after the first successful one
328
340
break ;
329
341
}
@@ -357,7 +369,11 @@ async fn connect_stdio(args: ConnectArgs) -> Result<()> {
357
369
s. write_all ( & dumbpipe:: HANDSHAKE ) . await . e ( ) ?;
358
370
}
359
371
tracing:: info!( "forwarding stdin/stdout to {}" , remote_node_id) ;
360
- forward_bidi ( tokio:: io:: stdin ( ) , tokio:: io:: stdout ( ) , r, s) . await ?;
372
+ if args. recv_only {
373
+ forward_bidi ( tokio:: io:: empty ( ) , tokio:: io:: stdout ( ) , r, s) . await ?;
374
+ } else {
375
+ forward_bidi ( tokio:: io:: stdin ( ) , tokio:: io:: stdout ( ) , r, s) . await ?;
376
+ }
361
377
tokio:: io:: stdout ( ) . flush ( ) . await . e ( ) ?;
362
378
Ok ( ( ) )
363
379
}
0 commit comments