mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-07-06 23:35:07 +03:00
refact: remove feature cli (#15524)
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
25
Cargo.lock
generated
25
Cargo.lock
generated
@@ -6588,7 +6588,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "556af5f5c953a2ee13f45753e581a38f9778e6551bc3ccc56d90b14628fe59d8"
|
checksum = "556af5f5c953a2ee13f45753e581a38f9778e6551bc3ccc56d90b14628fe59d8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
"rpassword 2.1.0",
|
"rpassword",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"termios 0.3.3",
|
"termios 0.3.3",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
@@ -7152,17 +7152,6 @@ dependencies = [
|
|||||||
"winapi 0.2.8",
|
"winapi 0.2.8",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rpassword"
|
|
||||||
version = "7.3.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "80472be3c897911d0137b2d2b9055faf6eeac5b14e324073d83bc17b191d7e3f"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"rtoolbox",
|
|
||||||
"windows-sys 0.48.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rtcp"
|
name = "rtcp"
|
||||||
version = "0.14.0"
|
version = "0.14.0"
|
||||||
@@ -7174,16 +7163,6 @@ dependencies = [
|
|||||||
"webrtc-util",
|
"webrtc-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rtoolbox"
|
|
||||||
version = "0.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c247d24e63230cdb56463ae328478bd5eac8b8faa8c69461a77e8e323afac90e"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"windows-sys 0.48.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rtp"
|
name = "rtp"
|
||||||
version = "0.14.0"
|
version = "0.14.0"
|
||||||
@@ -7283,7 +7262,6 @@ dependencies = [
|
|||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"chrono",
|
"chrono",
|
||||||
"cidr-utils",
|
"cidr-utils",
|
||||||
"clap 4.5.53",
|
|
||||||
"clipboard",
|
"clipboard",
|
||||||
"clipboard-master",
|
"clipboard-master",
|
||||||
"cocoa 0.24.1",
|
"cocoa 0.24.1",
|
||||||
@@ -7341,7 +7319,6 @@ dependencies = [
|
|||||||
"repng",
|
"repng",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"ringbuf",
|
"ringbuf",
|
||||||
"rpassword 7.3.1",
|
|
||||||
"rubato",
|
"rubato",
|
||||||
"runas",
|
"runas",
|
||||||
"rust-pulsectl",
|
"rust-pulsectl",
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ path = "src/service.rs"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
inline = []
|
inline = []
|
||||||
cli = []
|
|
||||||
use_samplerate = ["samplerate"]
|
use_samplerate = ["samplerate"]
|
||||||
use_rubato = ["rubato"]
|
use_rubato = ["rubato"]
|
||||||
use_dasp = ["dasp"]
|
use_dasp = ["dasp"]
|
||||||
@@ -62,8 +61,6 @@ dasp = { version = "0.11", features = ["signal", "interpolate-linear", "interpol
|
|||||||
rubato = { version = "0.12", optional = true }
|
rubato = { version = "0.12", optional = true }
|
||||||
samplerate = { version = "0.2", optional = true }
|
samplerate = { version = "0.2", optional = true }
|
||||||
uuid = { version = "1.3", features = ["v4"] }
|
uuid = { version = "1.3", features = ["v4"] }
|
||||||
clap = "4.2"
|
|
||||||
rpassword = "7.2"
|
|
||||||
num_cpus = "1.15"
|
num_cpus = "1.15"
|
||||||
bytes = { version = "1.4", features = ["serde"] }
|
bytes = { version = "1.4", features = ["serde"] }
|
||||||
default-net = "0.14"
|
default-net = "0.14"
|
||||||
|
|||||||
199
src/cli.rs
199
src/cli.rs
@@ -1,199 +0,0 @@
|
|||||||
use crate::client::*;
|
|
||||||
use async_trait::async_trait;
|
|
||||||
use hbb_common::{
|
|
||||||
config::PeerConfig,
|
|
||||||
config::READ_TIMEOUT,
|
|
||||||
futures::{SinkExt, StreamExt},
|
|
||||||
log,
|
|
||||||
message_proto::*,
|
|
||||||
protobuf::Message as _,
|
|
||||||
rendezvous_proto::ConnType,
|
|
||||||
tokio::{self, sync::mpsc},
|
|
||||||
Stream,
|
|
||||||
};
|
|
||||||
use std::sync::{Arc, RwLock};
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct Session {
|
|
||||||
id: String,
|
|
||||||
lc: Arc<RwLock<LoginConfigHandler>>,
|
|
||||||
sender: mpsc::UnboundedSender<Data>,
|
|
||||||
password: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Session {
|
|
||||||
pub fn new(id: &str, sender: mpsc::UnboundedSender<Data>) -> Self {
|
|
||||||
let mut password = "".to_owned();
|
|
||||||
if PeerConfig::load(id).password.is_empty() {
|
|
||||||
match rpassword::prompt_password("Enter password: ") {
|
|
||||||
Ok(p) => password = p,
|
|
||||||
Err(e) => {
|
|
||||||
log::error!("Failed to read password: {:?}", e);
|
|
||||||
password = "".to_owned();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let session = Self {
|
|
||||||
id: id.to_owned(),
|
|
||||||
sender,
|
|
||||||
password,
|
|
||||||
lc: Default::default(),
|
|
||||||
};
|
|
||||||
session.lc.write().unwrap().initialize(
|
|
||||||
id.to_owned(),
|
|
||||||
ConnType::PORT_FORWARD,
|
|
||||||
None,
|
|
||||||
false,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
session
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl Interface for Session {
|
|
||||||
fn get_login_config_handler(&self) -> Arc<RwLock<LoginConfigHandler>> {
|
|
||||||
return self.lc.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn msgbox(&self, msgtype: &str, title: &str, text: &str, link: &str) {
|
|
||||||
match msgtype {
|
|
||||||
"input-password" => {
|
|
||||||
self.sender
|
|
||||||
.send(Data::Login((self.password.clone(), true)))
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
"re-input-password" => {
|
|
||||||
log::error!("{}: {}", title, text);
|
|
||||||
match rpassword::prompt_password("Enter password: ") {
|
|
||||||
Ok(password) => {
|
|
||||||
let login_data = Data::Login((password, true));
|
|
||||||
self.sender.send(login_data).ok();
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
log::error!("reinput password failed, {:?}", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
msg if msg.contains("error") => {
|
|
||||||
log::error!("{}: {}: {}", msgtype, title, text);
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
log::info!("{}: {}: {}", msgtype, title, text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_login_error(&self, err: &str) -> bool {
|
|
||||||
handle_login_error(self.lc.clone(), err, self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_peer_info(&self, pi: PeerInfo) {
|
|
||||||
self.lc.write().unwrap().handle_peer_info(&pi);
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn handle_hash(&self, pass: &str, hash: Hash, peer: &mut Stream) {
|
|
||||||
log::info!(
|
|
||||||
"password={}",
|
|
||||||
hbb_common::password_security::temporary_password()
|
|
||||||
);
|
|
||||||
handle_hash(self.lc.clone(), &pass, hash, self, peer).await;
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn handle_login_from_ui(
|
|
||||||
&self,
|
|
||||||
os_username: String,
|
|
||||||
os_password: String,
|
|
||||||
password: String,
|
|
||||||
remember: bool,
|
|
||||||
peer: &mut Stream,
|
|
||||||
) {
|
|
||||||
handle_login_from_ui(
|
|
||||||
self.lc.clone(),
|
|
||||||
os_username,
|
|
||||||
os_password,
|
|
||||||
password,
|
|
||||||
remember,
|
|
||||||
peer,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn handle_test_delay(&self, t: TestDelay, peer: &mut Stream) {
|
|
||||||
handle_test_delay(t, peer).await;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn send(&self, data: Data) {
|
|
||||||
self.sender.send(data).ok();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::main(flavor = "current_thread")]
|
|
||||||
pub async fn connect_test(id: &str, key: String, token: String) {
|
|
||||||
let (sender, mut receiver) = mpsc::unbounded_channel::<Data>();
|
|
||||||
let handler = Session::new(&id, sender);
|
|
||||||
match crate::client::Client::start(id, &key, &token, ConnType::PORT_FORWARD, handler).await {
|
|
||||||
Err(err) => {
|
|
||||||
log::error!("Failed to connect {}: {}", &id, err);
|
|
||||||
}
|
|
||||||
Ok((mut stream, direct)) => {
|
|
||||||
log::info!("direct: {}", direct);
|
|
||||||
// rpassword::prompt_password("Input anything to exit").ok();
|
|
||||||
loop {
|
|
||||||
tokio::select! {
|
|
||||||
res = hbb_common::timeout(READ_TIMEOUT, stream.next()) => match res {
|
|
||||||
Err(_) => {
|
|
||||||
log::error!("Timeout");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Ok(Some(Ok(bytes))) => {
|
|
||||||
if let Ok(msg_in) = Message::parse_from_bytes(&bytes) {
|
|
||||||
match msg_in.union {
|
|
||||||
Some(message::Union::Hash(hash)) => {
|
|
||||||
log::info!("Got hash");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::main(flavor = "current_thread")]
|
|
||||||
pub async fn start_one_port_forward(
|
|
||||||
id: String,
|
|
||||||
port: i32,
|
|
||||||
remote_host: String,
|
|
||||||
remote_port: i32,
|
|
||||||
key: String,
|
|
||||||
token: String,
|
|
||||||
) {
|
|
||||||
crate::common::test_rendezvous_server();
|
|
||||||
crate::common::test_nat_type();
|
|
||||||
let (sender, mut receiver) = mpsc::unbounded_channel::<Data>();
|
|
||||||
let handler = Session::new(&id, sender);
|
|
||||||
if let Err(err) = crate::port_forward::listen(
|
|
||||||
handler.id.clone(),
|
|
||||||
handler.password.clone(),
|
|
||||||
port,
|
|
||||||
handler.clone(),
|
|
||||||
receiver,
|
|
||||||
&key,
|
|
||||||
&token,
|
|
||||||
handler.lc.clone(),
|
|
||||||
remote_host,
|
|
||||||
remote_port,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
log::error!("Failed to listen on {}: {}", port, err);
|
|
||||||
}
|
|
||||||
log::info!("port forward (:{}) exit", port);
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,6 @@ pub trait FileManager: Interface {
|
|||||||
#[cfg(not(any(
|
#[cfg(not(any(
|
||||||
target_os = "android",
|
target_os = "android",
|
||||||
target_os = "ios",
|
target_os = "ios",
|
||||||
feature = "cli",
|
|
||||||
feature = "flutter"
|
feature = "flutter"
|
||||||
)))]
|
)))]
|
||||||
fn get_home_dir(&self) -> String {
|
fn get_home_dir(&self) -> String {
|
||||||
@@ -16,7 +15,6 @@ pub trait FileManager: Interface {
|
|||||||
#[cfg(not(any(
|
#[cfg(not(any(
|
||||||
target_os = "android",
|
target_os = "android",
|
||||||
target_os = "ios",
|
target_os = "ios",
|
||||||
feature = "cli",
|
|
||||||
feature = "flutter"
|
feature = "flutter"
|
||||||
)))]
|
)))]
|
||||||
fn get_next_job_id(&self) -> i32 {
|
fn get_next_job_id(&self) -> i32 {
|
||||||
@@ -26,7 +24,6 @@ pub trait FileManager: Interface {
|
|||||||
#[cfg(not(any(
|
#[cfg(not(any(
|
||||||
target_os = "android",
|
target_os = "android",
|
||||||
target_os = "ios",
|
target_os = "ios",
|
||||||
feature = "cli",
|
|
||||||
feature = "flutter"
|
feature = "flutter"
|
||||||
)))]
|
)))]
|
||||||
fn update_next_job_id(&self, id: i32) {
|
fn update_next_job_id(&self, id: i32) {
|
||||||
@@ -36,7 +33,6 @@ pub trait FileManager: Interface {
|
|||||||
#[cfg(not(any(
|
#[cfg(not(any(
|
||||||
target_os = "android",
|
target_os = "android",
|
||||||
target_os = "ios",
|
target_os = "ios",
|
||||||
feature = "cli",
|
|
||||||
feature = "flutter"
|
feature = "flutter"
|
||||||
)))]
|
)))]
|
||||||
fn read_dir(&self, path: String, include_hidden: bool) -> sciter::Value {
|
fn read_dir(&self, path: String, include_hidden: bool) -> sciter::Value {
|
||||||
@@ -90,7 +86,6 @@ pub trait FileManager: Interface {
|
|||||||
#[cfg(not(any(
|
#[cfg(not(any(
|
||||||
target_os = "android",
|
target_os = "android",
|
||||||
target_os = "ios",
|
target_os = "ios",
|
||||||
feature = "cli",
|
|
||||||
feature = "flutter"
|
feature = "flutter"
|
||||||
)))]
|
)))]
|
||||||
fn confirm_delete_files(&self, id: i32, file_num: i32) {
|
fn confirm_delete_files(&self, id: i32, file_num: i32) {
|
||||||
@@ -100,7 +95,6 @@ pub trait FileManager: Interface {
|
|||||||
#[cfg(not(any(
|
#[cfg(not(any(
|
||||||
target_os = "android",
|
target_os = "android",
|
||||||
target_os = "ios",
|
target_os = "ios",
|
||||||
feature = "cli",
|
|
||||||
feature = "flutter"
|
feature = "flutter"
|
||||||
)))]
|
)))]
|
||||||
fn set_no_confirm(&self, id: i32) {
|
fn set_no_confirm(&self, id: i32) {
|
||||||
|
|||||||
@@ -764,15 +764,14 @@ async fn test_rendezvous_server_() {
|
|||||||
Config::reset_online();
|
Config::reset_online();
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[cfg(any(target_os = "android", target_os = "ios", feature = "cli"))]
|
|
||||||
pub fn test_rendezvous_server() {
|
pub fn test_rendezvous_server() {
|
||||||
std::thread::spawn(test_rendezvous_server_);
|
std::thread::spawn(test_rendezvous_server_);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn refresh_rendezvous_server() {
|
pub fn refresh_rendezvous_server() {
|
||||||
#[cfg(any(target_os = "android", target_os = "ios", feature = "cli"))]
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
test_rendezvous_server();
|
test_rendezvous_server();
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios", feature = "cli")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
std::thread::spawn(|| {
|
std::thread::spawn(|| {
|
||||||
if crate::ipc::test_rendezvous_server().is_err() {
|
if crate::ipc::test_rendezvous_server().is_err() {
|
||||||
test_rendezvous_server();
|
test_rendezvous_server();
|
||||||
|
|||||||
@@ -1026,7 +1026,7 @@ pub fn main_set_option(key: String, value: String) {
|
|||||||
set_option(key, value.clone());
|
set_option(key, value.clone());
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
crate::rendezvous_mediator::RendezvousMediator::restart();
|
crate::rendezvous_mediator::RendezvousMediator::restart();
|
||||||
#[cfg(any(target_os = "android", target_os = "ios", feature = "cli"))]
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
crate::common::test_rendezvous_server();
|
crate::common::test_rendezvous_server();
|
||||||
} else {
|
} else {
|
||||||
set_option(key, value.clone());
|
set_option(key, value.clone());
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
use crate::flutter;
|
use crate::flutter;
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
use crate::platform::windows::{get_char_from_vk, get_unicode_from_vk};
|
use crate::platform::windows::{get_char_from_vk, get_unicode_from_vk};
|
||||||
#[cfg(not(any(feature = "flutter", feature = "cli")))]
|
#[cfg(not(feature = "flutter"))]
|
||||||
use crate::ui::CUR_SESSION;
|
use crate::ui::CUR_SESSION;
|
||||||
use crate::ui_session_interface::{InvokeUiSession, Session};
|
use crate::ui_session_interface::{InvokeUiSession, Session};
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
@@ -469,7 +469,7 @@ static mut IS_LEFT_OPTION_DOWN: bool = false;
|
|||||||
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
fn get_keyboard_mode() -> String {
|
fn get_keyboard_mode() -> String {
|
||||||
#[cfg(not(any(feature = "flutter", feature = "cli")))]
|
#[cfg(not(feature = "flutter"))]
|
||||||
if let Some(session) = CUR_SESSION.lock().unwrap().as_ref() {
|
if let Some(session) = CUR_SESSION.lock().unwrap().as_ref() {
|
||||||
return session.get_keyboard_mode();
|
return session.get_keyboard_mode();
|
||||||
}
|
}
|
||||||
@@ -991,7 +991,7 @@ pub fn event_to_key_events(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_key_event(key_event: &KeyEvent) {
|
pub fn send_key_event(key_event: &KeyEvent) {
|
||||||
#[cfg(not(any(feature = "flutter", feature = "cli")))]
|
#[cfg(not(feature = "flutter"))]
|
||||||
if let Some(session) = CUR_SESSION.lock().unwrap().as_ref() {
|
if let Some(session) = CUR_SESSION.lock().unwrap().as_ref() {
|
||||||
session.send_key_event(key_event);
|
session.send_key_event(key_event);
|
||||||
}
|
}
|
||||||
@@ -1003,7 +1003,7 @@ pub fn send_key_event(key_event: &KeyEvent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_peer_platform() -> String {
|
pub fn get_peer_platform() -> String {
|
||||||
#[cfg(not(any(feature = "flutter", feature = "cli")))]
|
#[cfg(not(feature = "flutter"))]
|
||||||
if let Some(session) = CUR_SESSION.lock().unwrap().as_ref() {
|
if let Some(session) = CUR_SESSION.lock().unwrap().as_ref() {
|
||||||
return session.peer_platform();
|
return session.peer_platform();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ pub mod ipc;
|
|||||||
#[cfg(not(any(
|
#[cfg(not(any(
|
||||||
target_os = "android",
|
target_os = "android",
|
||||||
target_os = "ios",
|
target_os = "ios",
|
||||||
feature = "cli",
|
|
||||||
feature = "flutter"
|
feature = "flutter"
|
||||||
)))]
|
)))]
|
||||||
pub mod ui;
|
pub mod ui;
|
||||||
@@ -38,11 +37,9 @@ pub mod flutter;
|
|||||||
pub mod flutter_ffi;
|
pub mod flutter_ffi;
|
||||||
use common::*;
|
use common::*;
|
||||||
mod auth_2fa;
|
mod auth_2fa;
|
||||||
#[cfg(feature = "cli")]
|
|
||||||
pub mod cli;
|
|
||||||
#[cfg(not(target_os = "ios"))]
|
#[cfg(not(target_os = "ios"))]
|
||||||
mod clipboard;
|
mod clipboard;
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios", feature = "cli")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
pub mod core_main;
|
pub mod core_main;
|
||||||
mod custom_server;
|
mod custom_server;
|
||||||
mod lang;
|
mod lang;
|
||||||
|
|||||||
71
src/main.rs
71
src/main.rs
@@ -19,7 +19,6 @@ fn main() {
|
|||||||
#[cfg(not(any(
|
#[cfg(not(any(
|
||||||
target_os = "android",
|
target_os = "android",
|
||||||
target_os = "ios",
|
target_os = "ios",
|
||||||
feature = "cli",
|
|
||||||
feature = "flutter"
|
feature = "flutter"
|
||||||
)))]
|
)))]
|
||||||
fn main() {
|
fn main() {
|
||||||
@@ -32,73 +31,3 @@ fn main() {
|
|||||||
}
|
}
|
||||||
common::global_clean();
|
common::global_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "cli")]
|
|
||||||
fn main() {
|
|
||||||
if !common::global_init() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
use clap::App;
|
|
||||||
use hbb_common::log;
|
|
||||||
let args = format!(
|
|
||||||
"-p, --port-forward=[PORT-FORWARD-OPTIONS] 'Format: remote-id:local-port:remote-port[:remote-host]'
|
|
||||||
-c, --connect=[REMOTE_ID] 'test only'
|
|
||||||
-k, --key=[KEY] ''
|
|
||||||
-s, --server=[] 'Start server'",
|
|
||||||
);
|
|
||||||
let matches = App::new("rustdesk")
|
|
||||||
.version(crate::VERSION)
|
|
||||||
.author("Purslane Tech Pte. Ltd.<info@rustdesk.com>")
|
|
||||||
.about("RustDesk command line tool")
|
|
||||||
.args_from_usage(&args)
|
|
||||||
.get_matches();
|
|
||||||
use hbb_common::{config::LocalConfig, env_logger::*};
|
|
||||||
init_from_env(Env::default().filter_or(DEFAULT_FILTER_ENV, "info"));
|
|
||||||
if let Some(p) = matches.value_of("port-forward") {
|
|
||||||
let options: Vec<String> = p.split(":").map(|x| x.to_owned()).collect();
|
|
||||||
if options.len() < 3 {
|
|
||||||
log::error!("Wrong port-forward options");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let mut port = 0;
|
|
||||||
if let Ok(v) = options[1].parse::<i32>() {
|
|
||||||
port = v;
|
|
||||||
} else {
|
|
||||||
log::error!("Wrong local-port");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let mut remote_port = 0;
|
|
||||||
if let Ok(v) = options[2].parse::<i32>() {
|
|
||||||
remote_port = v;
|
|
||||||
} else {
|
|
||||||
log::error!("Wrong remote-port");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let mut remote_host = "localhost".to_owned();
|
|
||||||
if options.len() > 3 {
|
|
||||||
remote_host = options[3].clone();
|
|
||||||
}
|
|
||||||
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::start_one_port_forward(
|
|
||||||
options[0].clone(),
|
|
||||||
port,
|
|
||||||
remote_host,
|
|
||||||
remote_port,
|
|
||||||
key,
|
|
||||||
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") {
|
|
||||||
log::info!("id={}", hbb_common::config::Config::get_id());
|
|
||||||
crate::start_server(true, false);
|
|
||||||
}
|
|
||||||
common::global_clean();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use hbb_common::{
|
|||||||
log,
|
log,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(not(any(feature = "flutter", feature = "cli")))]
|
#[cfg(not(feature = "flutter"))]
|
||||||
use crate::ui_session_interface::Session;
|
use crate::ui_session_interface::Session;
|
||||||
use crate::{common::get_app_name, ipc, ui_interface::*};
|
use crate::{common::get_app_name, ipc, ui_interface::*};
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ lazy_static::lazy_static! {
|
|||||||
static ref STUPID_VALUES: Mutex<Vec<Arc<Vec<Value>>>> = Default::default();
|
static ref STUPID_VALUES: Mutex<Vec<Arc<Vec<Value>>>> = Default::default();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(feature = "flutter", feature = "cli")))]
|
#[cfg(not(feature = "flutter"))]
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
pub static ref CUR_SESSION: Arc<Mutex<Option<Session<remote::SciterHandler>>>> = Default::default();
|
pub static ref CUR_SESSION: Arc<Mutex<Option<Session<remote::SciterHandler>>>> = Default::default();
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ pub fn start(args: &mut [String]) {
|
|||||||
frame.register_behavior("native-remote", move || {
|
frame.register_behavior("native-remote", move || {
|
||||||
let handler =
|
let handler =
|
||||||
remote::SciterSession::new(cmd.clone(), id.clone(), pass.clone(), args.clone());
|
remote::SciterSession::new(cmd.clone(), id.clone(), pass.clone(), args.clone());
|
||||||
#[cfg(not(any(feature = "flutter", feature = "cli")))]
|
#[cfg(not(feature = "flutter"))]
|
||||||
{
|
{
|
||||||
*CUR_SESSION.lock().unwrap() = Some(handler.inner());
|
*CUR_SESSION.lock().unwrap() = Some(handler.inner());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -711,7 +711,6 @@ pub fn is_can_input_monitoring(_prompt: bool) -> bool {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_error() -> String {
|
pub fn get_error() -> String {
|
||||||
#[cfg(not(any(feature = "cli")))]
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
let dtype = crate::platform::linux::get_display_server();
|
let dtype = crate::platform::linux::get_display_server();
|
||||||
|
|||||||
Reference in New Issue
Block a user