recover --server and --connect in cli

This commit is contained in:
rustdesk 2022-12-29 14:17:47 +08:00
parent 40aaddf108
commit 1651cef4f3
2 changed files with 15 additions and 4 deletions

View File

@ -111,7 +111,7 @@ pub enum DataKeyboardResponse {
GetKeyState(bool), GetKeyState(bool),
} }
#[cfg(not(any(target_os = "android", target_os = "ios", feature = "cli")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
#[derive(Debug, Serialize, Deserialize, Clone)] #[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(tag = "t", content = "c")] #[serde(tag = "t", content = "c")]
pub enum DataMouse { pub enum DataMouse {
@ -195,11 +195,11 @@ pub enum Data {
ClipboardFileEnabled(bool), ClipboardFileEnabled(bool),
PrivacyModeState((i32, PrivacyModeState)), PrivacyModeState((i32, PrivacyModeState)),
TestRendezvousServer, TestRendezvousServer,
#[cfg(not(any(target_os = "android", target_os = "ios", feature = "cli")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
Keyboard(DataKeyboard), Keyboard(DataKeyboard),
#[cfg(not(any(target_os = "android", target_os = "ios", feature = "cli")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
KeyboardResponse(DataKeyboardResponse), KeyboardResponse(DataKeyboardResponse),
#[cfg(not(any(target_os = "android", target_os = "ios", feature = "cli")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
Mouse(DataMouse), Mouse(DataMouse),
Control(DataControl), Control(DataControl),
Theme(String), Theme(String),

View File

@ -36,6 +36,7 @@ fn main() {
use hbb_common::log; use hbb_common::log;
let args = format!( let args = format!(
"-p, --port-forward=[PORT-FORWARD-OPTIONS] 'Format: remote-id:local-port:remote-port[:remote-host]' "-p, --port-forward=[PORT-FORWARD-OPTIONS] 'Format: remote-id:local-port:remote-port[:remote-host]'
-c, --connect=[REMOTE_ID] 'test only'
-k, --key=[KEY] '' -k, --key=[KEY] ''
-s, --server... 'Start server'", -s, --server... 'Start server'",
); );
@ -71,6 +72,8 @@ fn main() {
if options.len() > 3 { if options.len() > 3 {
remote_host = options[3].clone(); remote_host = options[3].clone();
} }
common::test_rendezvous_server();
common::test_nat_type();
let key = matches.value_of("key").unwrap_or("").to_owned(); let key = matches.value_of("key").unwrap_or("").to_owned();
let token = LocalConfig::get_option("access_token"); let token = LocalConfig::get_option("access_token");
cli::start_one_port_forward( cli::start_one_port_forward(
@ -81,6 +84,14 @@ fn main() {
key, key,
token, token,
); );
} else if let Some(p) = matches.value_of("connect") {
common::test_rendezvous_server();
common::test_nat_type();
let key = matches.value_of("key").unwrap_or("").to_owned();
let token = LocalConfig::get_option("access_token");
cli::connect_test(p, key, token);
} else if let Some(p) = matches.value_of("server") {
crate::start_server(true);
} }
common::global_clean(); common::global_clean();
} }