mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
force relay when id is suffixed with "/r"
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
@@ -3,15 +3,15 @@ use std::{
|
||||
net::SocketAddr,
|
||||
ops::{Deref, Not},
|
||||
str::FromStr,
|
||||
sync::{Arc, atomic::AtomicBool, mpsc, Mutex, RwLock},
|
||||
sync::{atomic::AtomicBool, mpsc, Arc, Mutex, RwLock},
|
||||
};
|
||||
|
||||
pub use async_trait::async_trait;
|
||||
use bytes::Bytes;
|
||||
#[cfg(not(any(target_os = "android", target_os = "linux")))]
|
||||
use cpal::{
|
||||
Device,
|
||||
Host, StreamConfig, traits::{DeviceTrait, HostTrait, StreamTrait},
|
||||
traits::{DeviceTrait, HostTrait, StreamTrait},
|
||||
Device, Host, StreamConfig,
|
||||
};
|
||||
use magnum_opus::{Channels::*, Decoder as AudioDecoder};
|
||||
use sha2::{Digest, Sha256};
|
||||
@@ -19,26 +19,26 @@ use uuid::Uuid;
|
||||
|
||||
pub use file_trait::FileManager;
|
||||
use hbb_common::{
|
||||
AddrMangle,
|
||||
allow_err,
|
||||
anyhow::{anyhow, Context},
|
||||
bail,
|
||||
config::{
|
||||
Config, CONNECT_TIMEOUT, PeerConfig, PeerInfoSerde, READ_TIMEOUT, RELAY_PORT,
|
||||
Config, PeerConfig, PeerInfoSerde, CONNECT_TIMEOUT, READ_TIMEOUT, RELAY_PORT,
|
||||
RENDEZVOUS_TIMEOUT,
|
||||
}, get_version_number,
|
||||
log,
|
||||
message_proto::{*, option_message::BoolOption},
|
||||
},
|
||||
get_version_number, log,
|
||||
message_proto::{option_message::BoolOption, *},
|
||||
protobuf::Message as _,
|
||||
rand,
|
||||
rendezvous_proto::*,
|
||||
ResultType,
|
||||
socket_client,
|
||||
sodiumoxide::crypto::{box_, secretbox, sign},
|
||||
Stream, timeout, tokio::time::Duration,
|
||||
timeout,
|
||||
tokio::time::Duration,
|
||||
AddrMangle, ResultType, Stream,
|
||||
};
|
||||
pub use helper::*;
|
||||
pub use helper::LatencyController;
|
||||
pub use helper::*;
|
||||
use scrap::{
|
||||
codec::{Decoder, DecoderCfg},
|
||||
record::{Recorder, RecorderContext},
|
||||
@@ -943,7 +943,13 @@ impl LoginConfigHandler {
|
||||
///
|
||||
/// * `id` - id of peer
|
||||
/// * `conn_type` - Connection type enum.
|
||||
pub fn initialize(&mut self, id: String, conn_type: ConnType, switch_uuid: Option<String>) {
|
||||
pub fn initialize(
|
||||
&mut self,
|
||||
id: String,
|
||||
conn_type: ConnType,
|
||||
switch_uuid: Option<String>,
|
||||
force_relay: bool,
|
||||
) {
|
||||
self.id = id;
|
||||
self.conn_type = conn_type;
|
||||
let config = self.load_config();
|
||||
@@ -952,7 +958,7 @@ impl LoginConfigHandler {
|
||||
self.session_id = rand::random();
|
||||
self.supported_encoding = None;
|
||||
self.restarting_remote_device = false;
|
||||
self.force_relay = !self.get_option("force-always-relay").is_empty();
|
||||
self.force_relay = !self.get_option("force-always-relay").is_empty() || force_relay;
|
||||
self.direct = None;
|
||||
self.received = false;
|
||||
self.switch_uuid = switch_uuid;
|
||||
|
||||
@@ -3,19 +3,19 @@ use crate::{
|
||||
flutter_ffi::EventToUI,
|
||||
ui_session_interface::{io_loop, InvokeUiSession, Session},
|
||||
};
|
||||
use flutter_rust_bridge::{StreamSink};
|
||||
use flutter_rust_bridge::StreamSink;
|
||||
use hbb_common::{
|
||||
bail, config::LocalConfig, get_version_number, message_proto::*, rendezvous_proto::ConnType,
|
||||
ResultType,
|
||||
};
|
||||
use serde_json::json;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
ffi::CString,
|
||||
os::raw::{c_char, c_int},
|
||||
sync::{Arc, RwLock},
|
||||
};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
pub(super) const APP_TYPE_MAIN: &str = "main";
|
||||
pub(super) const APP_TYPE_CM: &str = "cm";
|
||||
@@ -114,7 +114,7 @@ pub struct FlutterHandler {
|
||||
// SAFETY: [rgba] is guarded by [rgba_valid], and it's safe to reach [rgba] with `rgba_valid == true`.
|
||||
// We must check the `rgba_valid` before reading [rgba].
|
||||
pub rgba: Arc<RwLock<Vec<u8>>>,
|
||||
pub rgba_valid: Arc<AtomicBool>
|
||||
pub rgba_valid: Arc<AtomicBool>,
|
||||
}
|
||||
|
||||
impl FlutterHandler {
|
||||
@@ -449,6 +449,7 @@ pub fn session_add(
|
||||
is_file_transfer: bool,
|
||||
is_port_forward: bool,
|
||||
switch_uuid: &str,
|
||||
force_relay: bool,
|
||||
) -> ResultType<()> {
|
||||
let session_id = get_session_id(id.to_owned());
|
||||
LocalConfig::set_remote_id(&session_id);
|
||||
@@ -477,7 +478,7 @@ pub fn session_add(
|
||||
.lc
|
||||
.write()
|
||||
.unwrap()
|
||||
.initialize(session_id, conn_type, switch_uuid);
|
||||
.initialize(session_id, conn_type, switch_uuid, force_relay);
|
||||
|
||||
if let Some(same_id_session) = SESSIONS.write().unwrap().insert(id.to_owned(), session) {
|
||||
same_id_session.close();
|
||||
@@ -667,7 +668,7 @@ pub fn session_get_rgba_size(id: *const char) -> usize {
|
||||
let id = unsafe { std::ffi::CStr::from_ptr(id as _) };
|
||||
if let Ok(id) = id.to_str() {
|
||||
if let Some(session) = SESSIONS.write().unwrap().get_mut(id) {
|
||||
return session.rgba.read().unwrap().len();
|
||||
return session.rgba.read().unwrap().len();
|
||||
}
|
||||
}
|
||||
0
|
||||
@@ -692,4 +693,4 @@ pub fn session_next_rgba(id: *const char) {
|
||||
return session.next_rgba();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::ui_session_interface::InvokeUiSession;
|
||||
use crate::{
|
||||
client::file_trait::FileManager,
|
||||
common::make_fd_to_json,
|
||||
@@ -20,7 +21,6 @@ use std::{
|
||||
os::raw::c_char,
|
||||
str::FromStr,
|
||||
};
|
||||
use crate::ui_session_interface::InvokeUiSession;
|
||||
|
||||
// use crate::hbbs_http::account::AuthResult;
|
||||
|
||||
@@ -84,8 +84,15 @@ pub fn session_add_sync(
|
||||
is_file_transfer: bool,
|
||||
is_port_forward: bool,
|
||||
switch_uuid: String,
|
||||
force_relay: bool,
|
||||
) -> SyncReturn<String> {
|
||||
if let Err(e) = session_add(&id, is_file_transfer, is_port_forward, &switch_uuid) {
|
||||
if let Err(e) = session_add(
|
||||
&id,
|
||||
is_file_transfer,
|
||||
is_port_forward,
|
||||
&switch_uuid,
|
||||
force_relay,
|
||||
) {
|
||||
SyncReturn(format!("Failed to add session with id {}, {}", &id, e))
|
||||
} else {
|
||||
SyncReturn("".to_owned())
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
use std::sync::RwLock;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
ops::{Deref, DerefMut},
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
use std::sync::RwLock;
|
||||
|
||||
use sciter::{
|
||||
dom::{
|
||||
Element,
|
||||
event::{BEHAVIOR_EVENTS, EVENT_GROUPS, EventReason, PHASE_MASK}, HELEMENT,
|
||||
event::{EventReason, BEHAVIOR_EVENTS, EVENT_GROUPS, PHASE_MASK},
|
||||
Element, HELEMENT,
|
||||
},
|
||||
make_args,
|
||||
video::{video_destination, AssetPtr, COLOR_SPACE},
|
||||
Value,
|
||||
video::{AssetPtr, COLOR_SPACE, video_destination},
|
||||
};
|
||||
|
||||
use hbb_common::tokio::io::AsyncReadExt;
|
||||
use hbb_common::{
|
||||
allow_err, fs::TransferJobMeta, log, message_proto::*, rendezvous_proto::ConnType,
|
||||
};
|
||||
use hbb_common::tokio::io::AsyncReadExt;
|
||||
|
||||
use crate::{
|
||||
client::*,
|
||||
@@ -286,7 +286,9 @@ impl InvokeUiSession for SciterHandler {
|
||||
}
|
||||
|
||||
/// RGBA is directly rendered by [on_rgba]. No need to store the rgba for the sciter ui.
|
||||
fn get_rgba(&self) -> *const u8 { std::ptr::null() }
|
||||
fn get_rgba(&self) -> *const u8 {
|
||||
std::ptr::null()
|
||||
}
|
||||
|
||||
fn next_rgba(&mut self) {}
|
||||
}
|
||||
@@ -467,7 +469,11 @@ impl SciterSession {
|
||||
ConnType::DEFAULT_CONN
|
||||
};
|
||||
|
||||
session.lc.write().unwrap().initialize(id, conn_type, None);
|
||||
session
|
||||
.lc
|
||||
.write()
|
||||
.unwrap()
|
||||
.initialize(id, conn_type, None, false);
|
||||
|
||||
Self(session)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user