fix: linux tun timeout (#4993)

* fix: linux tun timeout

* docs: UPDATELOG.md
This commit is contained in:
Sline
2025-10-09 15:09:17 +08:00
committed by GitHub
parent 44280b23e4
commit 5db4677ff8
3 changed files with 24 additions and 0 deletions

View File

@@ -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());

View File

@@ -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);