From f644053811b380843996714e66d5f0c0da5b172a Mon Sep 17 00:00:00 2001 From: rustdesk Date: Mon, 11 Mar 2024 01:36:43 +0800 Subject: [PATCH] fix hostname for mac --- src/common.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/common.rs b/src/common.rs index dddeaddc2..b5c0c2c8c 100644 --- a/src/common.rs +++ b/src/common.rs @@ -865,7 +865,16 @@ pub fn username() -> String { #[inline] pub fn hostname() -> String { #[cfg(not(any(target_os = "android", target_os = "ios")))] - return whoami::hostname(); + { + #[allow(unused_mut)] + let mut name = whoami::hostname(); + // some time, there is .local, some time not, so remove it for osx + #[cfg(target_os = "macos")] + if name.ends_with(".local") { + name = name.trim_end_matches(".local").to_owned(); + } + name + } #[cfg(any(target_os = "android", target_os = "ios"))] return DEVICE_NAME.lock().unwrap().clone(); }