mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-16 01:26:07 +00:00
feat(api-docs): generate response examples from Go structs; fix SS2022 PSK regen (#4996)
Stop hand-writing OpenAPI response examples, which kept drifting from the real payloads (clients/traffic missing fields, inbounds/list exposing userId which is json:"-", the fictional inbound-443 tag instead of the real in-<port>-<transport> form).
tools/openapigen now emits frontend/src/generated/examples.ts: a per-struct example instance built from type defaults, validate oneof/min bounds, and example: struct tags, with nested-ref expansion and a cycle guard. build-openapi.mjs composes the {success,obj} envelope from it for any endpoint annotated with responseSchema (+ responseSchemaArray for lists); the hand-written response is dropped for those. Service DTOs InboundOption/ApiTokenView/ProbeResultUI are added to the walker.
#4996: client password regeneration now produces a valid Shadowsocks 2022 PSK (correct base64 length per cipher) when an SS2022 inbound is attached, in both the single and bulk client forms; backend surfaces ssMethod on /inbounds/options so the UI can pick the right length.
Also: Swagger UI persists the Authorization token across reloads (persistAuthorization).
This commit is contained in:
@@ -0,0 +1,396 @@
|
||||
// Code generated by tools/openapigen. DO NOT EDIT.
|
||||
export const EXAMPLES: Record<string, unknown> = {
|
||||
"AllSetting": {
|
||||
"datepicker": "",
|
||||
"expireDiff": 0,
|
||||
"externalTrafficInformEnable": false,
|
||||
"externalTrafficInformURI": "",
|
||||
"ldapAutoCreate": false,
|
||||
"ldapAutoDelete": false,
|
||||
"ldapBaseDN": "",
|
||||
"ldapBindDN": "",
|
||||
"ldapDefaultExpiryDays": 0,
|
||||
"ldapDefaultLimitIP": 0,
|
||||
"ldapDefaultTotalGB": 0,
|
||||
"ldapEnable": false,
|
||||
"ldapFlagField": "",
|
||||
"ldapHost": "",
|
||||
"ldapInboundTags": "",
|
||||
"ldapInvertFlag": false,
|
||||
"ldapPassword": "",
|
||||
"ldapPort": 0,
|
||||
"ldapSyncCron": "",
|
||||
"ldapTruthyValues": "",
|
||||
"ldapUseTLS": false,
|
||||
"ldapUserAttr": "",
|
||||
"ldapUserFilter": "",
|
||||
"ldapVlessField": "",
|
||||
"pageSize": 0,
|
||||
"panelProxy": "",
|
||||
"remarkModel": "",
|
||||
"restartXrayOnClientDisable": false,
|
||||
"sessionMaxAge": 1,
|
||||
"subAnnounce": "",
|
||||
"subCertFile": "",
|
||||
"subClashEnable": false,
|
||||
"subClashEnableRouting": false,
|
||||
"subClashPath": "",
|
||||
"subClashRules": "",
|
||||
"subClashURI": "",
|
||||
"subDomain": "",
|
||||
"subEmailInRemark": false,
|
||||
"subEnable": false,
|
||||
"subEnableRouting": false,
|
||||
"subEncrypt": false,
|
||||
"subJsonEnable": false,
|
||||
"subJsonFinalMask": "",
|
||||
"subJsonMux": "",
|
||||
"subJsonPath": "",
|
||||
"subJsonRules": "",
|
||||
"subJsonURI": "",
|
||||
"subKeyFile": "",
|
||||
"subListen": "",
|
||||
"subPath": "",
|
||||
"subPort": 1,
|
||||
"subProfileUrl": "",
|
||||
"subRoutingRules": "",
|
||||
"subShowInfo": false,
|
||||
"subSupportUrl": "",
|
||||
"subTitle": "",
|
||||
"subURI": "",
|
||||
"subUpdates": 0,
|
||||
"tgBotAPIServer": "",
|
||||
"tgBotBackup": false,
|
||||
"tgBotChatId": "",
|
||||
"tgBotEnable": false,
|
||||
"tgBotLoginNotify": false,
|
||||
"tgBotProxy": "",
|
||||
"tgBotToken": "",
|
||||
"tgCpu": 0,
|
||||
"tgLang": "",
|
||||
"tgRunTime": "",
|
||||
"timeLocation": "",
|
||||
"trafficDiff": 0,
|
||||
"trustedProxyCIDRs": "",
|
||||
"twoFactorEnable": false,
|
||||
"twoFactorToken": "",
|
||||
"webBasePath": "",
|
||||
"webCertFile": "",
|
||||
"webDomain": "",
|
||||
"webKeyFile": "",
|
||||
"webListen": "",
|
||||
"webPort": 1
|
||||
},
|
||||
"AllSettingView": {
|
||||
"datepicker": "",
|
||||
"expireDiff": 0,
|
||||
"externalTrafficInformEnable": false,
|
||||
"externalTrafficInformURI": "",
|
||||
"hasApiToken": false,
|
||||
"hasLdapPassword": false,
|
||||
"hasNordSecret": false,
|
||||
"hasTgBotToken": false,
|
||||
"hasTwoFactorToken": false,
|
||||
"hasWarpSecret": false,
|
||||
"ldapAutoCreate": false,
|
||||
"ldapAutoDelete": false,
|
||||
"ldapBaseDN": "",
|
||||
"ldapBindDN": "",
|
||||
"ldapDefaultExpiryDays": 0,
|
||||
"ldapDefaultLimitIP": 0,
|
||||
"ldapDefaultTotalGB": 0,
|
||||
"ldapEnable": false,
|
||||
"ldapFlagField": "",
|
||||
"ldapHost": "",
|
||||
"ldapInboundTags": "",
|
||||
"ldapInvertFlag": false,
|
||||
"ldapPassword": "",
|
||||
"ldapPort": 0,
|
||||
"ldapSyncCron": "",
|
||||
"ldapTruthyValues": "",
|
||||
"ldapUseTLS": false,
|
||||
"ldapUserAttr": "",
|
||||
"ldapUserFilter": "",
|
||||
"ldapVlessField": "",
|
||||
"pageSize": 0,
|
||||
"panelProxy": "",
|
||||
"remarkModel": "",
|
||||
"restartXrayOnClientDisable": false,
|
||||
"sessionMaxAge": 1,
|
||||
"subAnnounce": "",
|
||||
"subCertFile": "",
|
||||
"subClashEnable": false,
|
||||
"subClashEnableRouting": false,
|
||||
"subClashPath": "",
|
||||
"subClashRules": "",
|
||||
"subClashURI": "",
|
||||
"subDomain": "",
|
||||
"subEmailInRemark": false,
|
||||
"subEnable": false,
|
||||
"subEnableRouting": false,
|
||||
"subEncrypt": false,
|
||||
"subJsonEnable": false,
|
||||
"subJsonFinalMask": "",
|
||||
"subJsonMux": "",
|
||||
"subJsonPath": "",
|
||||
"subJsonRules": "",
|
||||
"subJsonURI": "",
|
||||
"subKeyFile": "",
|
||||
"subListen": "",
|
||||
"subPath": "",
|
||||
"subPort": 1,
|
||||
"subProfileUrl": "",
|
||||
"subRoutingRules": "",
|
||||
"subShowInfo": false,
|
||||
"subSupportUrl": "",
|
||||
"subTitle": "",
|
||||
"subURI": "",
|
||||
"subUpdates": 0,
|
||||
"tgBotAPIServer": "",
|
||||
"tgBotBackup": false,
|
||||
"tgBotChatId": "",
|
||||
"tgBotEnable": false,
|
||||
"tgBotLoginNotify": false,
|
||||
"tgBotProxy": "",
|
||||
"tgBotToken": "",
|
||||
"tgCpu": 0,
|
||||
"tgLang": "",
|
||||
"tgRunTime": "",
|
||||
"timeLocation": "",
|
||||
"trafficDiff": 0,
|
||||
"trustedProxyCIDRs": "",
|
||||
"twoFactorEnable": false,
|
||||
"twoFactorToken": "",
|
||||
"webBasePath": "",
|
||||
"webCertFile": "",
|
||||
"webDomain": "",
|
||||
"webKeyFile": "",
|
||||
"webListen": "",
|
||||
"webPort": 1
|
||||
},
|
||||
"ApiToken": {
|
||||
"createdAt": 0,
|
||||
"enabled": false,
|
||||
"id": 0,
|
||||
"name": "",
|
||||
"token": ""
|
||||
},
|
||||
"ApiTokenView": {
|
||||
"createdAt": 1736000000,
|
||||
"enabled": true,
|
||||
"id": 2,
|
||||
"name": "central-panel-a",
|
||||
"token": "new-token-string"
|
||||
},
|
||||
"Client": {
|
||||
"auth": "",
|
||||
"comment": "",
|
||||
"created_at": 0,
|
||||
"email": "",
|
||||
"enable": false,
|
||||
"expiryTime": 0,
|
||||
"flow": "",
|
||||
"group": "",
|
||||
"id": "",
|
||||
"limitIp": 0,
|
||||
"password": "",
|
||||
"reset": 0,
|
||||
"reverse": null,
|
||||
"security": "",
|
||||
"subId": "",
|
||||
"tgId": 0,
|
||||
"totalGB": 0,
|
||||
"updated_at": 0
|
||||
},
|
||||
"ClientInbound": {
|
||||
"clientId": 0,
|
||||
"createdAt": 0,
|
||||
"flowOverride": "",
|
||||
"inboundId": 0
|
||||
},
|
||||
"ClientRecord": {
|
||||
"auth": "",
|
||||
"comment": "",
|
||||
"createdAt": 0,
|
||||
"email": "",
|
||||
"enable": false,
|
||||
"expiryTime": 0,
|
||||
"flow": "",
|
||||
"group": "",
|
||||
"id": 0,
|
||||
"limitIp": 0,
|
||||
"password": "",
|
||||
"reset": 0,
|
||||
"reverse": null,
|
||||
"security": "",
|
||||
"subId": "",
|
||||
"tgId": 0,
|
||||
"totalGB": 0,
|
||||
"updatedAt": 0,
|
||||
"uuid": ""
|
||||
},
|
||||
"ClientReverse": {
|
||||
"tag": ""
|
||||
},
|
||||
"ClientTraffic": {
|
||||
"down": 2097152,
|
||||
"email": "user1",
|
||||
"enable": true,
|
||||
"expiryTime": 1735689600000,
|
||||
"id": 14825,
|
||||
"inboundId": 1,
|
||||
"lastOnline": 1735680000000,
|
||||
"reset": 0,
|
||||
"subId": "i7tvdpeffi0hvvf1",
|
||||
"total": 10737418240,
|
||||
"up": 1048576,
|
||||
"uuid": "e18c9a96-71bf-48d4-933f-8b9a46d4290c"
|
||||
},
|
||||
"CustomGeoResource": {
|
||||
"alias": "",
|
||||
"createdAt": 0,
|
||||
"id": 0,
|
||||
"lastModified": "",
|
||||
"lastUpdatedAt": 0,
|
||||
"localPath": "",
|
||||
"type": "",
|
||||
"updatedAt": 0,
|
||||
"url": ""
|
||||
},
|
||||
"FallbackParentInfo": {
|
||||
"masterId": 0,
|
||||
"path": ""
|
||||
},
|
||||
"HistoryOfSeeders": {
|
||||
"id": 0,
|
||||
"seederName": ""
|
||||
},
|
||||
"Inbound": {
|
||||
"clientStats": [
|
||||
{
|
||||
"down": 2097152,
|
||||
"email": "user1",
|
||||
"enable": true,
|
||||
"expiryTime": 1735689600000,
|
||||
"id": 14825,
|
||||
"inboundId": 1,
|
||||
"lastOnline": 1735680000000,
|
||||
"reset": 0,
|
||||
"subId": "i7tvdpeffi0hvvf1",
|
||||
"total": 10737418240,
|
||||
"up": 1048576,
|
||||
"uuid": "e18c9a96-71bf-48d4-933f-8b9a46d4290c"
|
||||
}
|
||||
],
|
||||
"down": 0,
|
||||
"enable": true,
|
||||
"expiryTime": 0,
|
||||
"fallbackParent": null,
|
||||
"id": 1,
|
||||
"lastTrafficResetTime": 0,
|
||||
"listen": "",
|
||||
"nodeId": null,
|
||||
"originNodeGuid": "",
|
||||
"port": 443,
|
||||
"protocol": "vless",
|
||||
"remark": "VLESS-443",
|
||||
"settings": null,
|
||||
"sniffing": null,
|
||||
"streamSettings": null,
|
||||
"tag": "in-443-tcp",
|
||||
"total": 0,
|
||||
"trafficReset": "never",
|
||||
"up": 0
|
||||
},
|
||||
"InboundClientIps": {
|
||||
"clientEmail": "",
|
||||
"id": 0,
|
||||
"ips": null
|
||||
},
|
||||
"InboundFallback": {
|
||||
"alpn": "",
|
||||
"childId": 0,
|
||||
"dest": "",
|
||||
"id": 0,
|
||||
"masterId": 0,
|
||||
"name": "",
|
||||
"path": "",
|
||||
"sortOrder": 0,
|
||||
"xver": 0
|
||||
},
|
||||
"InboundOption": {
|
||||
"id": 1,
|
||||
"port": 443,
|
||||
"protocol": "vless",
|
||||
"remark": "VLESS-443",
|
||||
"ssMethod": "",
|
||||
"tag": "in-443-tcp",
|
||||
"tlsFlowCapable": true
|
||||
},
|
||||
"Msg": {
|
||||
"msg": "",
|
||||
"obj": null,
|
||||
"success": false
|
||||
},
|
||||
"Node": {
|
||||
"address": "node1.example.com",
|
||||
"allowPrivateAddress": false,
|
||||
"apiToken": "abcdef0123456789",
|
||||
"basePath": "/",
|
||||
"clientCount": 27,
|
||||
"configDirty": false,
|
||||
"configDirtyAt": 0,
|
||||
"cpuPct": 23.5,
|
||||
"createdAt": 1700000000,
|
||||
"depletedCount": 1,
|
||||
"enable": true,
|
||||
"guid": "",
|
||||
"id": 1,
|
||||
"inboundCount": 5,
|
||||
"lastError": "",
|
||||
"lastHeartbeat": 1700000000,
|
||||
"latencyMs": 42,
|
||||
"memPct": 45.1,
|
||||
"name": "de-fra-1",
|
||||
"onlineCount": 3,
|
||||
"panelVersion": "v3.x.x",
|
||||
"parentGuid": "",
|
||||
"pinnedCertSha256": "",
|
||||
"port": 2053,
|
||||
"remark": "",
|
||||
"scheme": "https",
|
||||
"status": "online",
|
||||
"tlsVerifyMode": "verify",
|
||||
"transitive": false,
|
||||
"updatedAt": 1700000000,
|
||||
"uptimeSecs": 86400,
|
||||
"xrayVersion": "25.10.31"
|
||||
},
|
||||
"OutboundTraffics": {
|
||||
"down": 0,
|
||||
"id": 0,
|
||||
"tag": "",
|
||||
"total": 0,
|
||||
"up": 0
|
||||
},
|
||||
"ProbeResultUI": {
|
||||
"cpuPct": 12.5,
|
||||
"error": "",
|
||||
"latencyMs": 42,
|
||||
"memPct": 45.2,
|
||||
"panelVersion": "v3.x.x",
|
||||
"status": "online",
|
||||
"uptimeSecs": 86400,
|
||||
"xrayVersion": "25.10.31"
|
||||
},
|
||||
"Setting": {
|
||||
"id": 0,
|
||||
"key": "",
|
||||
"value": ""
|
||||
},
|
||||
"User": {
|
||||
"id": 0,
|
||||
"password": "",
|
||||
"username": ""
|
||||
}
|
||||
};
|
||||
@@ -1,5 +1,9 @@
|
||||
// Code generated by tools/openapigen. DO NOT EDIT.
|
||||
export type LoginStatus = number;
|
||||
export type ProcessState = string;
|
||||
export type Protocol = string;
|
||||
export type SubLinkProvider = unknown;
|
||||
export type transportBits = number;
|
||||
|
||||
export interface AllSetting {
|
||||
datepicker: string;
|
||||
@@ -179,6 +183,14 @@ export interface ApiToken {
|
||||
token: string;
|
||||
}
|
||||
|
||||
export interface ApiTokenView {
|
||||
createdAt: number;
|
||||
enabled: boolean;
|
||||
id: number;
|
||||
name: string;
|
||||
token?: string;
|
||||
}
|
||||
|
||||
export interface Client {
|
||||
auth?: string;
|
||||
comment: string;
|
||||
@@ -280,6 +292,7 @@ export interface Inbound {
|
||||
lastTrafficResetTime: number;
|
||||
listen: string;
|
||||
nodeId?: number | null;
|
||||
originNodeGuid?: string;
|
||||
port: number;
|
||||
protocol: Protocol;
|
||||
remark: string;
|
||||
@@ -310,6 +323,16 @@ export interface InboundFallback {
|
||||
xver: number;
|
||||
}
|
||||
|
||||
export interface InboundOption {
|
||||
id: number;
|
||||
port: number;
|
||||
protocol: string;
|
||||
remark: string;
|
||||
ssMethod: string;
|
||||
tag: string;
|
||||
tlsFlowCapable: boolean;
|
||||
}
|
||||
|
||||
export interface Msg {
|
||||
msg: string;
|
||||
obj: unknown;
|
||||
@@ -328,6 +351,7 @@ export interface Node {
|
||||
createdAt: number;
|
||||
depletedCount: number;
|
||||
enable: boolean;
|
||||
guid: string;
|
||||
id: number;
|
||||
inboundCount: number;
|
||||
lastError: string;
|
||||
@@ -337,12 +361,14 @@ export interface Node {
|
||||
name: string;
|
||||
onlineCount: number;
|
||||
panelVersion: string;
|
||||
parentGuid?: string;
|
||||
pinnedCertSha256: string;
|
||||
port: number;
|
||||
remark: string;
|
||||
scheme: string;
|
||||
status: string;
|
||||
tlsVerifyMode: string;
|
||||
transitive?: boolean;
|
||||
updatedAt: number;
|
||||
uptimeSecs: number;
|
||||
xrayVersion: string;
|
||||
@@ -356,6 +382,17 @@ export interface OutboundTraffics {
|
||||
up: number;
|
||||
}
|
||||
|
||||
export interface ProbeResultUI {
|
||||
cpuPct: number;
|
||||
error: string;
|
||||
latencyMs: number;
|
||||
memPct: number;
|
||||
panelVersion: string;
|
||||
status: string;
|
||||
uptimeSecs: number;
|
||||
xrayVersion: string;
|
||||
}
|
||||
|
||||
export interface Setting {
|
||||
id: number;
|
||||
key: string;
|
||||
|
||||
@@ -1,8 +1,20 @@
|
||||
// Code generated by tools/openapigen. DO NOT EDIT.
|
||||
import { z } from 'zod';
|
||||
export const LoginStatusSchema = z.number().int();
|
||||
export type LoginStatus = z.infer<typeof LoginStatusSchema>;
|
||||
|
||||
export const ProcessStateSchema = z.string();
|
||||
export type ProcessState = z.infer<typeof ProcessStateSchema>;
|
||||
|
||||
export const ProtocolSchema = z.string();
|
||||
export type Protocol = z.infer<typeof ProtocolSchema>;
|
||||
|
||||
export const SubLinkProviderSchema = z.unknown();
|
||||
export type SubLinkProvider = z.infer<typeof SubLinkProviderSchema>;
|
||||
|
||||
export const transportBitsSchema = z.number().int();
|
||||
export type transportBits = z.infer<typeof transportBitsSchema>;
|
||||
|
||||
export const AllSettingSchema = z.object({
|
||||
datepicker: z.string(),
|
||||
expireDiff: z.number().int().min(0),
|
||||
@@ -184,6 +196,15 @@ export const ApiTokenSchema = z.object({
|
||||
});
|
||||
export type ApiToken = z.infer<typeof ApiTokenSchema>;
|
||||
|
||||
export const ApiTokenViewSchema = z.object({
|
||||
createdAt: z.number().int(),
|
||||
enabled: z.boolean(),
|
||||
id: z.number().int(),
|
||||
name: z.string(),
|
||||
token: z.string().optional(),
|
||||
});
|
||||
export type ApiTokenView = z.infer<typeof ApiTokenViewSchema>;
|
||||
|
||||
export const ClientSchema = z.object({
|
||||
auth: z.string().optional(),
|
||||
comment: z.string(),
|
||||
@@ -293,6 +314,7 @@ export const InboundSchema = z.object({
|
||||
lastTrafficResetTime: z.number().int(),
|
||||
listen: z.string(),
|
||||
nodeId: z.number().int().nullable().optional(),
|
||||
originNodeGuid: z.string().optional(),
|
||||
port: z.number().int().min(0).max(65535),
|
||||
protocol: z.enum(['vmess', 'vless', 'trojan', 'shadowsocks', 'wireguard', 'hysteria', 'http', 'mixed', 'tunnel', 'tun']),
|
||||
remark: z.string(),
|
||||
@@ -326,6 +348,17 @@ export const InboundFallbackSchema = z.object({
|
||||
});
|
||||
export type InboundFallback = z.infer<typeof InboundFallbackSchema>;
|
||||
|
||||
export const InboundOptionSchema = z.object({
|
||||
id: z.number().int(),
|
||||
port: z.number().int(),
|
||||
protocol: z.string(),
|
||||
remark: z.string(),
|
||||
ssMethod: z.string(),
|
||||
tag: z.string(),
|
||||
tlsFlowCapable: z.boolean(),
|
||||
});
|
||||
export type InboundOption = z.infer<typeof InboundOptionSchema>;
|
||||
|
||||
export const MsgSchema = z.object({
|
||||
msg: z.string(),
|
||||
obj: z.unknown(),
|
||||
@@ -345,6 +378,7 @@ export const NodeSchema = z.object({
|
||||
createdAt: z.number().int(),
|
||||
depletedCount: z.number().int(),
|
||||
enable: z.boolean(),
|
||||
guid: z.string(),
|
||||
id: z.number().int(),
|
||||
inboundCount: z.number().int(),
|
||||
lastError: z.string(),
|
||||
@@ -354,12 +388,14 @@ export const NodeSchema = z.object({
|
||||
name: z.string(),
|
||||
onlineCount: z.number().int(),
|
||||
panelVersion: z.string(),
|
||||
parentGuid: z.string().optional(),
|
||||
pinnedCertSha256: z.string(),
|
||||
port: z.number().int().min(1).max(65535),
|
||||
remark: z.string(),
|
||||
scheme: z.enum(['http', 'https']),
|
||||
status: z.string(),
|
||||
tlsVerifyMode: z.enum(['verify', 'skip', 'pin']),
|
||||
transitive: z.boolean().optional(),
|
||||
updatedAt: z.number().int(),
|
||||
uptimeSecs: z.number().int(),
|
||||
xrayVersion: z.string(),
|
||||
@@ -375,6 +411,18 @@ export const OutboundTrafficsSchema = z.object({
|
||||
});
|
||||
export type OutboundTraffics = z.infer<typeof OutboundTrafficsSchema>;
|
||||
|
||||
export const ProbeResultUISchema = z.object({
|
||||
cpuPct: z.number(),
|
||||
error: z.string(),
|
||||
latencyMs: z.number().int(),
|
||||
memPct: z.number(),
|
||||
panelVersion: z.string(),
|
||||
status: z.string(),
|
||||
uptimeSecs: z.number().int(),
|
||||
xrayVersion: z.string(),
|
||||
});
|
||||
export type ProbeResultUI = z.infer<typeof ProbeResultUISchema>;
|
||||
|
||||
export const SettingSchema = z.object({
|
||||
id: z.number().int(),
|
||||
key: z.string(),
|
||||
|
||||
@@ -33,6 +33,7 @@ export default function ApiDocsPage() {
|
||||
docExpansion="list"
|
||||
deepLinking={false}
|
||||
tryItOutEnabled
|
||||
persistAuthorization
|
||||
/>
|
||||
</div>
|
||||
</Layout.Content>
|
||||
|
||||
@@ -38,6 +38,8 @@ export interface Endpoint {
|
||||
response?: string;
|
||||
errorResponse?: string;
|
||||
errorStatus?: number;
|
||||
responseSchema?: string;
|
||||
responseSchemaArray?: boolean;
|
||||
}
|
||||
|
||||
export interface SubscriptionHeader {
|
||||
@@ -107,22 +109,22 @@ export const sections: readonly Section[] = [
|
||||
method: 'GET',
|
||||
path: '/panel/api/inbounds/list',
|
||||
summary: 'List every inbound owned by the authenticated user, including each inbound’s clientStats traffic counters. settings, streamSettings, and sniffing are returned as nested JSON objects (no escaped strings); legacy callers that send them back as JSON-encoded strings are still accepted on write.',
|
||||
response:
|
||||
'{\n "success": true,\n "obj": [\n {\n "id": 1,\n "userId": 1,\n "up": 0,\n "down": 0,\n "total": 0,\n "remark": "VLESS-443",\n "enable": true,\n "expiryTime": 0,\n "listen": "",\n "port": 443,\n "protocol": "vless",\n "settings": {\n "clients": [],\n "decryption": "none"\n },\n "streamSettings": {\n "network": "tcp",\n "security": "reality",\n "realitySettings": { "show": false, "dest": "..." }\n },\n "tag": "inbound-443",\n "sniffing": {\n "enabled": true,\n "destOverride": ["http", "tls"]\n },\n "clientStats": []\n }\n ]\n}',
|
||||
responseSchema: 'Inbound',
|
||||
responseSchemaArray: true,
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/panel/api/inbounds/list/slim',
|
||||
summary: 'Same shape as /list but with settings.clients[] stripped down to {email, enable, comment} and ClientStats not enriched with UUID/SubId. Use this for list pages; fetch /get/:id when you need the full per-client payload (uuid, password, flow, ...).',
|
||||
response:
|
||||
'{\n "success": true,\n "obj": [\n {\n "id": 1,\n "userId": 1,\n "remark": "VLESS-443",\n "settings": {\n "clients": [\n { "email": "alice", "enable": true }\n ],\n "decryption": "none"\n },\n "clientStats": []\n }\n ]\n}',
|
||||
'{\n "success": true,\n "obj": [\n {\n "id": 1,\n "remark": "VLESS-443",\n "settings": {\n "clients": [\n { "email": "alice", "enable": true }\n ],\n "decryption": "none"\n },\n "clientStats": []\n }\n ]\n}',
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/panel/api/inbounds/options',
|
||||
summary: 'Lightweight picker projection of the authenticated user’s inbounds. Returns only id, remark, protocol, port, and a server-computed tlsFlowCapable flag (true for VLESS / port-fallback on TCP with tls or reality). Use this for dropdowns and attach pickers — it skips settings, streamSettings, and clientStats so the payload stays small even on panels with thousands of clients.',
|
||||
response:
|
||||
'{\n "success": true,\n "obj": [\n {\n "id": 1,\n "remark": "VLESS-443",\n "protocol": "vless",\n "port": 443,\n "tlsFlowCapable": true\n }\n ]\n}',
|
||||
summary: 'Lightweight picker projection of the authenticated user’s inbounds. Returns id, remark, tag, protocol, port, a server-computed tlsFlowCapable flag (true for VLESS / port-fallback on TCP with tls or reality), and ssMethod (the Shadowsocks cipher, empty for non-Shadowsocks inbounds — used by the client UI to generate a valid Shadowsocks 2022 PSK). Use this for dropdowns and attach pickers — it skips settings, streamSettings, and clientStats so the payload stays small even on panels with thousands of clients.',
|
||||
responseSchema: 'InboundOption',
|
||||
responseSchemaArray: true,
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
@@ -696,7 +698,7 @@ export const sections: readonly Section[] = [
|
||||
method: 'POST',
|
||||
path: '/panel/api/clients/activeInbounds',
|
||||
summary: 'Inbound tags that carried traffic within the heartbeat window, grouped by the hosting node\'s panelGuid. Pairs with onlinesByGuid so the inbounds page only marks a multi-inbound client online on the inbounds it actually used. Nodes that do not report per-inbound activity are absent.',
|
||||
response: '{\n "success": true,\n "obj": {\n "a1b2-...": ["inbound-443", "inbound-8443"]\n }\n}',
|
||||
response: '{\n "success": true,\n "obj": {\n "a1b2-...": ["in-443-tcp", "in-8443-tcp"]\n }\n}',
|
||||
},
|
||||
{
|
||||
method: 'POST',
|
||||
@@ -711,7 +713,7 @@ export const sections: readonly Section[] = [
|
||||
params: [
|
||||
{ name: 'email', in: 'path', type: 'string', desc: 'Client email (unique across the panel).' },
|
||||
],
|
||||
response: '{\n "success": true,\n "obj": {\n "email": "user1",\n "up": 1048576,\n "down": 2097152,\n "total": 10737418240,\n "expiryTime": 1735689600000\n }\n}',
|
||||
responseSchema: 'ClientTraffic',
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
@@ -748,7 +750,8 @@ export const sections: readonly Section[] = [
|
||||
method: 'GET',
|
||||
path: '/panel/api/nodes/list',
|
||||
summary: 'List every configured node with its connection details, health, and last heartbeat patch.',
|
||||
response: '{\n "success": true,\n "obj": [\n {\n "id": 1,\n "name": "de-fra-1",\n "remark": "",\n "scheme": "https",\n "address": "node1.example.com",\n "port": 2053,\n "basePath": "/",\n "apiToken": "abcdef...",\n "enable": true,\n "allowPrivateAddress": false,\n "status": "online",\n "lastHeartbeat": 1700000000,\n "latencyMs": 42,\n "xrayVersion": "25.x.x",\n "panelVersion": "v3.x.x",\n "cpuPct": 23.5,\n "memPct": 45.1,\n "uptimeSecs": 86400,\n "lastError": "",\n "inboundCount": 5,\n "clientCount": 27,\n "onlineCount": 3,\n "depletedCount": 1,\n "createdAt": 1700000000,\n "updatedAt": 1700000000\n }\n ]\n}',
|
||||
responseSchema: 'Node',
|
||||
responseSchemaArray: true,
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
@@ -805,7 +808,7 @@ export const sections: readonly Section[] = [
|
||||
path: '/panel/api/nodes/test',
|
||||
summary: 'Probe a node without saving it. Uses the body as connection details and returns the same heartbeat snapshot a registered node would have.',
|
||||
body: '{\n "scheme": "https",\n "address": "node1.example.com",\n "port": 2053,\n "basePath": "/",\n "apiToken": "abcdef..."\n}',
|
||||
response: '{\n "success": true,\n "obj": {\n "status": "online",\n "latencyMs": 42,\n "xrayVersion": "25.x.x",\n "panelVersion": "v3.x.x",\n "cpuPct": 12.5,\n "memPct": 45.2,\n "uptimeSecs": 86400,\n "error": ""\n }\n}',
|
||||
responseSchema: 'ProbeResultUI',
|
||||
},
|
||||
{
|
||||
method: 'POST',
|
||||
@@ -978,7 +981,7 @@ export const sections: readonly Section[] = [
|
||||
{ name: 'name', in: 'body', type: 'string', desc: 'Human-readable label, e.g. "central-panel-a".' },
|
||||
],
|
||||
body: '{\n "name": "central-panel-a"\n}',
|
||||
response: '{\n "success": true,\n "obj": {\n "id": 2,\n "name": "central-panel-a",\n "token": "new-token-string",\n "enabled": true,\n "createdAt": 1736000000\n }\n}',
|
||||
responseSchema: 'ApiTokenView',
|
||||
errorResponse: '{\n "success": false,\n "msg": "a token with that name already exists"\n}',
|
||||
},
|
||||
{
|
||||
@@ -1014,7 +1017,7 @@ export const sections: readonly Section[] = [
|
||||
method: 'POST',
|
||||
path: '/panel/xray/',
|
||||
summary: 'Return the Xray config template (JSON string), available inbound tags, client reverse tags, and the configured outbound test URL in one response.',
|
||||
response: '{\n "success": true,\n "obj": {\n "xraySetting": "{...raw xray config...}",\n "inboundTags": "[\\"inbound-443\\"]",\n "clientReverseTags": "[]",\n "outboundTestUrl": "https://www.google.com/generate_204"\n }\n}',
|
||||
response: '{\n "success": true,\n "obj": {\n "xraySetting": "{...raw xray config...}",\n "inboundTags": "[\\"in-443-tcp\\"]",\n "clientReverseTags": "[]",\n "outboundTestUrl": "https://www.google.com/generate_204"\n }\n}',
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
|
||||
@@ -89,6 +89,15 @@ export default function ClientBulkAddModal({
|
||||
[form.inboundIds, flowCapableIds],
|
||||
);
|
||||
|
||||
const ss2022Method = useMemo(() => {
|
||||
for (const id of form.inboundIds || []) {
|
||||
const ib = (inbounds || []).find((row) => row.id === id);
|
||||
const method = ib?.ssMethod;
|
||||
if (method && method.substring(0, 4) === '2022') return method;
|
||||
}
|
||||
return '';
|
||||
}, [form.inboundIds, inbounds]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!showFlow && form.flow) {
|
||||
|
||||
@@ -153,7 +162,9 @@ export default function ClientBulkAddModal({
|
||||
email,
|
||||
subId: form.subId || RandomUtil.randomLowerAndNum(16),
|
||||
id: RandomUtil.randomUUID(),
|
||||
password: RandomUtil.randomLowerAndNum(16),
|
||||
password: ss2022Method
|
||||
? RandomUtil.randomShadowsocksPassword(ss2022Method)
|
||||
: RandomUtil.randomLowerAndNum(16),
|
||||
auth: RandomUtil.randomLowerAndNum(16),
|
||||
flow: showFlow ? (form.flow || '') : '',
|
||||
totalGB: Math.round((form.totalGB || 0) * SizeFormatter.ONE_GB),
|
||||
|
||||
@@ -228,6 +228,21 @@ export default function ClientFormModal({
|
||||
return ids;
|
||||
}, [inbounds]);
|
||||
|
||||
const ss2022Method = useMemo(() => {
|
||||
for (const id of form.inboundIds || []) {
|
||||
const ib = (inbounds || []).find((row) => row.id === id);
|
||||
const method = ib?.ssMethod;
|
||||
if (method && method.substring(0, 4) === '2022') return method;
|
||||
}
|
||||
return '';
|
||||
}, [form.inboundIds, inbounds]);
|
||||
|
||||
function regeneratePassword() {
|
||||
update('password', ss2022Method
|
||||
? RandomUtil.randomShadowsocksPassword(ss2022Method)
|
||||
: RandomUtil.randomLowerAndNum(16));
|
||||
}
|
||||
|
||||
const showFlow = useMemo(
|
||||
() => (form.inboundIds || []).some((id) => flowCapableIds.has(id)),
|
||||
[form.inboundIds, flowCapableIds],
|
||||
@@ -257,6 +272,15 @@ export default function ClientFormModal({
|
||||
}
|
||||
}, [showReverseTag, form.reverseTag]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!ss2022Method) return;
|
||||
setForm((prev) => (
|
||||
RandomUtil.isShadowsocks2022Password(prev.password, ss2022Method)
|
||||
? prev
|
||||
: { ...prev, password: RandomUtil.randomShadowsocksPassword(ss2022Method) }
|
||||
));
|
||||
}, [ss2022Method]);
|
||||
|
||||
const inboundOptions = useMemo(
|
||||
() => (inbounds || [])
|
||||
.filter((ib) => MULTI_CLIENT_PROTOCOLS.has(ib.protocol || ''))
|
||||
@@ -433,7 +457,7 @@ export default function ClientFormModal({
|
||||
<Form.Item label={t('pages.clients.password')}>
|
||||
<Space.Compact style={{ display: 'flex' }}>
|
||||
<Input value={form.password} style={{ flex: 1 }} onChange={(e) => update('password', e.target.value)} />
|
||||
<Button icon={<ReloadOutlined />} onClick={() => update('password', RandomUtil.randomLowerAndNum(16))} />
|
||||
<Button icon={<ReloadOutlined />} onClick={regeneratePassword} />
|
||||
</Space.Compact>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
|
||||
@@ -43,6 +43,7 @@ export const InboundOptionSchema = z.object({
|
||||
protocol: z.string().optional(),
|
||||
port: z.number().optional(),
|
||||
tlsFlowCapable: z.boolean().optional(),
|
||||
ssMethod: z.string().optional(),
|
||||
}).loose();
|
||||
|
||||
export const InboundOptionsSchema = z.array(InboundOptionSchema);
|
||||
|
||||
@@ -183,15 +183,22 @@ export class RandomUtil {
|
||||
}
|
||||
|
||||
static randomShadowsocksPassword(method: string = '2022-blake3-aes-256-gcm'): string {
|
||||
let length = 32;
|
||||
if (method === '2022-blake3-aes-128-gcm') {
|
||||
length = 16;
|
||||
}
|
||||
const length = method === '2022-blake3-aes-128-gcm' ? 16 : 32;
|
||||
const array = new Uint8Array(length);
|
||||
window.crypto.getRandomValues(array);
|
||||
return Base64.alternativeEncode(String.fromCharCode(...array));
|
||||
}
|
||||
|
||||
static isShadowsocks2022Password(password: string, method: string): boolean {
|
||||
if (!method || method.substring(0, 4) !== '2022') return true;
|
||||
const expected = method === '2022-blake3-aes-128-gcm' ? 16 : 32;
|
||||
try {
|
||||
return window.atob(password).length === expected;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static randomBase64(length: number = 16): string {
|
||||
const array = new Uint8Array(length);
|
||||
window.crypto.getRandomValues(array);
|
||||
|
||||
Reference in New Issue
Block a user