Skip to content

Commit

Permalink
compelete fix rustdesk#10210
Browse files Browse the repository at this point in the history
rather than the awful workaround
  • Loading branch information
rustdesk committed Jan 1, 2025
1 parent 4f3b821 commit ef90ab2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 54 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ crate-type = ["cdylib", "staticlib", "rlib"]
name = "naming"
path = "src/naming.rs"

[[bin]]
name = "service"
path = "src/service.rs"

[features]
inline = []
cli = []
Expand Down
3 changes: 2 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,13 @@ def build_flutter_dmg(version, features):
if not skip_cargo:
# set minimum osx build target, now is 10.14, which is the same as the flutter xcode project
system2(
f'MACOSX_DEPLOYMENT_TARGET=10.14 cargo build --features {features} --lib --release')
f'MACOSX_DEPLOYMENT_TARGET=10.14 cargo build --features {features} --release')
# copy dylib
system2(
"cp target/release/liblibrustdesk.dylib target/release/librustdesk.dylib")
os.chdir('flutter')
system2('flutter build macos --release')
system2('cp -rf ../target/release/service ./build/macos/Build/Products/Release/RustDesk.app/Contents/MacOS/')
'''
system2(
"create-dmg --volname \"RustDesk Installer\" --window-pos 200 120 --window-size 800 400 --icon-size 100 --app-drop-link 600 185 --icon RustDesk.app 200 190 --hide-extension RustDesk.app rustdesk.dmg ./build/macos/Build/Products/Release/RustDesk.app")
Expand Down
8 changes: 4 additions & 4 deletions flutter/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ SPEC CHECKSUMS:
desktop_drop: 69eeff437544aa619c8db7f4481b3a65f7696898
desktop_multi_window: 566489c048b501134f9d7fb6a2354c60a9126486
device_info_plus: 5401765fde0b8d062a2f8eb65510fb17e77cf07f
file_selector_macos: 54fdab7caa3ac3fc43c9fac4d7d8d231277f8cf2
file_selector_macos: 468fb6b81fac7c0e88d71317f3eec34c3b008ff9
flutter_custom_cursor: 629957115075c672287bd0fa979d863ccf6024f7
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
package_info_plus: 02d7a575e80f194102bef286361c6c326e4c29ce
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
texture_rgba_renderer: cbed959a3c127122194a364e14b8577bd62dc8f2
uni_links_desktop: 45900fb319df48fcdea2df0756e9c2626696b026
url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399
video_player_avfoundation: 7c6c11d8470e1675df7397027218274b6d2360b3
url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95
video_player_avfoundation: 02011213dab73ae3687df27ce441fbbcc82b5579
wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269
window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8
window_size: 339dafa0b27a95a62a843042038fa6c3c48de195
Expand Down
2 changes: 1 addition & 1 deletion flutter/macos/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Cocoa
import FlutterMacOS

@NSApplicationMain
@main
class AppDelegate: FlutterAppDelegate {
var launched = false;
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
Expand Down
47 changes: 0 additions & 47 deletions src/platform/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,53 +515,6 @@ pub fn lock_screen() {

pub fn start_os_service() {
log::info!("Username: {}", crate::username());
let mut sys = System::new();
let path =
std::fs::canonicalize(std::env::current_exe().unwrap_or_default()).unwrap_or_default();
let mut server = get_server_start_time(&mut sys, &path);
if server.is_none() {
log::error!("Agent not started yet, please restart --server first to make delegate work",);
std::process::exit(-1);
}
let my_start_time = sys
.process((std::process::id() as usize).into())
.map(|p| p.start_time())
.unwrap_or_default() as i64;
log::info!("Startime: {my_start_time} vs {:?}", server);

std::thread::spawn(move || loop {
std::thread::sleep(std::time::Duration::from_secs(1));
if server.is_none() {
server = get_server_start_time(&mut sys, &path);
}
let Some((start_time, pid)) = server else {
log::error!(
"Agent not started yet, please restart --server first to make delegate work",
);
std::process::exit(-1);
};
if my_start_time <= start_time + 3 {
log::error!(
"Agent start later, {my_start_time} vs {start_time}, please start --server first to make delegate work, earlier more 3 seconds",
);
std::process::exit(-1);
}
// only refresh this pid and check if valid, no need to refresh all processes since refreshing all is expensive, about 10ms on my machine
if !sys.refresh_process_specifics(pid, ProcessRefreshKind::new()) {
server = None;
continue;
}
if let Some(p) = sys.process(pid.into()) {
if let Some(p) = get_server_start_time_of(p, &path) {
server = Some((p, pid));
} else {
server = None;
}
} else {
server = None;
}
});

if let Err(err) = crate::ipc::start("_service") {
log::error!("Failed to start ipc_service: {}", err);
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform/privileges_scripts/daemon.plist
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<array>
<string>/bin/sh</string>
<string>-c</string>
<string>sleep 3; if pgrep -f '/Applications/RustDesk.app/Contents/MacOS/RustDesk --server' > /dev/null; then /Applications/RustDesk.app/Contents/MacOS/RustDesk --service; fi</string>
<string>/Applications/RustDesk.app/Contents/MacOS/service</string>
</array>
<key>RunAtLoad</key>
<true/>
Expand Down

0 comments on commit ef90ab2

Please sign in to comment.