fix(SingBox): inject DIRECT route rule for panel domain#940
Open
daidaidaiok wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SingBox::buildRule()previously readroute.rulesand 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()andStash::buildRules(): unshift a{domain: [host], outbound: direct}rule at the head ofroute.rulesso the panel host always bypasses the proxy.Before
After
Test plan
route.rules[0]contains the panel host withoutbound: direct.Hostheader is absent orroute.rulesis missing.🤖 Generated with Claude Code