[GH-ISSUE #6362] [Feature]: Support age-encrypted proxy-providers in subscription output #4315

Closed
opened 2026-10-31 20:38:46 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @jshir700 on GitHub (Aug 29, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6362

Operators who serve Clash-compatible subscriptions (e.g. /clash/) to end-users running Meta/Mihomo clients sometimes need the subscription to contain proxy-providers entries that reference encrypted remote YAML files. Meta supports encrypting the entire proxy-providers block with an age public key using the age-secret-key field — a standard that mirrors how individual share links can be protected.

Currently, 3x-ui's subscription output contains only raw proxy entries (or a flat outbound list in JSON mode). There is no way to emit a proxy-providers: block, nor any way to feed the age-secret-key that Meta requires to decrypt the remote provider file. This forces operators to either:

  1. Host the provider YAML externally themselves and point Meta at it directly (losing the single-URL convenience of a 3x-ui subscription), or
  2. Build a custom reverse-proxy / Sub-Converter pipe that transforms 3x-ui's output into a Meta-compatible profile with proxy-providers — adding operational overhead that could live inside 3x-ui natively.

Describe the solution you'd like

Add optional proxy-providers generation support to the Clash (/clash/) subscription output, with a configurable age-secret-key for encrypting the provider block.

Proposed behavior:

  1. New panel setting — a toggle and key input in the Subscription settings page:

    • subClashProxyProvidersEnable (boolean, default false) — when off, current behavior is preserved.
    • subClashAgeSecretKey (string, stored encrypted via the existing secret-storage layer) — the age private key in standard AGE-SECRET-KEY-... form. Optional; when omitted the provider is emitted unencrypted.
  2. Provider configuration — a text area in the subscription settings where the operator pastes one or more proxy-providers entries in standard Meta format:

    provider1:
      type: http
      url: "https://example.com/providers/proxies.yaml"
      path: ./proxy_providers/provider1.yaml
      interval: 3600
      proxy: DIRECT
      size-limit: 0
    

    (Format follows the Meta proxy-providers spec.)

  3. Output behavior — when enabled, the /clash/ endpoint appends the proxy-providers: block to the generated Clash YAML. If subClashAgeSecretKey is set, the entire proxy-providers: content is encrypted with the corresponding age public key and the age-secret-key field is injected alongside it:

    proxy-providers:
      provider1:
        type: http
        url: "https://example.com/providers/proxies.yaml"
        ...
    age-secret-key: AGE-SECRET-KEY-1ZTQLLN0A4U3ZTT3DCZKYN0CGZEZQLWX2DFTXUWMT4ZHR0N2UG6LSW9NT0N
    
  4. Backward compatibility — when the feature is disabled (default), /clash/ output is byte-for-byte identical to today's output. No schema migration required for existing rows.

  5. Security — the age secret key is stored using the same encryption-at-rest approach as tgBotToken (via the existing secret-setting layer), never logged or exposed in API responses.

Alternatives you've considered

  • Sub-Converter or other middleware — wraps 3x-ui's raw subscription and injects proxy-providers with encryption. Adds an extra component that must be maintained, monitored, and kept in sync with 3x-ui updates.
  • Static external YAML file — host the provider file on a separate server and point Meta directly at it. Works but loses the convenience of a single subscription URL.
  • Forking the panel — embedding the feature in a personal fork is possible but creates long-term merge debt with upstream.

Concrete use case

An operator manages ~80 clients through a single 3x-ui panel. They want each client to receive a single /clash/ subscription URL that Meta can consume directly. The operator also wants to distribute a shared proxy-providers list (mirrored by a CDN) that all clients update automatically — but they do not want the provider file contents exposed in plaintext to anyone who intercepts the subscription. With age-secret-key built into 3x-ui, the operator stores the age private key once in the panel, and every /clash/ response automatically carries the encrypted block, requiring zero external tooling.

Mockups, screenshots, or examples

Reference implementation in Meta docs: https://wiki.metacubex.one/config/proxy-providers/?age-secret-key

Example expected YAML output (with key set):

proxy-providers:
  default:
    type: http
    url: "https://cdn.example.com/providers/default.yaml"
    path: ./proxy_providers/default.yaml
    interval: 3600
    proxy: DIRECT
    size-limit: 1000000
age-secret-key: AGE-SECRET-KEY-1ZTQLLN0A4U3ZTT3DCZKYN0CGZEZQLWX2DFTXUWMT4ZHR0N2UG6LSW9NT0N

proxy-groups:
  - { name: PROXY, type: select, proxies: ["DEFAULT"], url: https://www.gstatic.com/generate_204, interval: 300 }

rules:
  - MATCH,PROXY

Example expected YAML output (key not set — provider unencrypted):

proxy-providers:
  default:
    type: http
    url: "https://cdn.example.com/providers/default.yaml"
    path: ./proxy_providers/default.yaml
    interval: 3600
    proxy: DIRECT

proxy-groups:
  - { name: PROXY, type: select, proxies: ["DEFAULT"] }

rules:
  - MATCH,PROXY

Which parts of the panel would this affect?

Subscription (share links / Clash / JSON), Other

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 @jshir700 on GitHub (Aug 29, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6362 ### Is your feature request related to a problem? Operators who serve Clash-compatible subscriptions (e.g. `/clash/`) to end-users running Meta/Mihomo clients sometimes need the subscription to contain `proxy-providers` entries that reference encrypted remote YAML files. Meta supports encrypting the entire `proxy-providers` block with an age public key using the `age-secret-key` field — a standard that mirrors how individual share links can be protected. Currently, 3x-ui's subscription output contains only raw proxy entries (or a flat outbound list in JSON mode). There is no way to emit a `proxy-providers:` block, nor any way to feed the `age-secret-key` that Meta requires to decrypt the remote provider file. This forces operators to either: 1. Host the provider YAML externally themselves and point Meta at it directly (losing the single-URL convenience of a 3x-ui subscription), or 2. Build a custom reverse-proxy / Sub-Converter pipe that transforms 3x-ui's output into a Meta-compatible profile with `proxy-providers` — adding operational overhead that could live inside 3x-ui natively. ### Describe the solution you'd like Add optional `proxy-providers` generation support to the Clash (`/clash/`) subscription output, with a configurable `age-secret-key` for encrypting the provider block. **Proposed behavior:** 1. **New panel setting** — a toggle and key input in the Subscription settings page: - `subClashProxyProvidersEnable` (boolean, default `false`) — when off, current behavior is preserved. - `subClashAgeSecretKey` (string, stored encrypted via the existing secret-storage layer) — the age private key in standard `AGE-SECRET-KEY-...` form. Optional; when omitted the provider is emitted unencrypted. 2. **Provider configuration** — a text area in the subscription settings where the operator pastes one or more `proxy-providers` entries in standard Meta format: ```yaml provider1: type: http url: "https://example.com/providers/proxies.yaml" path: ./proxy_providers/provider1.yaml interval: 3600 proxy: DIRECT size-limit: 0 ``` (Format follows the [Meta proxy-providers spec](https://wiki.metacubex.one/config/proxy-providers/).) 3. **Output behavior** — when enabled, the `/clash/` endpoint appends the `proxy-providers:` block to the generated Clash YAML. If `subClashAgeSecretKey` is set, the entire `proxy-providers:` content is encrypted with the corresponding age public key and the `age-secret-key` field is injected alongside it: ```yaml proxy-providers: provider1: type: http url: "https://example.com/providers/proxies.yaml" ... age-secret-key: AGE-SECRET-KEY-1ZTQLLN0A4U3ZTT3DCZKYN0CGZEZQLWX2DFTXUWMT4ZHR0N2UG6LSW9NT0N ``` 4. **Backward compatibility** — when the feature is disabled (default), `/clash/` output is byte-for-byte identical to today's output. No schema migration required for existing rows. 5. **Security** — the age secret key is stored using the same encryption-at-rest approach as `tgBotToken` (via the existing secret-setting layer), never logged or exposed in API responses. ### Alternatives you've considered - **Sub-Converter or other middleware** — wraps 3x-ui's raw subscription and injects `proxy-providers` with encryption. Adds an extra component that must be maintained, monitored, and kept in sync with 3x-ui updates. - **Static external YAML file** — host the provider file on a separate server and point Meta directly at it. Works but loses the convenience of a single subscription URL. - **Forking the panel** — embedding the feature in a personal fork is possible but creates long-term merge debt with upstream. ### Concrete use case An operator manages ~80 clients through a single 3x-ui panel. They want each client to receive a single `/clash/` subscription URL that Meta can consume directly. The operator also wants to distribute a shared `proxy-providers` list (mirrored by a CDN) that all clients update automatically — but they do not want the provider file contents exposed in plaintext to anyone who intercepts the subscription. With `age-secret-key` built into 3x-ui, the operator stores the age private key once in the panel, and every `/clash/` response automatically carries the encrypted block, requiring zero external tooling. ### Mockups, screenshots, or examples Reference implementation in Meta docs: https://wiki.metacubex.one/config/proxy-providers/?age-secret-key **Example expected YAML output (with key set):** ```yaml proxy-providers: default: type: http url: "https://cdn.example.com/providers/default.yaml" path: ./proxy_providers/default.yaml interval: 3600 proxy: DIRECT size-limit: 1000000 age-secret-key: AGE-SECRET-KEY-1ZTQLLN0A4U3ZTT3DCZKYN0CGZEZQLWX2DFTXUWMT4ZHR0N2UG6LSW9NT0N proxy-groups: - { name: PROXY, type: select, proxies: ["DEFAULT"], url: https://www.gstatic.com/generate_204, interval: 300 } rules: - MATCH,PROXY ``` **Example expected YAML output (key not set — provider unencrypted):** ```yaml proxy-providers: default: type: http url: "https://cdn.example.com/providers/default.yaml" path: ./proxy_providers/default.yaml interval: 3600 proxy: DIRECT proxy-groups: - { name: PROXY, type: select, proxies: ["DEFAULT"] } rules: - MATCH,PROXY ``` ### Which parts of the panel would this affect? Subscription (share links / Clash / JSON), Other ### Are you willing to help? - [ ] I'd like to implement this feature myself and open a PR. - [x] 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.
bsakaguchi 2026-10-31 20:38:46 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Aug 29, 2026):

Most of what you are asking for already works on the current code — the panel can already emit a proxy-providers: block and a top-level age-secret-key: line into /clash/ output today. The premise "there is no way to emit a proxy-providers: block, nor any way to feed the age-secret-key" is no longer accurate; what is genuinely missing is only the panel-side age encryption step, and that part has a problem worth settling before it is designed.

What already works

GetClash merges the operator's Clash routing setting into the generated config when the routing toggle is on (internal/sub/clash_service.go:101-112), and for an inline value mergeClashRulesYAML copies every top-level key that is not rules into the config verbatim:

// internal/sub/clash_service.go:808-817
	case map[string]any:
		for key, value := range typed {
			if key == "rules" {
				if ruleList, ok := asAnySlice(value); ok {
					mergeClashRules(base, ruleList)
				}
				continue
			}
			base[key] = value
		}

That includes proxy-providers, age-secret-key, or any other key mihomo accepts. It landed in 98ba8803 — "fix(subClashService): improve merging of clash rules in YAML (#5054)" — and git tag --contains 98ba8803 shows it first shipped in v3.3.0, so every release from v3.3.0 through v3.7.0 has it.

To use it: Panel → Settings → Subscription → the "Clash / Mihomo" tab, turn on subClashEnableRouting ("Enable routing"), and paste your YAML into subClashRules ("Global routing rules", SubscriptionGeneralTab.tsx:363-377):

proxy-providers:
  default:
    type: http
    url: "https://cdn.example.com/providers/default.yaml"
    path: ./proxy_providers/default.yaml
    interval: 3600
    proxy: DIRECT
age-secret-key: AGE-SECRET-KEY-...
proxy-groups:
  - name: PROXY
    type: select
    include-all: true
rules:
  - MATCH,PROXY

Two caveats that follow directly from base[key] = value:

  1. Any top-level key you supply replaces the generated one — it is not merged. The base config builds proxy-groups with this client's proxy names plus DIRECT (clash_service.go:91-99); pasting your own proxy-groups discards that, hence include-all: true (or an explicit list) above. Never paste a proxies: key — it would wipe the client's own nodes out of the profile.

  2. This works only when the setting holds inline YAML. If you instead put an https:// URL there, the remote path applies, and it allowlists exactly three keys — remoteClashAllowedKey returns true only for "proxy-groups", "rule-providers", "rules" (clash_service.go:911-918). proxy-providers is silently dropped, and a proxy-group referencing one is rejected outright:

    // internal/sub/clash_service.go:890
    return fmt.Errorf("remote Clash proxy-group %q cannot use proxy-providers", name)
    

    This is deliberate, not an oversight: it is pinned by TestMergeRemoteClashRulesPreservesGeneratedProxies (internal/sub/remote_routing_test.go:438, assertion "remote proxy-providers were imported" at :482) and by the "remote proxy provider use" case in TestRemoteClashRouteGraphValidation (:665-669). A remote source could otherwise inject arbitrary proxies into every client's profile.

What is genuinely not there — and two premises that do not hold

The remaining ask is the panel performing the age encryption itself. Two things in the proposal need correcting first:

  • There is no encryption-at-rest layer to reuse. UpdateSecret writes tgBotToken straight through (internal/web/service/setting.go:1367-1374 → saveSetting, :330-344), which stores the literal value in the settings table. The factoryDefaultSecretKeys / secret handling is response masking — the value is withheld from API responses — not encryption. So "stored using the same encryption-at-rest approach as tgBotToken" would not give the property you are after.
  • The stated threat model does not close. In your example output the subscription response carries both the provider reference and the AGE-SECRET-KEY-… needed to decrypt it. Anyone who intercepts that subscription therefore has everything required to read the provider file, so it does not protect "the provider file contents ... to anyone who intercepts the subscription". It only protects the file from someone who has the CDN URL but not a subscription — a narrower goal than the one written, and worth stating explicitly so the feature is not built against an expectation it cannot meet.

I also could not verify age-secret-key as a mihomo field: grep -rni "age-secret" over internal/, frontend/src, docs/content and docs/lib returns nothing, and I have no network access here, so I could not open the wiki. The link in the report ends in ?age-secret-key, which is a query string rather than a documented anchor. If you can quote the exact mihomo doc section and the minimum mihomo version that supports it, that is the one piece that would let this be scoped — since the panel already emits the block, encryption is the only thing left to design.

  • #5889 (open) — a broader request for full Clash/Mihomo profile templates; it overlaps with the proxy-groups/providers side of this.
  • #5044 (closed as completed) — the request whose fix is the base[key] = value loop quoted above.

Not a duplicate of either: #5044 is already shipped, and #5889 does not cover encryption.

Verdict: Feature request

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

<!-- gh-comment-id:5463661667 --> @github-actions[bot] commented on GitHub (Aug 29, 2026): Most of what you are asking for already works on the current code — the panel can already emit a `proxy-providers:` block **and** a top-level `age-secret-key:` line into `/clash/` output today. The premise "there is no way to emit a `proxy-providers:` block, nor any way to feed the `age-secret-key`" is no longer accurate; what is genuinely missing is only the panel-side *age encryption* step, and that part has a problem worth settling before it is designed. ## What already works `GetClash` merges the operator's Clash routing setting into the generated config when the routing toggle is on (`internal/sub/clash_service.go:101-112`), and for an **inline** value `mergeClashRulesYAML` copies every top-level key that is not `rules` into the config verbatim: ```go // internal/sub/clash_service.go:808-817 case map[string]any: for key, value := range typed { if key == "rules" { if ruleList, ok := asAnySlice(value); ok { mergeClashRules(base, ruleList) } continue } base[key] = value } ``` That includes `proxy-providers`, `age-secret-key`, or any other key mihomo accepts. It landed in `98ba8803` — *"fix(subClashService): improve merging of clash rules in YAML (#5054)"* — and `git tag --contains 98ba8803` shows it first shipped in **v3.3.0**, so every release from v3.3.0 through v3.7.0 has it. To use it: **Panel → Settings → Subscription → the "Clash / Mihomo" tab**, turn on `subClashEnableRouting` ("Enable routing"), and paste your YAML into `subClashRules` ("Global routing rules", `SubscriptionGeneralTab.tsx:363-377`): ```yaml proxy-providers: default: type: http url: "https://cdn.example.com/providers/default.yaml" path: ./proxy_providers/default.yaml interval: 3600 proxy: DIRECT age-secret-key: AGE-SECRET-KEY-... proxy-groups: - name: PROXY type: select include-all: true rules: - MATCH,PROXY ``` Two caveats that follow directly from `base[key] = value`: 1. Any top-level key you supply **replaces** the generated one — it is not merged. The base config builds `proxy-groups` with this client's proxy names plus `DIRECT` (`clash_service.go:91-99`); pasting your own `proxy-groups` discards that, hence `include-all: true` (or an explicit list) above. Never paste a `proxies:` key — it would wipe the client's own nodes out of the profile. 2. This works only when the setting holds **inline YAML**. If you instead put an `https://` URL there, the remote path applies, and it allowlists exactly three keys — `remoteClashAllowedKey` returns true only for `"proxy-groups", "rule-providers", "rules"` (`clash_service.go:911-918`). `proxy-providers` is silently dropped, and a proxy-group referencing one is rejected outright: ```go // internal/sub/clash_service.go:890 return fmt.Errorf("remote Clash proxy-group %q cannot use proxy-providers", name) ``` This is deliberate, not an oversight: it is pinned by `TestMergeRemoteClashRulesPreservesGeneratedProxies` (`internal/sub/remote_routing_test.go:438`, assertion `"remote proxy-providers were imported"` at `:482`) and by the `"remote proxy provider use"` case in `TestRemoteClashRouteGraphValidation` (`:665-669`). A remote source could otherwise inject arbitrary proxies into every client's profile. ## What is genuinely not there — and two premises that do not hold The remaining ask is the panel performing the age encryption itself. Two things in the proposal need correcting first: - **There is no encryption-at-rest layer to reuse.** `UpdateSecret` writes `tgBotToken` straight through (`internal/web/service/setting.go:1367-1374` → `saveSetting`, `:330-344`), which stores the literal value in the `settings` table. The `factoryDefaultSecretKeys` / secret handling is *response masking* — the value is withheld from API responses — not encryption. So "stored using the same encryption-at-rest approach as `tgBotToken`" would not give the property you are after. - **The stated threat model does not close.** In your example output the subscription response carries both the provider reference *and* the `AGE-SECRET-KEY-…` needed to decrypt it. Anyone who intercepts that subscription therefore has everything required to read the provider file, so it does not protect "the provider file contents ... to anyone who intercepts the subscription". It only protects the file from someone who has the CDN URL but *not* a subscription — a narrower goal than the one written, and worth stating explicitly so the feature is not built against an expectation it cannot meet. I also could not verify `age-secret-key` as a mihomo field: `grep -rni "age-secret"` over `internal/`, `frontend/src`, `docs/content` and `docs/lib` returns nothing, and I have no network access here, so I could not open the wiki. The link in the report ends in `?age-secret-key`, which is a query string rather than a documented anchor. If you can quote the exact mihomo doc section and the minimum mihomo version that supports it, that is the one piece that would let this be scoped — since the panel already emits the block, encryption is the only thing left to design. ## Related - #5889 (open) — a broader request for full Clash/Mihomo profile templates; it overlaps with the `proxy-groups`/providers side of this. - #5044 (closed as completed) — the request whose fix is the `base[key] = value` loop quoted above. Not a duplicate of either: #5044 is already shipped, and #5889 does not cover encryption. Verdict: Feature request *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
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#4315
No description provided.