mirror of
https://github.com/rustdesk/rustdesk-server.git
synced 2026-03-10 22:13:14 +08:00
clap
This commit is contained in:
24
src/main.rs
24
src/main.rs
@@ -1,14 +1,34 @@
|
||||
// https://tools.ietf.org/rfc/rfc5128.txt
|
||||
// https://blog.csdn.net/bytxl/article/details/44344855
|
||||
|
||||
use clap::App;
|
||||
use hbb_common::{env_logger::*, log, tokio, ResultType};
|
||||
use hbbs::*;
|
||||
const DEFAULT_PORT: &'static str = "21116";
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> ResultType<()> {
|
||||
init_from_env(Env::default().filter_or(DEFAULT_FILTER_ENV, "info"));
|
||||
let addr = "0.0.0.0:21116";
|
||||
let args = format!(
|
||||
"-p, --port=[default={}] 'Sets the listening port'
|
||||
-r, --relay-server=[] 'Sets the default relay server'",
|
||||
DEFAULT_PORT
|
||||
);
|
||||
let matches = App::new("hbbs")
|
||||
.version("1.0")
|
||||
.author("Zhou Huabing <info@rustdesk.com>")
|
||||
.about("RustDesk Rendezvous Server")
|
||||
.args_from_usage(&args)
|
||||
.get_matches();
|
||||
let addr = format!(
|
||||
"0.0.0.0:{}",
|
||||
matches.value_of("port").unwrap_or(DEFAULT_PORT)
|
||||
);
|
||||
log::info!("Listening on {}", addr);
|
||||
RendezvousServer::start(&addr).await?;
|
||||
RendezvousServer::start(
|
||||
&addr,
|
||||
matches.value_of("relay-server").unwrap_or("").to_owned(),
|
||||
)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user