aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/hbbr.rs
blob: f0633a2619d1390aa4c1955a6164d5d0ca4fbb29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use clap::App;
mod relay_server;
use hbb_common::{env_logger::*, ResultType};
use relay_server::*;
use std::sync::{Arc, Mutex};
mod lic;

fn main() -> ResultType<()> {
    init_from_env(Env::default().filter_or(DEFAULT_FILTER_ENV, "info"));
    let args = format!(
        "-p, --port=[NUMBER(default={})] 'Sets the listening port'
        -k, --key=[KEY] 'Only allow the client with the same key'
        {}
        ",
        DEFAULT_PORT,
        lic::EMAIL_ARG
    );
    let matches = App::new("hbbr")
        .version(hbbs::VERSION)
        .author("CarrieZ Studio<info@rustdesk.com>")
        .about("RustDesk Relay Server")
        .args_from_usage(&args)
        .get_matches();
    if !lic::check_lic(matches.value_of("email").unwrap_or("")) {
        return Ok(());
    }
    let stop: Arc<Mutex<bool>> = Default::default();
    start(
        matches.value_of("port").unwrap_or(DEFAULT_PORT),
        matches.value_of("key").unwrap_or(""),
        stop,
    )?;
    Ok(())
}