mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #4940] [Feature Request] Add subClashRules Support for Generated Clash/Mihomo Subscriptions #3462
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#3462
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @zencreek on GitHub (Jun 5, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4940
Is your feature request related to a problem?
Currently, 3x-ui can generate Clash/Mihomo subscriptions, but the generated YAML configuration only contains the default routing rules.
For self-hosted users, it is very common to use custom routing rules such as:
At the moment, users must:
This makes subscription management more complicated than necessary.
Existing Behavior
3x-ui already provides
subJsonRulesfor generated JSON subscriptions, allowing administrators to prepend custom routing rules to client configurations.However, there is currently no equivalent feature for Clash/Mihomo subscriptions.
Describe the solution you'd like
Add a new optional setting in:
Example:
or
When generating Clash/Mihomo subscriptions, 3x-ui should inject these rules before the final catch-all rule.
Generated example:
Optional Enhancement
Support both:
and
for maximum flexibility.
Although
prepend-ruleswould be the primary use case, allowing both options would make the feature more versatile for advanced users.Benefits
subJsonRulesfunctionalityAdditional Notes
This feature would be conceptually similar to the existing
subJsonRulesimplementation, but targeted at Clash/Mihomo YAML subscriptions.Since 3x-ui already supports custom rule injection for JSON subscriptions, extending a similar mechanism to Clash/Mihomo subscriptions would provide a consistent subscription management experience across different client types.
Alternatives you've considered
No response
Concrete use case
No response
Mockups, screenshots, or examples
No response
Which parts of the panel would this affect?
Subscription (share links / Clash / JSON)
Are you willing to help?
Before submitting
@github-actions[bot] commented on GitHub (Jun 5, 2026):
Good news — this feature is already implemented in the current codebase.
How to enable it
Go to Panel Settings → Subscription → General tab. Scroll to the Clash / Mihomo section. You will find two controls:
subClashEnableRouting) — toggle this on. Rules are only injected when this is enabled.subClashRules) — paste your custom rules here, one per line (no YAML header needed).Input format — plain text, one rule per line:
Or as a YAML sequence:
How rules are applied
Custom rules are prepended before the catch-all
MATCH,PROXYrule, producing exactly the output you described. If your custom rules already include aMATCHrule, they replace the defaults entirely rather than being prepended.Implementation references
web/entity/entity.go—SubClashRules/SubClashEnableRoutingfieldsweb/service/setting.go—GetSubClashRules()/GetSubClashEnableRouting()sub/subClashService.go—mergeClashRulesYAML()/mergeClashRules()frontend/src/pages/settings/SubscriptionGeneralTab.tsx— UI controls