添加代理主机的设置,允许代理设置为其他IP(非127.0.0.1) (#2963)

允许下拉选择ip地址(支持IPv6)、localhost、以及当前系统的主机名,同时兼容手工输入
This commit is contained in:
逐雁南飛
2025-04-16 10:22:53 +08:00
committed by Tunglies
parent 1282cc56bf
commit b70cad537c
17 changed files with 223 additions and 21 deletions

View File

@@ -31,6 +31,25 @@ pub fn get_auto_proxy() -> CmdResult<Mapping> {
Ok(map)
}
/// 获取系统主机名
#[tauri::command]
pub fn get_system_hostname() -> CmdResult<String> {
use gethostname::gethostname;
// 获取系统主机名处理可能的非UTF-8字符
let hostname = match gethostname().into_string() {
Ok(name) => name,
Err(os_string) => {
// 对于包含非UTF-8的主机名使用调试格式化
let fallback = format!("{:?}", os_string);
// 去掉可能存在的引号
fallback.trim_matches('"').to_string()
}
};
Ok(hostname)
}
/// 获取网络接口列表
#[tauri::command]
pub fn get_network_interfaces() -> Vec<String> {