mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6282] [MERGED] docs(api): document WireGuard and mtproto secret generation on clients/add #6206
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#6206
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/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)
e9a0bc8docs(api): document WireGuard and mtproto secret generation on clients/add600694ddocs(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/adddocuments 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 operationdescription, and adds the WireGuard specifics plus theattachcollision 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 bydefaultWireguardClients(internal/web/service/client_wireguard.go:130), reached fromAddInboundClient(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 fieldEndpointalready declares andbuild-openapi.mjsalready maps toop.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:
client_wireguard.go:138-144)privateKeywas supplied (:145-151)allowedIPsis empty (:152-157) — a free/32from the /24 the inbound's existing peers already sit in,10.0.0.0/24as the fallback (wireguardAllocationBase,:35), widening to the containing /16 before failing withwireguard: no free address available in <scope>(:49,:66-80)secret(client_crud.go:245-248)allowedIPsbrings them into the next inbound and is rejected withwireguard: 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
Areas affected
endpoints.tsand the generated spec only, no UI changeHow was this tested?
cd frontend && npm run gen:api— the regeneratedfrontend/public/openapi.jsondiffers in exactly the two operations and nothing elsedocs/public/openapi.jsonis 14 paths behindfrontend/public/openapi.jsonand 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 herecd docs && pnpm gen:api— onlycontent/docs/en/reference/api/clients.mdxchangednpm run typecheck,npm run lint,npm run format:check,npm run buildpass;npm testpasses for theunitandcomponentsprojects (1074 tests). Thestorybookproject needs a Playwright chromium that does not run on my machine; no component changedpnpm typecheck,pnpm lint,pnpm format:check,pnpm test(105 tests) pass, and I checked the page underpnpm devScreenshots / recordings
N/A — no UI change.
Breaking changes
None functional. The generated heading anchor for
clients/addchanges 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.mjstreats onlyin: 'body'as a body param.'body (json)','body (form)'and'body (multipart)'— 65 of the 79 body params inendpoints.ts— are dropped, so their names, types, required flags and descriptions never reach the spec. That is whyclients/addshows a bare{"type": "object"}request body with just an example, and why theclientparam 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 devindocs/writesdocs/AGENTS.mdanddocs/CLAUDE.md, neither of which is gitignored.Checklist
go build ./...and the test suite pass locally — no Go change; no Go toolchain on this machine.npm run lint,npm run typecheck, andnpm run buildpass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.