mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6402] [MERGED] feat(sub): bake Happ/INCY routing profiles into the JSON subscription #6255
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#6255
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?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6402
Author: @DIMFLIX
Created: 9/3/2026
Status: ✅ Merged
Merged: 9/10/2026
Merged by: @MHSanaei
Base:
main← Head:feat/json-sub-routing📝 Commits (10+)
4e99a3cfeat(sub): parse generic Happ/INCY routing payloads for the JSON subscription1551046feat(sub): bake Happ/INCY routing profiles into JSON subscription documents48cf385feat(sub): add the subJsonRoutingRules setting50d697bchore(api): regenerate OpenAPI artifacts for subJsonRoutingRules87264d2feat(web): routing profile editor for the JSON subscriptionf4e6ecffix(sub): warm and lazily resolve the baked JSON routing source7cc6d13feat(sub): fall back to the JSON routing profile for the Routing header8f8162aMerge remote-tracking branch 'upstream/main' into feat/json-sub-routing5681e5afix(sub): pass routingRules arg at call sites added by maind15eca9Merge remote-tracking branch 'upstream/main' into feat/json-sub-routing📊 Changes
47 files changed (+1302 additions, -113 deletions)
View changed files
📝
docs/public/openapi.json(+8 -0)📝
frontend/public/openapi.json(+8 -0)📝
frontend/src/generated/examples.ts(+2 -0)📝
frontend/src/generated/schemas.ts(+8 -0)📝
frontend/src/generated/types.ts(+2 -0)📝
frontend/src/generated/zod.ts(+2 -0)📝
frontend/src/models/setting.ts(+1 -0)📝
frontend/src/pages/settings/SubscriptionFormatsTab.tsx(+14 -0)📝
frontend/src/pages/settings/SubscriptionGeneralTab.tsx(+2 -6)➕
frontend/src/pages/settings/subscriptionShared.tsx(+6 -0)📝
frontend/src/schemas/setting.ts(+1 -0)📝
internal/sub/controller.go(+29 -17)📝
internal/sub/external_only_sub_test.go(+1 -1)📝
internal/sub/host_sub_test.go(+3 -3)📝
internal/sub/json_flow_gate_test.go(+2 -2)📝
internal/sub/json_info_node_test.go(+4 -4)➕
internal/sub/json_routing.go(+366 -0)➕
internal/sub/json_routing_baked_test.go(+447 -0)➕
internal/sub/json_routing_test.go(+192 -0)📝
internal/sub/json_service.go(+50 -9)...and 27 more files
📄 Description
What
JSON subscription clients that ignore response headers (Happ, INCY — especially with the client-side balancers from #6243/#6304) get no routing at all: the
Routingheader flow only helps raw/Clash-style subscriptions. This adds an opt-in routing profile that is baked into every JSON subscription document.New setting:
subJsonRoutingRulesAccepts one value, three input forms:
DirectSites/ProxySites/BlockSites/*Iplists, DNS fields,DnsHosts,RouteOrder)happ://routing/onadd/<base64>orincy://routing/onadd/<base64>deeplink (plain base64; std/URL-safe/padded variants all accepted)https://URL — resolved through the existing remote-routing resolver (#6168): TTL cache, ETag revalidation, SSRF guard, warmed by the cron jobWhen set, it replaces the template's
dnsandrouting.rulesin every emitted document — per-inbound docs and client-side balancer docs alike. The balancer document builder already rewritesoutboundTag: "proxy"→balancerTag: "balancer", so the profile's proxy rules route into the balancer with zero extra wiring.Fallback into the
RoutingheaderHapp/INCY fetch the geo files a baked profile references (e.g.
geosite:category-ru) through theRoutingresponse header, fed by the existingsubRoutingRulessetting. When that setting is blank the header stayed unset, so clients fetched no geo files even though a JSON profile was configured. A blank setting now falls back to the JSON profile:happ:///incy://deeplinks pass through, inline JSON and remote URLs are normalized to ahapp://deeplink via the existing resolver; an unusable or oversized value leaves the header unset (fail-closed). The header fallback is regression-tested for all input forms.Notes
subJsonRulessimple editor keeps working when no profile is set; a profile takes precedence outright.RouteOrder(defaultblock-direct-proxy).Validation
go test ./internal/sub/ ./internal/web/job/— green, incl. new tests: parser table-tests, baked-document tests, balancer-interplay test, cold-remote-warmup regression test, header-fallback testsnpm run typecheck/npm run lint/npm run test/npm run build— greenmake gen+ docs sync)Routingheader verified over HTTP) — all confirmed🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.