Browse Source

make hbbr / hbbs share the PORT value of .env

rustdesk 3 years ago
parent
commit
d88e4b5151
2 changed files with 11 additions and 5 deletions
  1. 11 2
      src/hbbr.rs
  2. 0 3
      src/version.rs

+ 11 - 2
src/hbbr.rs

@@ -29,9 +29,18 @@ fn main() -> ResultType<()> {
29 29
             section.iter().for_each(|(k, v)| std::env::set_var(k, v));
30 30
         }
31 31
     }
32
+    let mut port = RELAY_PORT;
33
+    if let Ok(v) = std::env::var("PORT") {
34
+        let v: i32 = v.parse().unwrap_or_default();
35
+        if v > 0 {
36
+            port = v + 1;
37
+        }
38
+    }
32 39
     start(
33
-        matches.value_of("port").unwrap_or(&RELAY_PORT.to_string()),
34
-        matches.value_of("key").unwrap_or(""),
40
+        matches.value_of("port").unwrap_or(&port.to_string()),
41
+        matches
42
+            .value_of("key")
43
+            .unwrap_or(&std::env::var("KEY").unwrap_or_default()),
35 44
     )?;
36 45
     Ok(())
37 46
 }

+ 0 - 3
src/version.rs

@@ -1,3 +0,0 @@
1
-pub const VERSION: &str = "1.1.7";
2
-#[allow(dead_code)]
3
-pub const BUILD_DATE: &str = "2023-02-01 10:45";