mirror of
https://github.com/ekzhang/bore.git
synced 2025-12-15 19:37:47 +01:00
58 lines
1.2 KiB
Rust
58 lines
1.2 KiB
Rust
use anyhow::Result;
|
|
use bore_cli::server::Server;
|
|
use clap::{Parser, Subcommand};
|
|
|
|
#[derive(Parser, Debug)]
|
|
#[clap(author, version, about)]
|
|
#[clap(propagate_version = true)]
|
|
struct Args {
|
|
#[clap(subcommand)]
|
|
command: Command,
|
|
}
|
|
|
|
#[derive(Subcommand, Debug)]
|
|
enum Command {
|
|
/// Starts a local proxy to the remote server.
|
|
Local {
|
|
/// The local port to listen on.
|
|
local_port: u16,
|
|
|
|
/// Address of the remote server to expose local ports to.
|
|
#[clap(short, long)]
|
|
to: String,
|
|
|
|
/// Optional port on the remote server to select.
|
|
#[clap(short, long, default_value_t = 0)]
|
|
port: u16,
|
|
},
|
|
|
|
/// Runs the remote proxy server.
|
|
Server {
|
|
/// Minimum TCP port number to accept.
|
|
#[clap(long, default_value_t = 1024)]
|
|
min_port: u16,
|
|
},
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<()> {
|
|
tracing_subscriber::fmt::init();
|
|
|
|
let args = Args::parse();
|
|
match args.command {
|
|
Command::Local {
|
|
local_port,
|
|
to,
|
|
port,
|
|
} => {
|
|
let _ = (local_port, to, port);
|
|
todo!()
|
|
}
|
|
Command::Server { min_port } => {
|
|
Server::new(min_port).listen().await?;
|
|
}
|
|
}
|
|
|
|
Ok(())
|
|
}
|