[PR #6282] [MERGED] docs(api): document WireGuard and mtproto secret generation on clients/add #6206

Closed
opened 2026-11-02 04:07:06 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6282
Author: @rokokol
Created: 8/21/2026
Status: ✅ Merged
Merged: 8/22/2026
Merged by: @MHSanaei

Base: main ← Head: docs/clients-add-wireguard-generation


📝 Commits (2)

  • e9a0bc8 docs(api): document WireGuard and mtproto secret generation on clients/add
  • 600694d docs(api): correct the clients/add generation rules flagged in review

📊 Changes

7 files changed (+213 additions, -43 deletions)

View changed files

📝 docs/content/docs/en/reference/api/clients.mdx (+57 -10)
📝 docs/content/docs/fa/reference/api/clients.mdx (+57 -10)
📝 docs/content/docs/ru/reference/api/clients.mdx (+57 -10)
📝 docs/content/docs/zh/reference/api/clients.mdx (+30 -9)
📝 docs/public/openapi.json (+3 -1)
📝 frontend/public/openapi.json (+3 -1)
📝 frontend/src/pages/api-docs/endpoints.ts (+6 -2)

📄 Description

Summary

POST /panel/api/clients/add documents which per-protocol secrets the server generates when they are omitted. That list was written before WireGuard gained per-client keys and never covered mtproto, so it names four of the six protocols the code actually handles. This replaces the enumeration in the summary with the rule itself, moves the per-protocol detail into the operation description, and adds the WireGuard specifics plus the attach collision rule.

Why

Closes #6276.

fillProtocolDefaults (internal/web/service/client_crud.go:226) covers VLESS/VMess, Trojan, Shadowsocks, Hysteria and mtproto; WireGuard is filled one layer deeper by defaultWireguardClients (internal/web/service/client_wireguard.go:130), reached from AddInboundClient (internal/web/service/client_inbound_apply.go:351). Read literally, the old summary says the endpoint is unusable for WireGuard unless the caller supplies a keypair and an address by hand — I wrote defensive client code around that assumption before reading the source.

Extending the enumeration would go stale again on the next protocol, so the summary now states the rule alone and the specifics live in description — a field Endpoint already declares and build-openapi.mjs already maps to op.description, though no endpoint used it until now. Both consumers render it: Swagger UI on the panel's API Docs page, and the operation body on the docs site.

What the description now states:

  • keypair generated when both keys are blank (client_wireguard.go:138-144)
  • public key derived when only privateKey was supplied (:145-151)
  • address allocated when allowedIPs is empty (:152-157) — a free /32 from the /24 the inbound's existing peers already sit in, 10.0.0.0/24 as the fallback (wireguardAllocationBase, :35), widening to the containing /16 before failing with wireguard: no free address available in <scope> (:49, :66-80)
  • mtproto's secret (client_crud.go:245-248)
  • the guard added for #5785, which nothing documented: a client already carrying allowedIPs brings them into the next inbound and is rejected with wireguard: allowedIPs entry already used by another client: when another client of that inbound holds the address (:166-168). The check is per inbound, so the same address on two different inbounds is accepted.

Type of change

  • Documentation

Areas affected

  • Frontend (UI / panel pages) — endpoints.ts and the generated spec only, no UI change

How was this tested?

  • cd frontend && npm run gen:api — the regenerated frontend/public/openapi.json differs in exactly the two operations and nothing else
  • docs/public/openapi.json is 14 paths behind frontend/public/openapi.json and nothing syncs it, so I patched the same two operations in place instead of resyncing the file — a full resync is a large unrelated diff. Say the word if you would rather have it here
  • cd docs && pnpm gen:api — only content/docs/en/reference/api/clients.mdx changed
  • ru/fa carry the English operation text verbatim, so they got the same block. zh is a hand translation and I translated the new text — a native speaker should check it
  • frontend: npm run typecheck, npm run lint, npm run format:check, npm run build pass; npm test passes for the unit and components projects (1074 tests). The storybook project needs a Playwright chromium that does not run on my machine; no component changed
  • docs: pnpm typecheck, pnpm lint, pnpm format:check, pnpm test (105 tests) pass, and I checked the page under pnpm dev

Screenshots / recordings

N/A — no UI change.

Breaking changes

None functional. The generated heading anchor for clients/add changes with its summary: #…auth-for-hysteria-are-generated-server-side… becomes #…per-protocol-secrets-are-generated-server-side…, so any deep link to that operation moves.

Noticed while in here (not part of this PR)

  • build-openapi.mjs treats only in: 'body' as a body param. 'body (json)', 'body (form)' and 'body (multipart)' — 65 of the 79 body params in endpoints.ts — are dropped, so their names, types, required flags and descriptions never reach the spec. That is why clients/add shows a bare {"type": "object"} request body with just an example, and why the client param description corrected here is currently invisible. Happy to open an issue or a PR; the form-encoded ones need a different content type, so it is not a one-liner.
  • pnpm dev in docs/ writes docs/AGENTS.md and docs/CLAUDE.md, neither of which is gitignored.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable) — documentation only.
  • go build ./... and the test suite pass locally — no Go change; no Go toolchain on this machine.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6282 **Author:** [@rokokol](https://github.com/rokokol) **Created:** 8/21/2026 **Status:** ✅ Merged **Merged:** 8/22/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `docs/clients-add-wireguard-generation` --- ### 📝 Commits (2) - [`e9a0bc8`](https://github.com/MHSanaei/3x-ui/commit/e9a0bc8e1673a7571bcb15220568c8f8939a6a9c) docs(api): document WireGuard and mtproto secret generation on clients/add - [`600694d`](https://github.com/MHSanaei/3x-ui/commit/600694d60d2edd4478d04a408f52d1913460b918) docs(api): correct the clients/add generation rules flagged in review ### 📊 Changes **7 files changed** (+213 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/en/reference/api/clients.mdx` (+57 -10) 📝 `docs/content/docs/fa/reference/api/clients.mdx` (+57 -10) 📝 `docs/content/docs/ru/reference/api/clients.mdx` (+57 -10) 📝 `docs/content/docs/zh/reference/api/clients.mdx` (+30 -9) 📝 `docs/public/openapi.json` (+3 -1) 📝 `frontend/public/openapi.json` (+3 -1) 📝 `frontend/src/pages/api-docs/endpoints.ts` (+6 -2) </details> ### 📄 Description ## Summary `POST /panel/api/clients/add` documents which per-protocol secrets the server generates when they are omitted. That list was written before WireGuard gained per-client keys and never covered mtproto, so it names four of the six protocols the code actually handles. This replaces the enumeration in the summary with the rule itself, moves the per-protocol detail into the operation `description`, and adds the WireGuard specifics plus the `attach` collision rule. ## Why Closes #6276. `fillProtocolDefaults` (`internal/web/service/client_crud.go:226`) covers VLESS/VMess, Trojan, Shadowsocks, Hysteria **and mtproto**; WireGuard is filled one layer deeper by `defaultWireguardClients` (`internal/web/service/client_wireguard.go:130`), reached from `AddInboundClient` (`internal/web/service/client_inbound_apply.go:351`). Read literally, the old summary says the endpoint is unusable for WireGuard unless the caller supplies a keypair and an address by hand — I wrote defensive client code around that assumption before reading the source. Extending the enumeration would go stale again on the next protocol, so the summary now states the rule alone and the specifics live in `description` — a field `Endpoint` already declares and `build-openapi.mjs` already maps to `op.description`, though no endpoint used it until now. Both consumers render it: Swagger UI on the panel's API Docs page, and the operation body on the docs site. What the description now states: - keypair generated when both keys are blank (`client_wireguard.go:138-144`) - public key derived when only `privateKey` was supplied (`:145-151`) - address allocated when `allowedIPs` is empty (`:152-157`) — a free `/32` from the /24 the inbound's existing peers already sit in, `10.0.0.0/24` as the fallback (`wireguardAllocationBase`, `:35`), widening to the containing /16 before failing with `wireguard: no free address available in <scope>` (`:49`, `:66-80`) - mtproto's `secret` (`client_crud.go:245-248`) - the guard added for #5785, which nothing documented: a client already carrying `allowedIPs` brings them into the next inbound and is rejected with `wireguard: allowedIPs entry already used by another client:` when another client **of that inbound** holds the address (`:166-168`). The check is per inbound, so the same address on two different inbounds is accepted. ## Type of change - [x] Documentation ## Areas affected - [x] Frontend (UI / panel pages) — `endpoints.ts` and the generated spec only, no UI change ## How was this tested? - `cd frontend && npm run gen:api` — the regenerated `frontend/public/openapi.json` differs in exactly the two operations and nothing else - `docs/public/openapi.json` is 14 paths behind `frontend/public/openapi.json` and nothing syncs it, so I patched the same two operations in place instead of resyncing the file — a full resync is a large unrelated diff. Say the word if you would rather have it here - `cd docs && pnpm gen:api` — only `content/docs/en/reference/api/clients.mdx` changed - ru/fa carry the English operation text verbatim, so they got the same block. zh is a hand translation and I translated the new text — **a native speaker should check it** - frontend: `npm run typecheck`, `npm run lint`, `npm run format:check`, `npm run build` pass; `npm test` passes for the `unit` and `components` projects (1074 tests). The `storybook` project needs a Playwright chromium that does not run on my machine; no component changed - docs: `pnpm typecheck`, `pnpm lint`, `pnpm format:check`, `pnpm test` (105 tests) pass, and I checked the page under `pnpm dev` ## Screenshots / recordings N/A — no UI change. ## Breaking changes None functional. The generated heading anchor for `clients/add` changes with its summary: `#…auth-for-hysteria-are-generated-server-side…` becomes `#…per-protocol-secrets-are-generated-server-side…`, so any deep link to that operation moves. ## Noticed while in here (not part of this PR) - `build-openapi.mjs` treats only `in: 'body'` as a body param. `'body (json)'`, `'body (form)'` and `'body (multipart)'` — 65 of the 79 body params in `endpoints.ts` — are dropped, so their names, types, required flags and descriptions never reach the spec. That is why `clients/add` shows a bare `{"type": "object"}` request body with just an example, and why the `client` param description corrected here is currently invisible. Happy to open an issue or a PR; the form-encoded ones need a different content type, so it is not a one-liner. - `pnpm dev` in `docs/` writes `docs/AGENTS.md` and `docs/CLAUDE.md`, neither of which is gitignored. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [ ] I added or updated tests for the new behavior (when applicable) — documentation only. - [ ] `go build ./...` and the test suite pass locally — no Go change; no Go toolchain on this machine. - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [x] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:07:06 +07:00
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#6206
No description provided.