Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ fn parse_alpn(alpn: &str) -> Result<Vec<u8>> {

#[derive(Parser, Debug)]
pub struct ListenArgs {
/// Immediately close our sending side, indicating that we will not transmit any data
#[clap(long)]
pub recv_only: bool,

#[clap(flatten)]
pub common: CommonArgs,
}
Expand Down Expand Up @@ -157,6 +161,10 @@ pub struct ConnectArgs {
/// The node to connect to
pub ticket: NodeTicket,

/// Immediately close our sending side, indicating that we will not transmit any data
#[clap(long)]
pub recv_only: bool,

#[clap(flatten)]
pub common: CommonArgs,
}
Expand Down Expand Up @@ -323,7 +331,11 @@ async fn listen_stdio(args: ListenArgs) -> Result<()> {
snafu::ensure_whatever!(buf == dumbpipe::HANDSHAKE, "invalid handshake");
}
tracing::info!("forwarding stdin/stdout to {}", remote_node_id);
forward_bidi(tokio::io::stdin(), tokio::io::stdout(), r, s).await?;
if args.recv_only {
forward_bidi(tokio::io::empty(), tokio::io::stdout(), r, s).await?;
} else {
forward_bidi(tokio::io::stdin(), tokio::io::stdout(), r, s).await?;
}
// stop accepting connections after the first successful one
break;
}
Expand Down Expand Up @@ -357,7 +369,11 @@ async fn connect_stdio(args: ConnectArgs) -> Result<()> {
s.write_all(&dumbpipe::HANDSHAKE).await.e()?;
}
tracing::info!("forwarding stdin/stdout to {}", remote_node_id);
forward_bidi(tokio::io::stdin(), tokio::io::stdout(), r, s).await?;
if args.recv_only {
forward_bidi(tokio::io::empty(), tokio::io::stdout(), r, s).await?;
} else {
forward_bidi(tokio::io::stdin(), tokio::io::stdout(), r, s).await?;
}
tokio::io::stdout().flush().await.e()?;
Ok(())
}
Expand Down
Loading