[GH-ISSUE #5824] [Feature]: Add/Inject Routing Rules to JSON subscription #4045

Open
opened 2026-10-31 20:36:46 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @ilya-practicum on GitHub (Jul 5, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5824

Sometimes it is useful to set different routing rules for different inbounds. Currently, you cannot ship several routing profiles in one subscription also you cannot apply different routing profiles for specific inbounds.

Describe the solution you'd like

For each inbound creation/edit window add new tab called "Routing" where you can add custom JSON routing block (similar to advanced tab for inbound editing).

Alternatives you've considered

No response

Concrete use case

When user connects to JSON subscription endpoint that routing blocks will be injected in corresponding outbounds sections. The idea is to provide geoip/geosite databses and JSON routing rules simultaneously:

  1. Provide geosite/geoip databases with happ://routing/onadd profile
  2. Provide routing rules for each inbound via JSON subscription

That may be useful in situations when you have inbounds with different purposes - one for normal usage and other for Whitelist/AI/Torrent/etc.

Mockups, screenshots, or examples

No response

Which parts of the panel would this affect?

Frontend (UI / panel pages), Subscription (share links / Clash / JSON)

Are you willing to help?

  • I'd like to implement this feature myself and open a PR.
  • I can help test once a PR is open.

Before submitting

  • I searched existing issues and this feature has not been requested.
  • This feature request is written in English.
Originally created by @ilya-practicum on GitHub (Jul 5, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5824 ### Is your feature request related to a problem? Sometimes it is useful to set different routing rules for different inbounds. Currently, you cannot ship several routing profiles in one subscription also you cannot apply different routing profiles for specific inbounds. ### Describe the solution you'd like For each inbound creation/edit window add new tab called "Routing" where you can add custom JSON routing block (similar to advanced tab for inbound editing). ### Alternatives you've considered _No response_ ### Concrete use case When user connects to JSON subscription endpoint that routing blocks will be injected in corresponding outbounds sections. The idea is to provide geoip/geosite databses and JSON routing rules simultaneously: 1. Provide geosite/geoip databases with happ://routing/onadd profile 2. Provide routing rules for each inbound via JSON subscription That may be useful in situations when you have inbounds with different purposes - one for normal usage and other for Whitelist/AI/Torrent/etc. ### Mockups, screenshots, or examples _No response_ ### Which parts of the panel would this affect? Frontend (UI / panel pages), Subscription (share links / Clash / JSON) ### Are you willing to help? - [ ] I'd like to implement this feature myself and open a PR. - [ ] I can help test once a PR is open. ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this feature has not been requested. - [x] This feature request is written in English.
Author
Owner

@github-actions[bot] commented on GitHub (Jul 5, 2026):

Confirmed in the source: this is not currently possible, and it is distinct from what exists today.

What exists now

  • There is a single global routing-rules option for the JSON subscription: the subJsonRules panel setting (Settings -> Subscription tab, "Direct routing" toggle in frontend/src/pages/settings/SubscriptionFormatsTab.tsx). Its JSON is merged into every generated config's routing.rules array in NewSubJsonService (internal/sub/json_service.go:29-48), ahead of the rules from internal/sub/default.json. It applies to the whole subscription output, not per inbound, and there is no per-inbound field on the Inbound model (internal/database/model/model.go:46-86) to store a per-inbound routing block.
  • The inbound edit modal's "Advanced" tab (frontend/src/pages/inbounds/form/InboundFormModal.tsx:1048, AdvancedAllEditor/AdvancedSliceEditor) edits the inbound's own Xray-side stream/sniffing JSON, not routing rules injected into subscription outbounds.
  • There is one narrower, protocol-specific mechanism for per-endpoint routing differentiation: vlessRoute (internal/sub/vless_route.go), which encodes a route number into unused VLESS UUID bytes so different hosts/endpoints can be distinguished server-side. It does not carry general JSON routing rules and only applies to VLESS.

So today, shipping different routing profiles per inbound through the JSON subscription, as opposed to one global rule set for the whole subscription, would require the feature you are describing.

For context, a few related but distinct asks exist in this repo: #5124 (subscription "packages" with reusable route presets, open) and the closed #3879/#4776 (subscription-level routing/grouping ideas). None of them cover a per-inbound "Routing" tab with JSON injected specifically into that inbound's subscription outbounds, so this is not a duplicate.

Labeling as an enhancement for maintainer review.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4887932061 --> @github-actions[bot] commented on GitHub (Jul 5, 2026): Confirmed in the source: this is not currently possible, and it is distinct from what exists today. **What exists now** - There is a single **global** routing-rules option for the JSON subscription: the `subJsonRules` panel setting (Settings -> Subscription tab, "Direct routing" toggle in `frontend/src/pages/settings/SubscriptionFormatsTab.tsx`). Its JSON is merged into every generated config's `routing.rules` array in `NewSubJsonService` (`internal/sub/json_service.go:29-48`), ahead of the rules from `internal/sub/default.json`. It applies to the whole subscription output, not per inbound, and there is no per-inbound field on the `Inbound` model (`internal/database/model/model.go:46-86`) to store a per-inbound routing block. - The inbound edit modal's "Advanced" tab (`frontend/src/pages/inbounds/form/InboundFormModal.tsx:1048`, `AdvancedAllEditor`/`AdvancedSliceEditor`) edits the inbound's own Xray-side stream/sniffing JSON, not routing rules injected into subscription outbounds. - There is one narrower, protocol-specific mechanism for per-endpoint routing differentiation: `vlessRoute` (`internal/sub/vless_route.go`), which encodes a route number into unused VLESS UUID bytes so different hosts/endpoints can be distinguished server-side. It does not carry general JSON routing rules and only applies to VLESS. So today, shipping different routing profiles per inbound through the JSON subscription, as opposed to one global rule set for the whole subscription, would require the feature you are describing. For context, a few related but distinct asks exist in this repo: #5124 (subscription "packages" with reusable route presets, open) and the closed #3879/#4776 (subscription-level routing/grouping ideas). None of them cover a per-inbound "Routing" tab with JSON injected specifically into that inbound's subscription outbounds, so this is not a duplicate. Labeling as an enhancement for maintainer review. *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@ilya-practicum commented on GitHub (Jul 5, 2026):

In case this will be implemented, that will also be important to force user to use JSON subscription endpoint instead of deeplinks. To make this possible a checkbox in "Panel Settings -> Subscription" or "Client's Creation/Edit window" (to make settings apply to specific clients) will be useful. If it is checked then on Subscription page all deeplinks (in "Copy URL" section) will be removed and user is forced to use JSON with injected rules.

<!-- gh-comment-id:4887973205 --> @ilya-practicum commented on GitHub (Jul 5, 2026): In case this will be implemented, that will also be important to force user to use JSON subscription endpoint instead of deeplinks. To make this possible a checkbox in "Panel Settings -> Subscription" or "Client's Creation/Edit window" (to make settings apply to specific clients) will be useful. If it is checked then on Subscription page all deeplinks (in "Copy URL" section) will be removed and user is forced to use JSON with injected rules.
Author
Owner

@JeuDeTarot commented on GitHub (Jul 24, 2026):

https://github.com/MHSanaei/3x-ui/issues/4479
+1

<!-- gh-comment-id:5073921229 --> @JeuDeTarot commented on GitHub (Jul 24, 2026): https://github.com/MHSanaei/3x-ui/issues/4479 +1
Author
Owner

@isleuntothyself commented on GitHub (Aug 28, 2026):

+1

<!-- gh-comment-id:5451590337 --> @isleuntothyself commented on GitHub (Aug 28, 2026): +1
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#4045
No description provided.