refactor: simplify proxy type handling and improve error handling in network commands

This commit is contained in:
Tunglies
2025-05-16 00:09:34 +08:00
parent 92ae277e3a
commit 53a46d0dc6
11 changed files with 30 additions and 35 deletions

View File

@@ -1,4 +1,4 @@
use std::fmt::{self, write};
use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Type {

View File

@@ -274,10 +274,10 @@ impl NetworkManager {
}
match proxy_type {
ProxyType::NoProxy => {
ProxyType::None => {
builder = builder.no_proxy();
}
ProxyType::SelfProxy => {
ProxyType::Localhost => {
let port = Config::verge()
.latest()
.verge_mixed_port
@@ -295,7 +295,7 @@ impl NetworkManager {
builder = builder.proxy(proxy);
}
}
ProxyType::SystemProxy => {
ProxyType::System => {
use sysproxy::Sysproxy;
if let Ok(p @ Sysproxy { enable: true, .. }) = Sysproxy::get_system_proxy() {
@@ -420,7 +420,7 @@ impl NetworkManager {
/// 代理类型
#[derive(Debug, Clone, Copy)]
pub enum ProxyType {
NoProxy,
SelfProxy,
SystemProxy,
None,
Localhost,
System,
}