open-trade лет назад: 4
Родитель
Сommit
244410cda9
2 измененных файлов с 17 добавлено и 27 удалено
  1. 8 2
      src/hbbr.rs
  2. 9 25
      src/main.rs

+ 8 - 2
src/hbbr.rs

@@ -7,7 +7,9 @@ use std::sync::{Arc, Mutex};
7
 fn main() -> ResultType<()> {
7
 fn main() -> ResultType<()> {
8
     init_from_env(Env::default().filter_or(DEFAULT_FILTER_ENV, "info"));
8
     init_from_env(Env::default().filter_or(DEFAULT_FILTER_ENV, "info"));
9
     let args = format!(
9
     let args = format!(
10
-        "-p, --port=[NUMBER(default={})] 'Sets the listening port'",
10
+        "-p, --port=[NUMBER(default={})] 'Sets the listening port'
11
+        -k, --key=[KEY] 'Only allow the client with the same key'
12
+        ",
11
         DEFAULT_PORT
13
         DEFAULT_PORT
12
     );
14
     );
13
     let matches = App::new("hbbr")
15
     let matches = App::new("hbbr")
@@ -17,6 +19,10 @@ fn main() -> ResultType<()> {
17
         .args_from_usage(&args)
19
         .args_from_usage(&args)
18
         .get_matches();
20
         .get_matches();
19
     let stop: Arc<Mutex<bool>> = Default::default();
21
     let stop: Arc<Mutex<bool>> = Default::default();
20
-    start(matches.value_of("port").unwrap_or(DEFAULT_PORT), "", stop)?;
22
+    start(
23
+        matches.value_of("port").unwrap_or(DEFAULT_PORT),
24
+        matches.value_of("key").unwrap_or(""),
25
+        stop,
26
+    )?;
21
     Ok(())
27
     Ok(())
22
 }
28
 }

+ 9 - 25
src/main.rs

@@ -7,8 +7,6 @@ use hbbs::*;
7
 use ini::Ini;
7
 use ini::Ini;
8
 use std::sync::{Arc, Mutex};
8
 use std::sync::{Arc, Mutex};
9
 
9
 
10
-const LICENSE_KEY: &'static str = "";
11
-
12
 fn main() -> ResultType<()> {
10
 fn main() -> ResultType<()> {
13
     init_from_env(Env::default().filter_or(DEFAULT_FILTER_ENV, "info"));
11
     init_from_env(Env::default().filter_or(DEFAULT_FILTER_ENV, "info"));
14
     let args = format!(
12
     let args = format!(
@@ -17,14 +15,10 @@ fn main() -> ResultType<()> {
17
         -s, --serial=[NUMBER(default=0)] 'Sets configure update serial number'
15
         -s, --serial=[NUMBER(default=0)] 'Sets configure update serial number'
18
         -R, --rendezvous-servers=[HOSTS] 'Sets rendezvous servers, seperated by colon'
16
         -R, --rendezvous-servers=[HOSTS] 'Sets rendezvous servers, seperated by colon'
19
         -u, --software-url=[URL] 'Sets download url of RustDesk software of newest version'
17
         -u, --software-url=[URL] 'Sets download url of RustDesk software of newest version'
20
-        -r, --relay-server{}=[HOST] 'Sets the default relay server{}'",
18
+        -r, --relay-servers=[HOST] 'Sets the default relay servers, seperated by colon, only
19
+        available for licensed users'
20
+        -k, --key=[KEY] 'Only allow the client with the same key'",
21
         DEFAULT_PORT,
21
         DEFAULT_PORT,
22
-        if LICENSE_KEY.is_empty() { "" } else { "s" },
23
-        if LICENSE_KEY.is_empty() {
24
-            ""
25
-        } else {
26
-            "s, seperated by colon, only available for licensed users"
27
-        }
28
     );
22
     );
29
     let matches = App::new("hbbs")
23
     let matches = App::new("hbbs")
30
         .version(crate::VERSION)
24
         .version(crate::VERSION)
@@ -51,21 +45,11 @@ fn main() -> ResultType<()> {
51
         return default.to_owned();
45
         return default.to_owned();
52
     };
46
     };
53
     let port = get_arg("port", DEFAULT_PORT);
47
     let port = get_arg("port", DEFAULT_PORT);
54
-    let mut relay_servers: Vec<String> = get_arg(
55
-        &format!(
56
-            "relay-server{}",
57
-            if LICENSE_KEY.is_empty() { "" } else { "s" }
58
-        ),
59
-        "",
60
-    )
61
-    .split(",")
62
-    .filter(|x| !x.is_empty() && test_if_valid_server(x, "relay-server").is_ok())
63
-    .map(|x| x.to_owned())
64
-    .collect();
65
-    if relay_servers.len() > 1 && LICENSE_KEY.is_empty() {
66
-        log::error!("Only support multiple relay servers for licenced users");
67
-        relay_servers = vec![relay_servers[0].clone()];
68
-    }
48
+    let relay_servers: Vec<String> = get_arg("relay-servers", "")
49
+        .split(",")
50
+        .filter(|x| !x.is_empty() && test_if_valid_server(x, "relay-server").is_ok())
51
+        .map(|x| x.to_owned())
52
+        .collect();
69
     let serial: i32 = get_arg("serial", "").parse().unwrap_or(0);
53
     let serial: i32 = get_arg("serial", "").parse().unwrap_or(0);
70
     let rendezvous_servers: Vec<String> = get_arg("rendezvous-servers", "")
54
     let rendezvous_servers: Vec<String> = get_arg("rendezvous-servers", "")
71
         .split(",")
55
         .split(",")
@@ -84,7 +68,7 @@ fn main() -> ResultType<()> {
84
         serial,
68
         serial,
85
         rendezvous_servers,
69
         rendezvous_servers,
86
         get_arg("software-url", ""),
70
         get_arg("software-url", ""),
87
-        LICENSE_KEY,
71
+        &get_arg("key", ""),
88
         stop,
72
         stop,
89
     )?;
73
     )?;
90
     Ok(())
74
     Ok(())