-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[Feature Request] Add option 'route_only' for resolve action #3083
Description
据我在 #3068 描述的问题,在 route 规则进行 resolve action 后,出站中的域名会从 Domain:Port 变成 IP:Port 形式发送给服务器端,经 @reF1nd 查看后得知此为 expected behavior。
此时服务器端入站接收到的请求为 IP:Port,如果我需要在服务器端进一步实现某些依赖 Domain 的分流规则,则需借助 Protocol Sniff,但据文档所述,Listen Fields 中的 sniff 和 sniff_override_destination 选项已被标记为 Deprecated,而新版 sniff action 的用法并不支持 sniff_override_destination 这类选项,导致我目前不得不使用 deprecated options 以及 sniff 这个偏方来实现我的需求。
我在 #3048 看到开发者 @dyhkwong 的解释是这个 Feature 原本是从 V2Ray 继承过来的 bad behavior,所以新版 sniff action 明确删除了这个选项。
我希望开发者们可以酌情考虑下实际使用场景的需求,在 resolve action 中增加 route_only 选项:
"rules":
[
{
"action": "resolve",
"route_only": true
}
]
如果 route_only 被设为 true,则请求还是以 Domain:Port 形式发送给服务器端,这样用户就可以在服务器端根据 Domain 做进一步处理。
目前由于没有这个 Feature,我只能在服务器端使用已被标记为 Deprecated 的 sniff_override_destination 选项,这还会导致 Domain 在服务器端被二次解析,如果不在客户端进行 resolve action,又会导致基于 IP 地址的 ruleset 无法生效。
相关 Issues 还有 #2775,但是他所描述的 DNS 解析问题我认为不存在,因为即使是客户端进行 resolve action 也能在 dns server 里指定 detour 给服务器端出站,但是在 resolve action 中加入这么一个开关确实有一定的必要性。
我已通过 Github Sponsor 捐助以支持开发者维护 sing-box 项目,并有意成为长期 Sponsor,感谢各位开发者的维护。