From 3342bb339fff6149b7b2b3a567687c74d90f608c Mon Sep 17 00:00:00 2001 From: JyJyJcr <82190170+JyJyJcr@users.noreply.github.com> Date: Tue, 13 Feb 2024 23:23:56 +0900 Subject: [PATCH 1/3] feat: specify addr of ssh server --- src/server.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/server.rs b/src/server.rs index 71e5acb..d8dd969 100644 --- a/src/server.rs +++ b/src/server.rs @@ -13,6 +13,9 @@ pub struct Opt { /// Address to listen on #[clap(long = "listen", short = 'l', default_value = "0.0.0.0:4433")] listen: SocketAddr, + /// Address of the ssh server + #[clap(long = "proxy-for", short = 'p', default_value = "127.0.0.1:22")] + proxy_for: SocketAddr, } /// Returns default server configuration along with its certificate. @@ -65,14 +68,14 @@ pub async fn run(options: Opt) -> Result<(), Box> { conn.remote_address() ); tokio::spawn(async move { - handle_connection(conn).await; + handle_connection(options.proxy_for, conn).await; }); // Dropping all handles associated with a connection implicitly closes it } } -async fn handle_connection(connection: quinn::Connection) { - let ssh_stream = TcpStream::connect("127.0.0.1:22").await; +async fn handle_connection(proxy_for: SocketAddr, connection: quinn::Connection) { + let ssh_stream = TcpStream::connect(proxy_for).await; let ssh_conn = match ssh_stream { Ok(conn) => conn, Err(e) => { From a7404af626340e7be74a7b09e8c284f4a57148f7 Mon Sep 17 00:00:00 2001 From: JyJyJcr <82190170+JyJyJcr@users.noreply.github.com> Date: Wed, 14 Feb 2024 00:08:44 +0900 Subject: [PATCH 2/3] docs: update README.md --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index de6ab21..4dc63f3 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,8 @@ Server Usage: quicssh-rs server [OPTIONS] Options: - -l, --listen Address to listen on [default: 0.0.0.0:4433] - -h, --help Print help - -V, --version Print version + -l, --listen Address to listen on [default: 0.0.0.0:4433] + -p, --proxy-for Address of the ssh server [default: 127.0.0.1:22] + -h, --help Print help + -V, --version Print version ``` From 103684b6613e360e6064dd0f67598e8a33551382 Mon Sep 17 00:00:00 2001 From: JyJyJcr <82190170+JyJyJcr@users.noreply.github.com> Date: Wed, 14 Feb 2024 23:23:20 +0900 Subject: [PATCH 3/3] refactor: rename `--proxy-for` to `--proxy-to` --- README.md | 2 +- src/server.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4dc63f3..0ed0c0b 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ Usage: quicssh-rs server [OPTIONS] Options: -l, --listen Address to listen on [default: 0.0.0.0:4433] - -p, --proxy-for Address of the ssh server [default: 127.0.0.1:22] + -p, --proxy-to Address of the ssh server [default: 127.0.0.1:22] -h, --help Print help -V, --version Print version ``` diff --git a/src/server.rs b/src/server.rs index d8dd969..c10bd01 100644 --- a/src/server.rs +++ b/src/server.rs @@ -14,8 +14,8 @@ pub struct Opt { #[clap(long = "listen", short = 'l', default_value = "0.0.0.0:4433")] listen: SocketAddr, /// Address of the ssh server - #[clap(long = "proxy-for", short = 'p', default_value = "127.0.0.1:22")] - proxy_for: SocketAddr, + #[clap(long = "proxy-to", short = 'p', default_value = "127.0.0.1:22")] + proxy_to: SocketAddr, } /// Returns default server configuration along with its certificate. @@ -68,7 +68,7 @@ pub async fn run(options: Opt) -> Result<(), Box> { conn.remote_address() ); tokio::spawn(async move { - handle_connection(options.proxy_for, conn).await; + handle_connection(options.proxy_to, conn).await; }); // Dropping all handles associated with a connection implicitly closes it }