mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-09 00:01:28 +03:00
@@ -1051,7 +1051,7 @@ fn get_api_server_(api: String, custom: String) -> String {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_public(url: &str) -> bool {
|
pub fn is_public(url: &str) -> bool {
|
||||||
url.contains("rustdesk.com")
|
url.contains("rustdesk.com/") || url.ends_with("rustdesk.com")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_udp_punch_enabled() -> bool {
|
pub fn get_udp_punch_enabled() -> bool {
|
||||||
@@ -2405,4 +2405,27 @@ mod tests {
|
|||||||
Duration::from_nanos(0)
|
Duration::from_nanos(0)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_is_public() {
|
||||||
|
// Test URLs containing "rustdesk.com/"
|
||||||
|
assert!(is_public("https://rustdesk.com/"));
|
||||||
|
assert!(is_public("https://www.rustdesk.com/"));
|
||||||
|
assert!(is_public("https://api.rustdesk.com/v1"));
|
||||||
|
assert!(is_public("https://rustdesk.com/path"));
|
||||||
|
|
||||||
|
// Test URLs ending with "rustdesk.com"
|
||||||
|
assert!(is_public("rustdesk.com"));
|
||||||
|
assert!(is_public("https://rustdesk.com"));
|
||||||
|
assert!(is_public("http://www.rustdesk.com"));
|
||||||
|
assert!(is_public("https://api.rustdesk.com"));
|
||||||
|
|
||||||
|
// Test non-public URLs
|
||||||
|
assert!(!is_public("https://example.com"));
|
||||||
|
assert!(!is_public("https://custom-server.com"));
|
||||||
|
assert!(!is_public("http://192.168.1.1"));
|
||||||
|
assert!(!is_public("localhost"));
|
||||||
|
assert!(!is_public("https://rustdesk.computer.com"));
|
||||||
|
assert!(!is_public("rustdesk.comhello.com"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ fn heartbeat_url() -> String {
|
|||||||
Config::get_option("api-server"),
|
Config::get_option("api-server"),
|
||||||
Config::get_option("custom-rendezvous-server"),
|
Config::get_option("custom-rendezvous-server"),
|
||||||
);
|
);
|
||||||
if url.is_empty() || url.contains("rustdesk.com") {
|
if url.is_empty() || crate::is_public(&url) {
|
||||||
return "".to_owned();
|
return "".to_owned();
|
||||||
}
|
}
|
||||||
format!("{}/api/heartbeat", url)
|
format!("{}/api/heartbeat", url)
|
||||||
|
|||||||
Reference in New Issue
Block a user