mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-12-04 15:46:07 +00:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
333bfc6427 | ||
|
|
289f839646 | ||
|
|
3dd95ab73b | ||
|
|
3e953e886a | ||
|
|
bca767fcdb | ||
|
|
5b937c3a68 | ||
|
|
7949eca16c | ||
|
|
506e111460 | ||
|
|
fcb485bb90 | ||
|
|
febee50a6e |
No files matched your search
Generated
+6
-6
@@ -3724,7 +3724,7 @@ dependencies = [
|
||||
"url",
|
||||
"users",
|
||||
"uuid",
|
||||
"webpki-roots 1.0.11",
|
||||
"webpki-roots 1.0.12",
|
||||
"webrtc",
|
||||
"whoami",
|
||||
"x11 2.21.0",
|
||||
@@ -3922,7 +3922,7 @@ dependencies = [
|
||||
"tokio",
|
||||
"tokio-rustls",
|
||||
"tower-service",
|
||||
"webpki-roots 1.0.11",
|
||||
"webpki-roots 1.0.12",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -6916,7 +6916,7 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
"webpki-roots 1.0.11",
|
||||
"webpki-roots 1.0.12",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -9539,14 +9539,14 @@ version = "0.26.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9"
|
||||
dependencies = [
|
||||
"webpki-roots 1.0.11",
|
||||
"webpki-roots 1.0.12",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webpki-roots"
|
||||
version = "1.0.11"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f5f280bbb2b287bc8e7de7e3852945a0ff50d1bbcb5ed42b6c7a568c546df171"
|
||||
checksum = "7265c9301c16a8711c992c2d8da90ee77ef54b1ed51482d6dfeb00dc756b1297"
|
||||
dependencies = [
|
||||
"rustls-pki-types",
|
||||
]
|
||||
|
||||
@@ -35,6 +35,7 @@ import kotlin.math.max
|
||||
import hbb.MessageOuterClass.KeyEvent
|
||||
import hbb.MessageOuterClass.KeyboardMode
|
||||
import hbb.KeyEventConverter
|
||||
import ffi.FFI
|
||||
|
||||
// const val BUTTON_UP = 2
|
||||
// const val BUTTON_BACK = 0x08
|
||||
@@ -79,6 +80,8 @@ class InputService : AccessibilityService() {
|
||||
}
|
||||
|
||||
private fun notifyInputState() {
|
||||
// The Flutter UI may not be running to forward this, e.g. when enabled from system settings.
|
||||
FFI.setInputServiceOpen(isOpen)
|
||||
val inputState = isOpen.toString()
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
MainActivity.flutterMethodChannel?.invokeMethod(
|
||||
|
||||
@@ -254,6 +254,7 @@ class MainService : Service() {
|
||||
val homePath = applicationContext.getExternalFilesDir(null)?.absolutePath
|
||||
?: applicationContext.filesDir.absolutePath
|
||||
FFI.startServer(configPath, homePath, "")
|
||||
FFI.setInputServiceOpen(InputService.isOpen)
|
||||
|
||||
createForegroundNotification()
|
||||
}
|
||||
|
||||
@@ -29,4 +29,5 @@ object FFI {
|
||||
external fun onClipboardUpdate(clips: ByteBuffer)
|
||||
external fun isServiceClipboardEnabled(): Boolean
|
||||
external fun setDocumentLogsEnabled(enabled: Boolean)
|
||||
external fun setInputServiceOpen(open: Boolean)
|
||||
}
|
||||
@@ -212,7 +212,7 @@ class _TerminalPageState extends State<TerminalPage>
|
||||
focusNode: _terminalFocusNode,
|
||||
// Note: autofocus is not used here because focus is managed manually
|
||||
// via _onTabStateChanged() to handle tab switching properly.
|
||||
backgroundOpacity: 0.7,
|
||||
backgroundOpacity: 1.0,
|
||||
padding: _calculatePadding(heightPx),
|
||||
onSecondaryTapDown: (details, offset) async {
|
||||
final selection = _terminalModel.terminalController.selection;
|
||||
|
||||
@@ -20,7 +20,7 @@ import 'package:xterm/xterm.dart';
|
||||
import '../../desktop/pages/terminal_connection_manager.dart';
|
||||
import '../../consts.dart';
|
||||
|
||||
const _terminalBackgroundOpacity = 0.7;
|
||||
const _terminalBackgroundOpacity = 1.0;
|
||||
|
||||
Widget _buildTerminalViewForPlatform({
|
||||
required bool reportMouseInput,
|
||||
|
||||
@@ -191,8 +191,8 @@ class ServerModel with ChangeNotifier {
|
||||
});
|
||||
}
|
||||
|
||||
// Initial keyboard status is off on mobile
|
||||
if (isMobile) {
|
||||
// Initial keyboard status is off on iOS; Android syncs it from InputService natively.
|
||||
if (isIOS) {
|
||||
bind.mainSetOption(key: kOptionEnableKeyboard, value: 'N');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,16 @@ impl Drop for SimpleCallOnReturn {
|
||||
}
|
||||
}
|
||||
|
||||
/// `sodium_init()` chooses libsodium's implementations, so it runs before anything else uses the
|
||||
/// library: a later call swaps Poly1305 under a computation another thread is in the middle of.
|
||||
pub fn init_sodium() {
|
||||
if hbb_common::sodiumoxide::init().is_err() {
|
||||
log::error!("Failed to initialize libsodium");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn global_init() -> bool {
|
||||
init_sodium();
|
||||
#[cfg(all(target_os = "linux", feature = "drm"))]
|
||||
crate::platform::linux::dispatch_wayland_display_probe();
|
||||
#[cfg(target_os = "linux")]
|
||||
|
||||
@@ -41,6 +41,8 @@ lazy_static::lazy_static! {
|
||||
}
|
||||
|
||||
fn initialize(app_dir: &str, custom_client_config: &str) {
|
||||
// On mobile `global_init` below comes after the custom client's signature is verified.
|
||||
crate::common::init_sodium();
|
||||
flutter::async_tasks::start_flutter_async_runner();
|
||||
// `APP_DIR` is set in `main_get_data_dir_ios()` on iOS.
|
||||
#[cfg(not(target_os = "ios"))]
|
||||
@@ -3087,6 +3089,8 @@ pub mod server_side {
|
||||
custom_client_config: JString,
|
||||
) {
|
||||
log::debug!("startServer from jvm");
|
||||
// Started at boot, the service runs without the Flutter side and its `initialize`.
|
||||
crate::common::init_sodium();
|
||||
let mut env = env;
|
||||
if let Ok(app_dir) = env.get_string(&app_dir) {
|
||||
*config::APP_DIR.write().unwrap() = app_dir.into();
|
||||
@@ -3186,4 +3190,22 @@ pub mod server_side {
|
||||
) -> jboolean {
|
||||
jboolean::from(crate::server::is_clipboard_service_ok())
|
||||
}
|
||||
|
||||
/// Keeps `enable-keyboard` in step with InputService when the Flutter UI is not running.
|
||||
#[no_mangle]
|
||||
pub unsafe extern "system" fn Java_ffi_FFI_setInputServiceOpen(
|
||||
_env: JNIEnv,
|
||||
_class: JClass,
|
||||
open: jboolean,
|
||||
) {
|
||||
// Config must not load before startServer sets APP_DIR; MainService syncs again after it.
|
||||
if config::APP_DIR.read().unwrap().is_empty() {
|
||||
return;
|
||||
}
|
||||
let key = super::keys::OPTION_ENABLE_KEYBOARD;
|
||||
let value = if open == 0 { "N" } else { "Y" };
|
||||
if let Err(e) = super::main_set_option(key.to_owned(), value.to_owned()) {
|
||||
log::error!("Failed to sync input service state: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+56
-1
@@ -4432,7 +4432,7 @@ pub fn try_set_window_foreground(window: HWND) {
|
||||
}
|
||||
|
||||
pub mod reg_display_settings {
|
||||
use hbb_common::ResultType;
|
||||
use hbb_common::{bail, ResultType};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use winreg::{enums::*, RegValue};
|
||||
@@ -4496,6 +4496,7 @@ pub mod reg_display_settings {
|
||||
}
|
||||
|
||||
pub fn restore_reg_connectivity(reg_recovery: RegRecovery, force: bool) -> ResultType<()> {
|
||||
connectivity_subkey(®_recovery)?;
|
||||
let hklm = winreg::RegKey::predef(HKEY_LOCAL_MACHINE);
|
||||
let reg_item = hklm.open_subkey_with_flags(®_recovery.path, KEY_READ | KEY_WRITE)?;
|
||||
if !force {
|
||||
@@ -4537,6 +4538,60 @@ pub mod reg_display_settings {
|
||||
_ => RegType::REG_NONE,
|
||||
}
|
||||
}
|
||||
|
||||
fn connectivity_subkey(recovery: &RegRecovery) -> ResultType<&str> {
|
||||
let prefix = format!("{}\\{}\\", REG_GRAPHICS_DRIVERS_PATH, REG_CONNECTIVITY_PATH);
|
||||
let Some(subkey) = recovery.path.strip_prefix(&prefix) else {
|
||||
bail!("Invalid display connectivity recovery target");
|
||||
};
|
||||
if recovery.key != "Recent"
|
||||
|| subkey.is_empty()
|
||||
|| matches!(subkey, "." | "..")
|
||||
|| subkey.chars().any(|c| matches!(c, '\\' | '/' | '\0'))
|
||||
{
|
||||
bail!("Invalid display connectivity recovery target");
|
||||
}
|
||||
Ok(subkey)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use winreg::types::ToRegValue;
|
||||
|
||||
#[test]
|
||||
fn registry_recovery_rejects_external_targets_before_access() {
|
||||
for force in [false, true] {
|
||||
let recovery = RegRecovery {
|
||||
path: format!("SOFTWARE\\RustDesk\\{}", uuid::Uuid::new_v4()),
|
||||
key: "Recent".to_owned(),
|
||||
old: (vec![0x22; 4], RegType::REG_DWORD as isize),
|
||||
new: (vec![0x11; 4], RegType::REG_DWORD as isize),
|
||||
};
|
||||
let error = restore_reg_connectivity(recovery, force).unwrap_err();
|
||||
assert_eq!(
|
||||
error.to_string(),
|
||||
"Invalid display connectivity recovery target"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn registry_recovery_accepts_display_changes() {
|
||||
let connectivity = |value: &str| {
|
||||
HashMap::from([(
|
||||
"monitor".to_owned(),
|
||||
HashMap::from([("Recent".to_owned(), value.to_reg_value())]),
|
||||
)])
|
||||
};
|
||||
let recovery = diff_recent_connectivity(
|
||||
connectivity("before"),
|
||||
connectivity("after-layout-change"),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(connectivity_subkey(&recovery).unwrap(), "monitor");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_printer_names() -> ResultType<Vec<String>> {
|
||||
|
||||
@@ -802,10 +802,15 @@ impl Connection {
|
||||
}
|
||||
ipc::Data::SwitchPermission{name, enabled} => {
|
||||
log::info!("Change permission {} -> {}", name, enabled);
|
||||
// Android broadcasts these to every connection; only remote sessions use them.
|
||||
if (&name == "keyboard" || &name == "clipboard") && !conn.is_remote() {
|
||||
continue;
|
||||
}
|
||||
if &name == "keyboard" {
|
||||
conn.keyboard = enabled;
|
||||
conn.send_permission(Permission::Keyboard, enabled).await;
|
||||
if let Some(s) = conn.server.upgrade() {
|
||||
// Until authorized, only record the value; try_sub_monitor_services subscribes from it.
|
||||
if let Some(s) = conn.server.upgrade().filter(|_| conn.authorized) {
|
||||
s.write().unwrap().subscribe(
|
||||
super::clipboard_service::NAME,
|
||||
conn.inner.clone(), conn.can_sub_clipboard_service());
|
||||
@@ -822,7 +827,7 @@ impl Connection {
|
||||
} else if &name == "clipboard" {
|
||||
conn.clipboard = enabled;
|
||||
conn.send_permission(Permission::Clipboard, enabled).await;
|
||||
if let Some(s) = conn.server.upgrade() {
|
||||
if let Some(s) = conn.server.upgrade().filter(|_| conn.authorized) {
|
||||
s.write().unwrap().subscribe(
|
||||
super::clipboard_service::NAME,
|
||||
conn.inner.clone(), conn.can_sub_clipboard_service());
|
||||
@@ -853,7 +858,7 @@ impl Connection {
|
||||
conn.try_empty_file_clipboard();
|
||||
}
|
||||
#[cfg(feature = "unix-file-copy-paste")]
|
||||
if let Some(s) = conn.server.upgrade() {
|
||||
if let Some(s) = conn.server.upgrade().filter(|_| conn.authorized) {
|
||||
s.write().unwrap().subscribe(
|
||||
super::clipboard_service::FILE_NAME,
|
||||
conn.inner.clone(),
|
||||
@@ -3198,6 +3203,11 @@ impl Connection {
|
||||
if self.is_authed_view_camera_conn() {
|
||||
return true;
|
||||
}
|
||||
#[cfg(target_os = "android")]
|
||||
if !self.peer_keyboard_enabled() {
|
||||
self.update_auto_disconnect_timer();
|
||||
return true;
|
||||
}
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
if let Err(e) = call_main_service_pointer_input("mouse", me.mask, me.x, me.y) {
|
||||
log::debug!("call_main_service_pointer_input fail:{}", e);
|
||||
@@ -3237,6 +3247,11 @@ impl Connection {
|
||||
if self.is_authed_view_camera_conn() {
|
||||
return true;
|
||||
}
|
||||
#[cfg(target_os = "android")]
|
||||
if !self.peer_keyboard_enabled() {
|
||||
self.update_auto_disconnect_timer();
|
||||
return true;
|
||||
}
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
if let Err(e) = match pde.union {
|
||||
Some(pointer_device_event::Union::TouchEvent(touch)) => match touch.union {
|
||||
@@ -3279,6 +3294,9 @@ impl Connection {
|
||||
if self.is_authed_view_camera_conn() {
|
||||
return true;
|
||||
}
|
||||
if !self.peer_keyboard_enabled() {
|
||||
return true;
|
||||
}
|
||||
let key = match me.mode.enum_value() {
|
||||
Ok(KeyboardMode::Map) => {
|
||||
Some(crate::keyboard::keycode_to_rdev_key(me.chr()))
|
||||
|
||||
Reference in new issue
Block a user