mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
- Renamed `cmds` module to `cmd` for better naming consistency - Reorganized command modules into separate files under src/cmd/ - Updated all imports and references to use the new module name - Fixed missing dependency in webdav.rs to reference core::backup - Updated tray module to use new cmd namespace - Improved uwp.rs module structure using platform-specific implementations - Removed unnecessary imports from various command files
65 lines
1.7 KiB
Rust
65 lines
1.7 KiB
Rust
use crate::wrap_err;
|
|
use super::CmdResult;
|
|
use sysproxy::{Autoproxy, Sysproxy};
|
|
use serde_yaml::Mapping;
|
|
use network_interface::NetworkInterface;
|
|
|
|
/// get the system proxy
|
|
#[tauri::command]
|
|
pub fn get_sys_proxy() -> CmdResult<Mapping> {
|
|
let current = wrap_err!(Sysproxy::get_system_proxy())?;
|
|
let mut map = Mapping::new();
|
|
map.insert("enable".into(), current.enable.into());
|
|
map.insert(
|
|
"server".into(),
|
|
format!("{}:{}", current.host, current.port).into(),
|
|
);
|
|
map.insert("bypass".into(), current.bypass.into());
|
|
|
|
Ok(map)
|
|
}
|
|
|
|
/// get the system proxy
|
|
#[tauri::command]
|
|
pub fn get_auto_proxy() -> CmdResult<Mapping> {
|
|
let current = wrap_err!(Autoproxy::get_auto_proxy())?;
|
|
|
|
let mut map = Mapping::new();
|
|
map.insert("enable".into(), current.enable.into());
|
|
map.insert("url".into(), current.url.into());
|
|
|
|
Ok(map)
|
|
}
|
|
|
|
/// 获取网络接口列表
|
|
#[tauri::command]
|
|
pub fn get_network_interfaces() -> Vec<String> {
|
|
use sysinfo::Networks;
|
|
let mut result = Vec::new();
|
|
let networks = Networks::new_with_refreshed_list();
|
|
for (interface_name, _) in &networks {
|
|
result.push(interface_name.clone());
|
|
}
|
|
result
|
|
}
|
|
|
|
/// 获取网络接口详细信息
|
|
#[tauri::command]
|
|
pub fn get_network_interfaces_info() -> CmdResult<Vec<NetworkInterface>> {
|
|
use network_interface::NetworkInterface;
|
|
use network_interface::NetworkInterfaceConfig;
|
|
|
|
let names = get_network_interfaces();
|
|
let interfaces = wrap_err!(NetworkInterface::show())?;
|
|
|
|
let mut result = Vec::new();
|
|
|
|
for interface in interfaces {
|
|
if names.contains(&interface.name) {
|
|
result.push(interface);
|
|
}
|
|
}
|
|
|
|
Ok(result)
|
|
}
|