diff --git a/UPDATELOG.md b/UPDATELOG.md index cf4b1a9e8..a47fb76de 100644 --- a/UPDATELOG.md +++ b/UPDATELOG.md @@ -22,6 +22,7 @@ - 移除流媒体检测的系统级提示(使用软件内通知) - 优化后端 i18n 资源占用 - 改进 Linux 托盘支持并添加 `--no-tray` 选项 +- Linux 现在在新生成的配置中默认将 TUN 栈恢复为 mixed 模式 ### 🐞 修复问题 diff --git a/src-tauri/src/config/clash.rs b/src-tauri/src/config/clash.rs index a46874e06..f99fa3d8d 100644 --- a/src-tauri/src/config/clash.rs +++ b/src-tauri/src/config/clash.rs @@ -51,6 +51,9 @@ impl IClashTemp { let mut tun = Mapping::new(); let mut cors_map = Mapping::new(); tun.insert("enable".into(), false.into()); + #[cfg(target_os = "linux")] + tun.insert("stack".into(), "mixed".into()); + #[cfg(not(target_os = "linux"))] tun.insert("stack".into(), "gvisor".into()); tun.insert("auto-route".into(), true.into()); tun.insert("strict-route".into(), false.into()); diff --git a/src-tauri/src/enhance/tun.rs b/src-tauri/src/enhance/tun.rs index 5f81a99f1..d019960a2 100644 --- a/src-tauri/src/enhance/tun.rs +++ b/src-tauri/src/enhance/tun.rs @@ -29,6 +29,26 @@ pub fn use_tun(mut config: Mapping, enable: bool) -> Mapping { }); if enable { + #[cfg(target_os = "linux")] + { + let stack_key = Value::from("stack"); + let should_override = match tun_val.get(&stack_key) { + Some(value) => value + .as_str() + .map(|stack| stack.eq_ignore_ascii_case("gvisor")) + .unwrap_or(false), + None => true, + }; + + if should_override { + revise!(tun_val, "stack", "mixed"); + log::warn!( + target: "app", + "gVisor TUN stack detected on Linux; falling back to 'mixed' for compatibility" + ); + } + } + // 读取DNS配置 let dns_key = Value::from("dns"); let dns_val = config.get(&dns_key);