Skip to content

Tun protect#8779

Merged
2dust merged 5 commits into2dust:masterfrom
DHR60:tun_protect
Feb 26, 2026
Merged

Tun protect#8779
2dust merged 5 commits into2dust:masterfrom
DHR60:tun_protect

Conversation

@DHR60
Copy link
Copy Markdown
Contributor

@DHR60 DHR60 commented Feb 8, 2026

基于 #8768

彻底解决因双核心回环导致的 TUN 不可用问题

sing-box 开启一个直连出站的 protect 入站,xray 将其作为前置代理,解决因 DNS 以及进程嗅探失败等原因导致的 TUN 不可用

@DHR60
Copy link
Copy Markdown
Contributor Author

DHR60 commented Feb 9, 2026

diff: DHR60/v2rayN@refactor_config_gen...tun_protect

删除了启用额外监听端口

尽可能将 protect 这部分分离而不是整合到现有代码中,以便 xray tun 完善后将这部分删除
所以看起来实现有点丑

@DHR60 DHR60 force-pushed the tun_protect branch 3 times, most recently from 3314b4a to f7a1e43 Compare February 15, 2026 09:02
@DHR60 DHR60 marked this pull request as ready for review February 24, 2026 15:45
public bool IsTunEnabled { get; init; } = false;
public HashSet<string> ProtectDomainList { get; init; } = new();
public int ProtectSocksPort { get; init; } = 0;
// -> tun inbound --(if routing proxy)--> relay outbound
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

逻辑没有问题,但是不知道实际使用能解决多少问题?
如果开了tun,并且把策略组等都打开,这个配置文件看的头大了

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dial 到实际网口出口只由 sing-box 负责
可能就只能解决进程嗅探失败导致回环还有 DNS 回环问题

其他的像是什么规则集下载失败,系统原因什么的应该解决不了

所以大概最多最多也就解决三成用户的 TUN 不可用

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这么说可能 xray 的 ech 还有点问题,ech config 是 xray 自己 dial 获取的

不管了,xray ech 这部分就忽略吧

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还有 xray 的 Wireguard 应该也有问题,Wireguard 不允许传递域名,所以 xray 会自行将其解析为 IP。

DNS Protect 不好写,这个也不管了

@2dust
Copy link
Copy Markdown
Owner

2dust commented Feb 26, 2026

测试了以下都通过:

  • tun + xray (单一或策略组)
  • tun + sing-box
  • tun + 自定义 + socks端口
  • 自定义 + socks端口

分片等合并后面的 PR 再试

@DHR60
Copy link
Copy Markdown
Contributor Author

DHR60 commented Feb 26, 2026

分片 pick 过来测试了下没问题

tun + xray (单一或策略组)

图片

@2dust 2dust merged commit 3c1ecf0 into 2dust:master Feb 26, 2026
@DHR60 DHR60 deleted the tun_protect branch February 26, 2026 13:42
@goffgoff888
Copy link
Copy Markdown

你好,这个管用,之前的所有的版本都会莫名其妙的网络突然不行,开关就可以,有的时候整个软件都使用不了,用了这个版本,我就没有出现这个问题过,开的tun 模式,使用了singlebox

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants