[GH-ISSUE #6873] [Feature]: One-click clone/copy configuration for Clients and Inbounds with proper credential regeneration #4565

Open
opened 2026-10-31 20:40:33 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @xiaobaZeo on GitHub (Oct 19, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6873

  1. Missing Clone Feature for Clients: On the Clients page (/clients), there is currently no way to duplicate or clone an existing client. When administrators manage many clients sharing the same service tier (e.g. identical traffic quota, expiry duration, renewal frequency, IP/HWID limits, group, and attached inbounds), they must manually re-enter every field from scratch for each client.
  2. Incomplete Randomization in Inbound Cloning: On the Inbounds page (/inbounds), while an inbound "Clone" action exists, buildClonePayload currently only clears the client list (clients = []) and allocates a random port. It copies protocol-level credentials verbatim instead of re-randomizing them:
    • WireGuard secretKey is copied, resulting in identical server private keys across inbounds.
    • AmneziaWG server.privateKey, server.publicKey, and DPI obfuscation parameters (Jc, Jmin, Jmax, S1, S2, H1..H4) are copied verbatim instead of generating fresh obfuscation and keys.
    • Shadowsocks single-user password, HTTP/Mixed accounts, and Reality shortIds are not regenerated.

Describe the solution you'd like

1. Add "Clone Client" Action to the Clients Page

  • In ClientRowActions (/clients), add a Clone action button (icon: <CopyOutlined />).
  • Clicking it opens a confirmation dialog (e.g., Clone client "{email}"?).
  • Upon confirmation, a new client is created immediately via /panel/api/clients/add following these strict rules:
    • Preserve Custom Configuration:
      • Traffic quota (totalGB), expiration (expiryTime), delayed start (delayedDays)
      • Periodic renewal settings (trafficReset, trafficResetDay, reset, resetDay, etc.)
      • Concurrency & security limits (limitIp, limitHwid, tgId)
      • Organization & metadata (group, comment, enable)
      • Protocol options (flow, security, reverseTag, externalLinks)
      • Attached inbounds (inboundIds)
    • Regenerate Random Credentials (Rule-based Fresh Generation):
      • email: newly generated via RandomUtil.randomLowerAndNum(10)
      • uuid / id: newly generated via RandomUtil.randomUUID()
      • subId: newly generated via RandomUtil.randomLowerAndNum(16)
      • password: newly generated via RandomUtil.randomLowerAndNum(16)
      • auth: newly generated via RandomUtil.randomLowerAndNum(16)
      • WireGuard / AmneziaWG keys: newly generated Curve25519 keypair via Wireguard.generateKeypair()
      • MTProto secret: newly derived FakeTLS secret via generateMtprotoSecret(domain)
      • allowedIPs: cleared so the backend automatically assigns the next available IP in the tunnel subnet.

2. Harden Inbound Cloning (buildClonePayload)

  • Update buildClonePayload in inbound-clone.ts to ensure protocol-specific credentials and obfuscation parameters are re-randomized upon cloning:
    • WireGuard: regenerate secretKey (Wireguard.generateKeypair().privateKey).
    • AmneziaWG: regenerate server keypair and AWG obfuscation parameters (generateAwgObfuscation()).
    • Single-user Shadowsocks: regenerate random password based on the method.
    • HTTP / Mixed: regenerate accounts credentials (user and pass).
    • Reality: regenerate shortIds.

Alternatives you've considered

  • Manually recreating each client and re-selecting all attached inbounds, traffic caps, and renewal policies — highly time-consuming and error-prone.
  • Exporting raw JSON and modifying it manually — tedious and easy to introduce conflicting UUIDs or duplicate emails.

Concrete use case

An administrator offers standard user profiles (e.g. "VIP Tier: 100 GB / 30-day auto-renew / 2 IPs / Attached to Inbound #1, #2 and #5 / Group: VIP"). When adding new customers to this tier, the administrator can simply click "Clone" on any existing VIP user to instantly provision a new client with unique credentials while perfectly retaining all tier policies.

Which parts of the panel would this affect?

  • Frontend (UI / panel pages)

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.
Originally created by @xiaobaZeo on GitHub (Oct 19, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6873 ### Is your feature request related to a problem? 1. **Missing Clone Feature for Clients:** On the Clients page (`/clients`), there is currently no way to duplicate or clone an existing client. When administrators manage many clients sharing the same service tier (e.g. identical traffic quota, expiry duration, renewal frequency, IP/HWID limits, group, and attached inbounds), they must manually re-enter every field from scratch for each client. 2. **Incomplete Randomization in Inbound Cloning:** On the Inbounds page (`/inbounds`), while an inbound "Clone" action exists, `buildClonePayload` currently only clears the client list (`clients = []`) and allocates a random port. It copies protocol-level credentials verbatim instead of re-randomizing them: - WireGuard `secretKey` is copied, resulting in identical server private keys across inbounds. - AmneziaWG `server.privateKey`, `server.publicKey`, and DPI obfuscation parameters (`Jc, Jmin, Jmax, S1, S2, H1..H4`) are copied verbatim instead of generating fresh obfuscation and keys. - Shadowsocks single-user `password`, HTTP/Mixed `accounts`, and Reality `shortIds` are not regenerated. ### Describe the solution you'd like #### 1. Add "Clone Client" Action to the Clients Page - In `ClientRowActions` (`/clients`), add a Clone action button (icon: `<CopyOutlined />`). - Clicking it opens a confirmation dialog (e.g., `Clone client "{email}"?`). - Upon confirmation, a new client is created immediately via `/panel/api/clients/add` following these strict rules: - **Preserve Custom Configuration:** - Traffic quota (`totalGB`), expiration (`expiryTime`), delayed start (`delayedDays`) - Periodic renewal settings (`trafficReset`, `trafficResetDay`, `reset`, `resetDay`, etc.) - Concurrency & security limits (`limitIp`, `limitHwid`, `tgId`) - Organization & metadata (`group`, `comment`, `enable`) - Protocol options (`flow`, `security`, `reverseTag`, `externalLinks`) - Attached inbounds (`inboundIds`) - **Regenerate Random Credentials (Rule-based Fresh Generation):** - `email`: newly generated via `RandomUtil.randomLowerAndNum(10)` - `uuid` / `id`: newly generated via `RandomUtil.randomUUID()` - `subId`: newly generated via `RandomUtil.randomLowerAndNum(16)` - `password`: newly generated via `RandomUtil.randomLowerAndNum(16)` - `auth`: newly generated via `RandomUtil.randomLowerAndNum(16)` - WireGuard / AmneziaWG keys: newly generated Curve25519 keypair via `Wireguard.generateKeypair()` - MTProto `secret`: newly derived FakeTLS secret via `generateMtprotoSecret(domain)` - `allowedIPs`: cleared so the backend automatically assigns the next available IP in the tunnel subnet. #### 2. Harden Inbound Cloning (`buildClonePayload`) - Update `buildClonePayload` in `inbound-clone.ts` to ensure protocol-specific credentials and obfuscation parameters are re-randomized upon cloning: - WireGuard: regenerate `secretKey` (`Wireguard.generateKeypair().privateKey`). - AmneziaWG: regenerate server keypair and AWG obfuscation parameters (`generateAwgObfuscation()`). - Single-user Shadowsocks: regenerate random `password` based on the method. - HTTP / Mixed: regenerate `accounts` credentials (`user` and `pass`). - Reality: regenerate `shortIds`. ### Alternatives you've considered - Manually recreating each client and re-selecting all attached inbounds, traffic caps, and renewal policies — highly time-consuming and error-prone. - Exporting raw JSON and modifying it manually — tedious and easy to introduce conflicting UUIDs or duplicate emails. ### Concrete use case An administrator offers standard user profiles (e.g. "VIP Tier: 100 GB / 30-day auto-renew / 2 IPs / Attached to Inbound #1, #2 and #5 / Group: VIP"). When adding new customers to this tier, the administrator can simply click "Clone" on any existing VIP user to instantly provision a new client with unique credentials while perfectly retaining all tier policies. ### Which parts of the panel would this affect? - Frontend (UI / panel pages) ### Are you willing to help? - [x] 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 and this feature has not been requested.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 19, 2026):

This is a valid feature request, and both of its premises match the current code. The Clients page has no clone action. The inbound "Clone" action does copy protocol credentials verbatim; it only clears the client list and changes the port.

1. No clone action on /clients. ClientRowActions (frontend/src/pages/clients/RowCells.tsx:17-24) takes only onShowQr, onShowInfo, onResetTraffic, onEdit and onDelete, so there is nothing to duplicate a client with.

Until a clone action exists, the closest thing is the Bulk add modal (frontend/src/pages/clients/ClientBulkAddModal.tsx). It creates N clients in one go with a shared group, comment, flow, limitIp, limitHwid, totalGB, expiryTime, renewal settings (reset, resetDay, trafficReset, …) and inboundIds (see its EMPTY defaults at lines 45-66). It does not prefill those values from an existing client, though, which is the gap you describe. An older request for the same thing, #137 (2023), was closed as not planned on the legacy panel.

2. The inbound clone keeps credentials. buildClonePayload (frontend/src/lib/xray/inbound-clone.ts:13-48) changes only the client list:

const raw = { ...coerceInboundJsonField(dbInbound.settings) };
raw.clients = [];

streamSettings is passed through as-is (lines 23-26). So everything else in settings gets copied: the WireGuard secretKey, the AmneziaWG server.privateKey/publicKey and obfuscation parameters, the Shadowsocks server password, and the HTTP/Mixed accounts. Because streamSettings is copied too, Reality shortIds (and the Reality keys) carry over as well. The existing test pins this on purpose: inbound-clone.test.ts asserts that "the rest of the settings survive verbatim".

For AmneziaWG specifically, copying the obfuscation parameters contradicts what the defaults say they are for. frontend/src/lib/xray/inbound-defaults.ts says the parameters "are randomized per inbound (a static default would give every install the same DPI fingerprint)". Today a clone produces two inbounds with the same fingerprint and the same server key.

Notes for whoever implements this:

  • For the inbound side, the generators already exist: createDefaultWireguardInboundSettings / createDefaultAmneziawgInboundSettings in inbound-defaults.ts, and generateAwgObfuscation in frontend/src/lib/xray/amneziawg-obfuscation.ts. Reusing them is better than writing new random logic, because the Go generator (GenerateObfuscation31 in internal/amneziawg/params.go) has to stay in step with the TS one.
  • The "rest of the settings survive verbatim" test would need to change to match the new behaviour.
  • A client clone should go through the existing /panel/api/clients/add path, so no new route is needed. Any new UI string (button label, confirmation text) has to be added to all 13 locale files in internal/web/translation/.
  • Whether to regenerate the Reality key pair as well as shortIds is a design decision for the maintainer. Regenerating it would change the public key that every share link of the clone uses.

Verdict: Feature request

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

<!-- gh-comment-id:6262391420 --> @github-actions[bot] commented on GitHub (Oct 19, 2026): This is a valid feature request, and both of its premises match the current code. The Clients page has no clone action. The inbound "Clone" action does copy protocol credentials verbatim; it only clears the client list and changes the port. **1. No clone action on `/clients`.** `ClientRowActions` (`frontend/src/pages/clients/RowCells.tsx:17-24`) takes only `onShowQr`, `onShowInfo`, `onResetTraffic`, `onEdit` and `onDelete`, so there is nothing to duplicate a client with. Until a clone action exists, the closest thing is the **Bulk add** modal (`frontend/src/pages/clients/ClientBulkAddModal.tsx`). It creates N clients in one go with a shared `group`, `comment`, `flow`, `limitIp`, `limitHwid`, `totalGB`, `expiryTime`, renewal settings (`reset`, `resetDay`, `trafficReset`, …) and `inboundIds` (see its `EMPTY` defaults at lines 45-66). It does not prefill those values from an existing client, though, which is the gap you describe. An older request for the same thing, #137 (2023), was closed as not planned on the legacy panel. **2. The inbound clone keeps credentials.** `buildClonePayload` (`frontend/src/lib/xray/inbound-clone.ts:13-48`) changes only the client list: ```ts const raw = { ...coerceInboundJsonField(dbInbound.settings) }; raw.clients = []; ``` `streamSettings` is passed through as-is (lines 23-26). So everything else in `settings` gets copied: the WireGuard `secretKey`, the AmneziaWG `server.privateKey`/`publicKey` and obfuscation parameters, the Shadowsocks server `password`, and the HTTP/Mixed `accounts`. Because `streamSettings` is copied too, Reality `shortIds` (and the Reality keys) carry over as well. The existing test pins this on purpose: `inbound-clone.test.ts` asserts that "the rest of the settings survive verbatim". For AmneziaWG specifically, copying the obfuscation parameters contradicts what the defaults say they are for. `frontend/src/lib/xray/inbound-defaults.ts` says the parameters "are randomized per inbound (a static default would give every install the same DPI fingerprint)". Today a clone produces two inbounds with the same fingerprint and the same server key. Notes for whoever implements this: - For the inbound side, the generators already exist: `createDefaultWireguardInboundSettings` / `createDefaultAmneziawgInboundSettings` in `inbound-defaults.ts`, and `generateAwgObfuscation` in `frontend/src/lib/xray/amneziawg-obfuscation.ts`. Reusing them is better than writing new random logic, because the Go generator (`GenerateObfuscation31` in `internal/amneziawg/params.go`) has to stay in step with the TS one. - The `"rest of the settings survive verbatim"` test would need to change to match the new behaviour. - A client clone should go through the existing `/panel/api/clients/add` path, so no new route is needed. Any new UI string (button label, confirmation text) has to be added to all 13 locale files in `internal/web/translation/`. - Whether to regenerate the Reality key pair as well as `shortIds` is a design decision for the maintainer. Regenerating it would change the public key that every share link of the clone uses. 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#4565
No description provided.