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,7 +4,7 @@ use axum::{extract::State, Json};
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::rustdesk::config::{PublicServerInfo, RustDeskConfig};
|
||||
use crate::rustdesk::config::RustDeskConfig;
|
||||
use crate::state::AppState;
|
||||
|
||||
use super::apply::apply_rustdesk_config;
|
||||
@@ -23,8 +23,6 @@ pub struct RustDeskConfigResponse {
|
||||
pub has_keypair: bool,
|
||||
/// 是否已设置 relay key
|
||||
pub has_relay_key: bool,
|
||||
/// 是否使用公共服务器(用户留空时)
|
||||
pub using_public_server: bool,
|
||||
}
|
||||
|
||||
impl From<&RustDeskConfig> for RustDeskConfigResponse {
|
||||
@@ -37,7 +35,6 @@ impl From<&RustDeskConfig> for RustDeskConfigResponse {
|
||||
has_password: !config.device_password.is_empty(),
|
||||
has_keypair: config.public_key.is_some() && config.private_key.is_some(),
|
||||
has_relay_key: config.relay_key.is_some(),
|
||||
using_public_server: config.is_using_public_server(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,8 +45,6 @@ pub struct RustDeskStatusResponse {
|
||||
pub config: RustDeskConfigResponse,
|
||||
pub service_status: String,
|
||||
pub rendezvous_status: Option<String>,
|
||||
/// 公共服务器信息(仅当有公共服务器配置时返回)
|
||||
pub public_server: Option<PublicServerInfo>,
|
||||
}
|
||||
|
||||
/// 获取 RustDesk 配置
|
||||
@@ -73,14 +68,10 @@ pub async fn get_rustdesk_status(State(state): State<Arc<AppState>>) -> Json<Rus
|
||||
}
|
||||
};
|
||||
|
||||
// 获取公共服务器信息
|
||||
let public_server = RustDeskConfig::public_server_info();
|
||||
|
||||
Json(RustDeskStatusResponse {
|
||||
config: RustDeskConfigResponse::from(&config),
|
||||
service_status,
|
||||
rendezvous_status,
|
||||
public_server,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1814,35 +1814,62 @@ pub struct IceServerInfo {
|
||||
}
|
||||
|
||||
/// Get ICE servers configuration for client-side WebRTC
|
||||
/// Returns user-configured servers, or Google STUN as fallback if none configured
|
||||
pub async fn webrtc_ice_servers(State(state): State<Arc<AppState>>) -> Json<IceServersResponse> {
|
||||
use crate::webrtc::config::public_ice;
|
||||
|
||||
let config = state.config.get();
|
||||
let mut ice_servers = Vec::new();
|
||||
|
||||
// Add STUN server
|
||||
if let Some(ref stun) = config.stream.stun_server {
|
||||
if !stun.is_empty() {
|
||||
// Check if user has configured custom ICE servers
|
||||
let has_custom_stun = config
|
||||
.stream
|
||||
.stun_server
|
||||
.as_ref()
|
||||
.map(|s| !s.is_empty())
|
||||
.unwrap_or(false);
|
||||
let has_custom_turn = config
|
||||
.stream
|
||||
.turn_server
|
||||
.as_ref()
|
||||
.map(|s| !s.is_empty())
|
||||
.unwrap_or(false);
|
||||
|
||||
if has_custom_stun || has_custom_turn {
|
||||
// Use user-configured ICE servers
|
||||
if let Some(ref stun) = config.stream.stun_server {
|
||||
if !stun.is_empty() {
|
||||
ice_servers.push(IceServerInfo {
|
||||
urls: vec![stun.clone()],
|
||||
username: None,
|
||||
credential: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ref turn) = config.stream.turn_server {
|
||||
if !turn.is_empty() {
|
||||
let username = config.stream.turn_username.clone();
|
||||
let credential = config.stream.turn_password.clone();
|
||||
if username.is_some() && credential.is_some() {
|
||||
ice_servers.push(IceServerInfo {
|
||||
urls: vec![turn.clone()],
|
||||
username,
|
||||
credential,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// No custom servers configured - use Google STUN as default
|
||||
if let Some(stun) = public_ice::stun_server() {
|
||||
ice_servers.push(IceServerInfo {
|
||||
urls: vec![stun.clone()],
|
||||
urls: vec![stun],
|
||||
username: None,
|
||||
credential: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Add TURN server (with credentials)
|
||||
if let Some(ref turn) = config.stream.turn_server {
|
||||
if !turn.is_empty() {
|
||||
let username = config.stream.turn_username.clone();
|
||||
let credential = config.stream.turn_password.clone();
|
||||
// Only add TURN if credentials are provided
|
||||
if username.is_some() && credential.is_some() {
|
||||
ice_servers.push(IceServerInfo {
|
||||
urls: vec![turn.clone()],
|
||||
username,
|
||||
credential,
|
||||
});
|
||||
}
|
||||
}
|
||||
// Note: TURN servers are not provided - users must configure their own
|
||||
}
|
||||
|
||||
Json(IceServersResponse { ice_servers })
|
||||
|
||||
Reference in New Issue
Block a user