Skip to content

fix(SingBox): inject DIRECT route rule for panel domain#940

Open
daidaidaiok wants to merge 1 commit into
cedar2025:masterfrom
daidaidaiok:fix/singbox-panel-domain-direct
Open

fix(SingBox): inject DIRECT route rule for panel domain#940
daidaidaiok wants to merge 1 commit into
cedar2025:masterfrom
daidaidaiok:fix/singbox-panel-domain-direct

Conversation

@daidaidaiok
Copy link
Copy Markdown

Summary

SingBox::buildRule() previously read route.rules and wrote it back unchanged — an empty hook. As a result, sing-box / hiddify / sfm users importing the subscription have the panel host (the very URL they pulled the subscription from) routed through their proxy outbound. When the outbound cannot reach the panel's origin IP (very common when the panel is hosted in mainland China and the outbound is overseas, or vice versa), the panel becomes unreachable after they enable the proxy.

This mirrors the behaviour already implemented in Clash::buildRules(), ClashMeta::buildRules() and Stash::buildRules(): unshift a {domain: [host], outbound: direct} rule at the head of route.rules so the panel host always bypasses the proxy.

Before

"route": {
  "rules": [
    { "outbound": "dns-out", "protocol": "dns" },
    { "clash_mode": "direct", "outbound": "direct" },
    ...
  ]
}

After

"route": {
  "rules": [
    { "domain": ["panel.example.com"], "outbound": "direct" },   // <- injected
    { "outbound": "dns-out", "protocol": "dns" },
    { "clash_mode": "direct", "outbound": "direct" },
    ...
  ]
}

Test plan

  • Patched on a live deployment, reloaded Octane, confirmed route.rules[0] contains the panel host with outbound: direct.
  • Existing rules (dns-out, clash_mode, geosite-cn, etc.) are preserved and ordered after the new rule.
  • No effect when Host header is absent or route.rules is missing.

🤖 Generated with Claude Code

The buildRule() method previously read the configured rules and wrote them
back unchanged, leaving an empty hook. As a result, sing-box / hiddify / sfm
users who import the subscription have the panel host routed through their
proxy outbound, frequently making the panel unreachable when the outbound
cannot reach the panel's origin IP.

Mirror the existing behaviour from Clash / ClashMeta / Stash protocols:
unshift a {domain: [host], outbound: direct} rule at the head of
route.rules so the panel host always bypasses the proxy.
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.

1 participant