diff options
author | open-trade <[email protected]> | 2020-10-31 14:33:25 +0800 |
---|---|---|
committer | open-trade <[email protected]> | 2020-10-31 14:33:25 +0800 |
commit | f1646522d1a885836e61933eb0f0ce9d08eb10ed (patch) | |
tree | b6f5918c0a97b1f9b26ee149341e0288c7d5bd28 /src/main.rs | |
parent | 75dcbe47b7b92b519f0dccbbe6c577838dfcaa3a (diff) | |
download | rustdesk-server-f1646522d1a885836e61933eb0f0ce9d08eb10ed.tar.gz rustdesk-server-f1646522d1a885836e61933eb0f0ce9d08eb10ed.zip |
license
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs index 1c81632..9c64b71 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,8 +16,14 @@ async fn main() -> ResultType<()> { -s, --serial=[NUMBER(default=0)] 'Sets configure update serial number' -R, --rendezvous-servers=[HOSTS] 'Sets rendezvous servers, seperated by colon' -u, --software-url=[URL] 'Sets download url of RustDesk software of newest version' - -r, --relay-server=[HOST] 'Sets the default relay server'", - DEFAULT_PORT + -r, --relay-server{}=[HOST] 'Sets the default relay server{}'", + DEFAULT_PORT, + if LICENSE_KEY.is_empty() { "" } else { "s" }, + if LICENSE_KEY.is_empty() { + "" + } else { + "s, seperated by colon, only available for licensed users" + } ); let matches = App::new("hbbs") .version(crate::VERSION) @@ -44,28 +50,38 @@ async fn main() -> ResultType<()> { return default.to_owned(); }; let port = get_arg("port", DEFAULT_PORT); - let mut relay_server = get_arg("relay-server", ""); - if let Err(err) = test_if_valid_server(&relay_server) { - relay_server = "".to_owned(); - log::error!("Invalid relay-server: {}", err); + let mut relay_servers: Vec<String> = get_arg( + &format!( + "relay-server{}", + if LICENSE_KEY.is_empty() { "" } else { "s" } + ), + "", + ) + .split(",") + .filter(|x| !x.is_empty() && test_if_valid_server(x, "relay-server").is_ok()) + .map(|x| x.to_owned()) + .collect(); + if relay_servers.len() > 1 && LICENSE_KEY.is_empty() { + log::error!("Only support multiple relay servers for licenced users"); + relay_servers = vec![relay_servers[0].clone()]; } let serial: i32 = get_arg("serial", "").parse().unwrap_or(0); let rendezvous_servers: Vec<String> = get_arg("rendezvous-servers", "") .split(",") - .filter(|x| test_if_valid_server(x).is_ok()) + .filter(|x| !x.is_empty() && test_if_valid_server(x, "rendezvous-server").is_ok()) .map(|x| x.to_owned()) .collect(); let addr = format!("0.0.0.0:{}", port); log::info!("Listening on {}", addr); let addr2 = format!("0.0.0.0:{}", port.parse::<i32>().unwrap_or(0) - 1); log::info!("Listening on {}, extra port for NAT test", addr2); - log::info!("relay-server={}", relay_server); + log::info!("relay-servers={:?}", relay_servers); log::info!("serial={}", serial); log::info!("rendezvous-servers={:?}", rendezvous_servers); RendezvousServer::start( &addr, &addr2, - relay_server, + relay_servers, serial, rendezvous_servers, get_arg("software-url", ""), |