An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.
Rust androidanydeskdartflatpakflutterflutter-appsioslinuxmacosp2prdpremote-controlremote-desktoprustrust-langteamviewervncwaylandwindows
refactor is_public
rustdeskc45f7d2dd222
diff --git a/src/common.rs b/src/common.rsindex 6a8d39e27..e6993d074 100644--- a/src/common.rs+++ b/src/common.rs@@ -1087,8 +1087,15 @@ fn get_api_server_(api: String, custom: String) -> String {#[inline]pub fn is_public(url: &str) -> bool {- let url = url.to_ascii_lowercase();- url.contains(".rustdesk.com")+ let parsed = url::Url::parse(url)+ .ok()+ .filter(|parsed| parsed.has_host())+ .or_else(|| url::Url::parse(&format!("http://{url}")).ok());+ let Some(host) = parsed.as_ref().and_then(url::Url::host_str) else {+ return false;+ };+ let host = host.strip_suffix('.').unwrap_or(host);+ host == "rustdesk.com" || host.ends_with(".rustdesk.com")}pub fn get_udp_punch_enabled() -> bool {@@ -2880,6 +2887,16 @@ mod tests {assert!(!is_public("rustdesk.comhello.com"));}+ #[test]+ fn test_is_public_matches_rustdesk_root_domain() {+ assert!(is_public("rustdesk.com/"));+ assert!(is_public("rustdesk.com:21117"));+ assert!(is_public("api.rustdesk.com:21117"));+ assert!(!is_public("hello-rustdesk.com"));+ assert!(!is_public("api.rustdesk.com.evil.test"));+ assert!(!is_public("https://[email protected]"));+ }+#[test]fn test_should_use_tcp_proxy_for_api_url() {assert!(should_use_tcp_proxy_for_api_url(