fix: 修复 direct 因透明代理循环代理的问题
This commit is contained in:
@@ -17,7 +17,7 @@ def generate_xray_config(node: Node, settings: XrayConfigSettings | None = None)
|
||||
"inbounds": _build_inbounds(settings),
|
||||
"outbounds": [
|
||||
node_to_outbound(node, settings, tag="proxy"),
|
||||
direct_outbound(),
|
||||
direct_outbound(settings),
|
||||
block_outbound(),
|
||||
dns_outbound(),
|
||||
],
|
||||
|
||||
@@ -25,9 +25,12 @@ def node_to_outbound(node: Node, settings: XrayConfigSettings, tag: str = "proxy
|
||||
return outbound
|
||||
|
||||
|
||||
def direct_outbound() -> dict[str, Any]:
|
||||
def direct_outbound(settings: XrayConfigSettings | None = None) -> dict[str, Any]:
|
||||
"""生成 v2rayA 使用的 direct outbound。"""
|
||||
return {"tag": "direct", "protocol": "freedom", "settings": {"domainStrategy": "UseIP"}}
|
||||
outbound: dict[str, Any] = {"tag": "direct", "protocol": "freedom", "settings": {"domainStrategy": "UseIP"}}
|
||||
if settings is not None:
|
||||
_apply_transparent_mark(outbound, settings)
|
||||
return outbound
|
||||
|
||||
|
||||
def block_outbound() -> dict[str, Any]:
|
||||
|
||||
@@ -136,6 +136,7 @@ def test_generate_redirect_dns_inbound_when_transparent_redirect_enabled() -> No
|
||||
assert _inbound(config, "dns-in")["listen"] == "127.2.0.17"
|
||||
assert {"type": "field", "inboundTag": ["dns-in"], "outboundTag": "dns-out"} in config["routing"]["rules"]
|
||||
assert _outbound(config, "proxy")["streamSettings"]["sockopt"]["mark"] == 128
|
||||
assert _outbound(config, "direct")["streamSettings"]["sockopt"]["mark"] == 128
|
||||
|
||||
|
||||
def test_generate_redirect_transparent_inbound_stays_local_when_docker_transparent_disabled() -> None:
|
||||
|
||||
Reference in New Issue
Block a user