mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6363] [Feature]: Support proxy-providers in remote Clash routing source; add inline age-secret-key path for encrypted provider files #4318
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#4318
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 @jshir700 on GitHub (Aug 29, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6363
Is your feature request related to a problem?
When 3x-ui's Clash subscription is used with Meta/Mihomo clients that rely on remote proxy-provider files (e.g. a CDN-hosted
providers/default.yamlthat is updated independently), operators currently have no native path to express that dependency through the panel. The two ways to inject aproxy-providers:block today both fall short for this workflow:Inline mode (currently the only working path) — paste the full provider YAML directly into the panel's "Global routing rules" field. This works for small, static provider lists but breaks the common case where the provider file is hosted on a CDN and updated independently. More critically, because
mergeClashRulesYAMLcopies every top-level key exceptrulesverbatim (clash_service.go:808-817), any top-level key the operator pastes replaces the panel-generated one. Pasting a fullproxy-groups:block wipes the panel's auto-generated groups (includingPROXYandDIRECT). Operators must therefore also restate every proxy-group — includinginclude-all: trueor an explicitproxies:list — inside the pasted block, which defeats the purpose of a centrally-managed subscription.Remote mode (the intended path for large/CDN-backed setups) — point the "Global routing rules" field at a remote URL. Here
proxy-providersis silently dropped:remoteClashAllowedKey()only returns true forproxy-groups,rule-providers, andrules(clash_service.go:911-918), andvalidateRemoteClashValueenforces this with the commentremote Clash proxy-group %q cannot use proxy-providers(clash_service.go:890). This guard was introduced in #5044 / #5054 to prevent a compromised remote source from injecting arbitrary proxies into every client's profile. It is correct for untrusted sources but too strict for the operator's own CDN — the operator controls both ends and the guard adds no real protection in that scenario.The net result: operators who want a single 3x-ui subscription URL that also carries a reference to a remote, optionally age-encrypted provider file either (a) maintain a separate static Clash YAML outside the panel (two sources of truth), or (b) embed the full inline config and restate every proxy-group on every update.
Describe the solution you'd like
Part A — Relax the remote-source guard for
proxy-providersWhen the Clash routing source is a remote URL, extend the allowed-key set so that
proxy-providersis accepted alongsideproxy-groups,rule-providers, andrules. Mirror the existing validation pattern forrule-providers(verify each entry is a named map with required fields). Reject groups that referenceusefrom a remote source (the current safety check stays) — only relax the key-allowlist itself.This keeps the security boundary: a remote source still cannot inject arbitrary proxies into the generated profile. It can only declare where the provider files live; the actual proxy contents come from the operator's CDN, not from the routing YAML.
Code change sketch:
Then in
mergeRemoteClashRules, handle the new case likerule-providers:Part B — Document the inline path as the supported route for
age-secret-keyThe
age-secret-keyfield is a per-provider field inside theproxy-providersmap in the Meta spec (docs, minimum Meta v1.16.x). It works only when the provider YAML is emitted inline in the subscription — the remote source path cannot carry it becauseproxy-providersis rejected at the remote-allowlist stage (Part A above fixes this, but the inline path is simpler for operators who host small provider files themselves).Document that operators should paste a complete config block (including
proxy-groupswithinclude-all: trueor an explicitproxies:list) into the inline "Global routing rules" field when usingage-secret-key. Provide a ready-to-copy template in the UI or docs:Note: the panel should warn (or pre-fill) the
proxy-groupsblock whenproxy-providersis detected in the inline input, to prevent operators from accidentally wiping generated groups.What is intentionally NOT in scope
mihomo age encrypt <public_key> <source> <target>) and hosts the encrypted result. 3x-ui only needs to emit theage-secret-keyfield so clients can decrypt it.Alternatives you've considered
.yamland point Meta at it. Works but creates two sources of truth: node names, ports, and credentials change in 3x-ui while the external file remains stale unless manually updated.proxy-providersat the edge. Adds a component that must be maintained and kept in sync with 3x-ui updates.Concrete use case
An operator manages ~120 clients across 4 inbounds on a single 3x-ui panel. They host a shared
proxy-providers/default.yamlon a CDN that aggregates nodes from multiple regional exit servers. The provider file is updated weekly from a private script; each update is age-encrypted with a known public key and the encrypted blob is pushed to the CDN.They want a single subscription URL per client (
https://panel:2096/clash/<sub-id>) that Meta can consume directly — no Sub-Converter, no separate YAML file to maintain. The subscription must carry theage-secret-keyso Meta can decrypt the provider file at runtime.With Part A + Part B, the operator pastes the block above into the panel once. Every client refresh receives the correct config, and when the provider file on the CDN changes, no panel change is needed.
Mockups, screenshots, or examples
Expected YAML output after the fix (inline mode, operator pastes the block):
With Part A, the same block works when pasted into a remote URL (
https://cdn.example.com/routing/clash.yaml) — the remote-source guard no longer dropsproxy-providers.Meta docs reference: https://wiki.metacubex.one/en/config/proxy-providers/#age-secret-key
(mihomo v1.16.x+, supports
age-secret-keyinside each provider entry; CLI toolmihomo age keygen/mihomo age encrypt/mihomo age decryptfor key management.)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 (Aug 29, 2026):
Part B needs no code at all — the inline path already emits a per-provider
age-secret-keytoday, and has since v3.3.0 — so the only genuinely open ask here is Part A, and in the shape proposed it does not preserve the boundary you say it preserves. Details below, including the two smaller pieces of this request that do look worth doing.Your three line references are accurate against the current default branch:
mergeClashRulesYAMLatinternal/sub/clash_service.go:808-817,remoteClashAllowedKeyat:911-918, and theuse:rejection at:890.Part B — already works, no panel change required
mergeClashRulesYAMLcopies every top-level key exceptrulesinto the generated config verbatim:The value goes to
marshalClashYAMLunchanged (internal/sub/clash_service.go:114→internal/sub/clash_yaml.go:87-89, which only quotes YAML-ambiguous scalars). Nothing in the repo inspects the field —grep -rni "age-secret"overinternal/,frontend/src,docs/contentanddocs/libreturns no hits — so whether mihomo wants it per-provider or top-level, the panel passes it through either way. That loop landed in98ba8803"fix(subClashService): improve merging of clash rules in YAML (#5054)";git tag --contains 98ba8803givesv3.3.0as the first release carrying it.To use it: Settings → Subscription → the "Clash / Mihomo" tab, enable
subClashEnableRouting, and paste into the "Global routing rules" field (subClashRules,frontend/src/pages/settings/SubscriptionGeneralTab.tsx:363-377). A multi-line value is always treated as inline —ParseRemoteRoutingURLreturnsremote=falsefor anything containing a newline or not starting withhttps://(internal/util/common/url.go:30-36).Two caveats, both a direct consequence of
base[key] = value:proxies:key — it replaces the client's own generated nodes.proxy-groupsreplaces the generated group block (built atinternal/sub/clash_service.go:91-99), which is why your template needsinclude-all: trueor an explicit list. Note the remote path does not behave this way: it merges groups by name and keeps the rest (mergeClashProxyGroups,:1021-1054).One thing worth knowing before you rely on it: the inline path runs no validation.
validateClashRouteGraphis called only frommergeRemoteClashRules(:850), so an inline typo — a rule pointing at a group you deleted, a group referencing a proxy that does not exist — is emitted as-is and fails client-side. Also,subClashRulesis a single global setting (internal/web/service/setting.go:117), so one pastedage-secret-keygoes to every subscriber of the panel.Part A — the guard does not survive the relaxation as sketched
The exclusion is deliberate and pinned by tests, not an oversight.
TestMergeRemoteClashRulesPreservesGeneratedProxies(internal/sub/remote_routing_test.go:438) feeds a hostile document and asserts:and that fixture is already the exact shape your proposal would enable —
proxy-providers:at:450-452next to a groupVPNwithinclude-all: trueat:460-463.That combination is the problem. Your proposal keeps the
use:rejection as the safety check, butvalidateClashRouteGraphonly checks a group's explicitproxies:list and skips any group that has no such key:A remote group with
include-all: truetherefore passes validation untouched today (the fixture above proves it — the merge succeeds and theVPNgroup survives,:496-499). Withproxy-providersallowed, that group's membership would be decided by a file the panel never fetches or sees, and aMATCH,VPNrule from the same remote document routes every client through it. So theuse:guard alone does not hold the line; whoever controls the routing YAML would again control where clients' proxies come from — which is exactly whatmergeRemoteClashRules's doc comment says it exists to prevent (:825-826, "lets remote update only the route graph").The other half is that your stated use case does not need Part A. The inline block carries only the provider
url,path,intervalandage-secret-key— none of which change when the CDN file is regenerated weekly, because the client fetches that file, not the panel. "When the provider file on the CDN changes, no panel change is needed" is already true of the inline path. Part A buys exactly one thing: changing which provider URL is referenced without logging into the panel.Two implementation notes if the maintainer takes it anyway:
mergeRemoteClashRulesalready ends indefault: base[key] = value(:846-848), which is howrule-providersgets in.remoteClashAllowedKeychanges the decision in a second place:normalizeClashRoutinguses the same function to decide whether a fetched document has any usable key at all (internal/sub/remote_routing.go:433-442), so a providers-only document would start being cached and accepted too.One correction on the history
The remote-source guard is not from #5044 / #5054. Those are the June inline-merge change (
98ba8803, 2026-06-08) — the one that makes Part B work. The remote path and its allowlist arrived in380aff4d"Add remote routing URL support (#6168)" (2026-08-18);git tag --contains 380aff4dgivesv3.7.0, so the guard is about a week old in released terms.What looks worth doing from this request
The two small pieces, both grounded in
base[key] = value:proxies:or aproxy-groups:/proxy-providers:block, since neither the frontend normergeClashRulesYAMLgives any feedback that a generated key was just replaced.grep -rn "subClashRules\|routing source" docs/content/docs/enreturns nothing;docs/content/docs/en/config/subscription.mdx:49mentions/clash/only as an output format. The in-panel description is the only place it is described at all, and it says "imports only groups/providers/rules" (internal/web/translation/en-US.json:1314), where "providers" meansrule-providers— worth disambiguating there too.Related
Verdict: Feature request
This reply was generated automatically; a maintainer may follow up.