mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
feat!: 移除内置公共服务器
- 移除公共 RustDesk ID 服务器 (用户需自行配置) - 移除公共 TURN 服务器 (仅保留 Google STUN) - 清理废弃代码: PublicServerInfo, is_using_public_server 等 - 更新前端 UI 和国际化文本 - 重新生成 TypeScript 类型 破坏性变更: 不再提供内置公共服务器。用户必须配置自己的 RustDesk 服务器和 TURN 服务器才能在生产环境中使用。
This commit is contained in:
@@ -4,21 +4,21 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::secrets;
|
||||
|
||||
/// Public ICE server utilities
|
||||
/// ICE server utilities - Only provides Google STUN, no TURN
|
||||
pub mod public_ice {
|
||||
use super::*;
|
||||
|
||||
/// Check if public ICE servers are configured (at compile time)
|
||||
/// Always returns true (we have Google STUN)
|
||||
pub fn is_configured() -> bool {
|
||||
secrets::ice::is_configured()
|
||||
}
|
||||
|
||||
/// Check if public TURN servers are configured (requires credentials)
|
||||
/// Always returns false (TURN not provided)
|
||||
pub fn has_turn() -> bool {
|
||||
secrets::ice::has_turn()
|
||||
}
|
||||
|
||||
/// Get the public STUN server URL
|
||||
/// Get the Google STUN server URL
|
||||
pub fn stun_server() -> Option<String> {
|
||||
let server = secrets::ice::STUN_SERVER;
|
||||
if server.is_empty() {
|
||||
@@ -28,33 +28,15 @@ pub mod public_ice {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get public TURN servers as TurnServer structs
|
||||
/// Always returns empty vector (TURN not provided)
|
||||
pub fn turn_servers() -> Vec<TurnServer> {
|
||||
if !secrets::ice::has_turn() {
|
||||
return vec![];
|
||||
}
|
||||
|
||||
let urls: Vec<String> = secrets::ice::TURN_URLS
|
||||
.split(',')
|
||||
.map(|s| s.trim().to_string())
|
||||
.filter(|s| !s.is_empty())
|
||||
.collect();
|
||||
|
||||
if urls.is_empty() {
|
||||
return vec![];
|
||||
}
|
||||
|
||||
vec![TurnServer {
|
||||
urls,
|
||||
username: secrets::ice::TURN_USERNAME.to_string(),
|
||||
credential: secrets::ice::TURN_PASSWORD.to_string(),
|
||||
}]
|
||||
vec![]
|
||||
}
|
||||
|
||||
/// Get all public ICE servers (STUN + TURN) for WebRTC configuration
|
||||
/// Get all public ICE servers (STUN only, no TURN)
|
||||
pub fn get_all_servers() -> (Vec<String>, Vec<TurnServer>) {
|
||||
let stun_servers = stun_server().into_iter().collect();
|
||||
let turn_servers = turn_servers();
|
||||
let turn_servers = vec![];
|
||||
(stun_servers, turn_servers)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,46 +199,56 @@ impl PeerConnection {
|
||||
pc.on_data_channel(Box::new(move |dc: Arc<RTCDataChannel>| {
|
||||
let data_channel = data_channel.clone();
|
||||
let hid = hid_clone.clone();
|
||||
let label = dc.label().to_string();
|
||||
|
||||
Box::pin(async move {
|
||||
info!("Data channel opened with HID support: {}", dc.label());
|
||||
// Handle both reliable (hid) and unreliable (hid-unreliable) channels
|
||||
let is_hid_channel = label == "hid" || label == "hid-unreliable";
|
||||
|
||||
// Store data channel
|
||||
*data_channel.write().await = Some(dc.clone());
|
||||
if is_hid_channel {
|
||||
info!("HID DataChannel opened: {} (unreliable: {})", label, label == "hid-unreliable");
|
||||
|
||||
// Set up message handler with HID processing
|
||||
// Immediately spawn task in tokio runtime for low latency
|
||||
dc.on_message(Box::new(move |msg: DataChannelMessage| {
|
||||
let hid = hid.clone();
|
||||
// Store the reliable data channel for sending responses
|
||||
if label == "hid" {
|
||||
*data_channel.write().await = Some(dc.clone());
|
||||
}
|
||||
|
||||
tokio::spawn(async move {
|
||||
debug!("DataChannel HID message: {} bytes", msg.data.len());
|
||||
// Set up message handler with HID processing
|
||||
// Both channels use the same HID processing logic
|
||||
dc.on_message(Box::new(move |msg: DataChannelMessage| {
|
||||
let hid = hid.clone();
|
||||
|
||||
// Parse and process HID message
|
||||
if let Some(event) = parse_hid_message(&msg.data) {
|
||||
match event {
|
||||
HidChannelEvent::Keyboard(kb_event) => {
|
||||
if let Err(e) = hid.send_keyboard(kb_event).await {
|
||||
debug!("Failed to send keyboard event: {}", e);
|
||||
tokio::spawn(async move {
|
||||
debug!("DataChannel HID message: {} bytes", msg.data.len());
|
||||
|
||||
// Parse and process HID message
|
||||
if let Some(event) = parse_hid_message(&msg.data) {
|
||||
match event {
|
||||
HidChannelEvent::Keyboard(kb_event) => {
|
||||
if let Err(e) = hid.send_keyboard(kb_event).await {
|
||||
debug!("Failed to send keyboard event: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
HidChannelEvent::Mouse(ms_event) => {
|
||||
if let Err(e) = hid.send_mouse(ms_event).await {
|
||||
debug!("Failed to send mouse event: {}", e);
|
||||
HidChannelEvent::Mouse(ms_event) => {
|
||||
if let Err(e) = hid.send_mouse(ms_event).await {
|
||||
debug!("Failed to send mouse event: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
HidChannelEvent::Consumer(consumer_event) => {
|
||||
if let Err(e) = hid.send_consumer(consumer_event).await {
|
||||
debug!("Failed to send consumer event: {}", e);
|
||||
HidChannelEvent::Consumer(consumer_event) => {
|
||||
if let Err(e) = hid.send_consumer(consumer_event).await {
|
||||
debug!("Failed to send consumer event: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Return empty future (actual work is spawned above)
|
||||
Box::pin(async {})
|
||||
}));
|
||||
// Return empty future (actual work is spawned above)
|
||||
Box::pin(async {})
|
||||
}));
|
||||
} else {
|
||||
info!("Non-HID DataChannel opened: {}", label);
|
||||
}
|
||||
})
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user