lic draft

This commit is contained in:
opentrade
2021-04-08 17:53:56 +08:00
parent 92bd9c3250
commit 25554dd318
5 changed files with 578 additions and 30 deletions

View File

@@ -3,14 +3,17 @@ 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
DEFAULT_PORT,
lic::EMAIL_ARG
);
let matches = App::new("hbbr")
.version(hbbs::VERSION)
@@ -18,6 +21,9 @@ fn main() -> ResultType<()> {
.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),

6
src/lic.rs Normal file
View File

@@ -0,0 +1,6 @@
pub fn check_lic(email: &str) -> bool {
true
}
pub const EMAIL_ARG: &'static str =
"-m, --email=[EMAIL] 'Sets your email address registered with RustDesk'";

View File

@@ -4,6 +4,7 @@
use clap::App;
use hbb_common::{env_logger::*, log, ResultType};
use hbbs::*;
mod lic;
use ini::Ini;
use std::sync::{Arc, Mutex};
@@ -17,8 +18,9 @@ fn main() -> ResultType<()> {
-u, --software-url=[URL] 'Sets download url of RustDesk software of newest version'
-r, --relay-servers=[HOST] 'Sets the default relay servers, seperated by colon'
-C, --change-id=[BOOL(default=Y)] 'Sets if support to change id'
{}
-k, --key=[KEY] 'Only allow the client with the same key'",
DEFAULT_PORT,
DEFAULT_PORT, lic::EMAIL_ARG
);
let matches = App::new("hbbs")
.version(crate::VERSION)
@@ -62,6 +64,9 @@ fn main() -> ResultType<()> {
log::info!("serial={}", serial);
log::info!("rendezvous-servers={:?}", rendezvous_servers);
let stop: Arc<Mutex<bool>> = Default::default();
if !lic::check_lic(&get_arg("email", "")) {
return Ok(());
}
RendezvousServer::start(
&addr,
&addr2,