diff --git a/docs/content/docs/en/config/clients.mdx b/docs/content/docs/en/config/clients.mdx index 79c8a3300..9fdff5b7f 100644 --- a/docs/content/docs/en/config/clients.mdx +++ b/docs/content/docs/en/config/clients.mdx @@ -27,9 +27,11 @@ inbounds** at once, with per-client traffic accounting. | **Comment** | all | Free-text note. | - Reaching the **traffic** or **expiry** limit disables the client, and a client - disabled or deleted by hand counts too; the panel restarts Xray then - (`restartXrayOnClientDisable`, on by default). + Reaching the **traffic** or **expiry** limit disables the client. + `restartXrayOnClientDepleted` controls whether Xray restarts to close the + client's existing sessions. Manual disable and delete use + `restartXrayOnClientDisable`. The new setting inherits the old value until + explicitly configured. ## Block a subscription device diff --git a/docs/content/docs/en/config/panel.mdx b/docs/content/docs/en/config/panel.mdx index d10faef2d..680fdba17 100644 --- a/docs/content/docs/en/config/panel.mdx +++ b/docs/content/docs/en/config/panel.mdx @@ -172,3 +172,16 @@ a 2xx status within 3 seconds, the panel drops that batch, logs one warning with the reason, and logs again when deliveries resume. Deltas waiting for the next send are held in memory: disabling the webhook or a panel process exit discards them. + +### Xray restart policy + +**Restart Xray on client quota or expiry** is independent of the existing +disable/delete switch. It can close already accepted sessions for clients +disabled automatically on the panel or on a managed node. Restarts are coalesced +per depletion batch and per affected node. Remote restart requests use a bounded +best-effort call. If the new setting is unset, it inherits the old switch until +saved explicitly. + +**Node traffic fetch timeout** defaults to 4 seconds and accepts values from +1 to 30 seconds. It applies to the snapshot fetch. Local traffic polling keeps +its existing cadence. diff --git a/docs/public/openapi.json b/docs/public/openapi.json index 93229c43e..bb735ee53 100644 --- a/docs/public/openapi.json +++ b/docs/public/openapi.json @@ -177,6 +177,10 @@ "minimum": 1, "type": "integer" }, + "nodeTrafficFetchTimeout": { + "example": 4, + "type": "integer" + }, "outboundDownThreshold": { "maximum": 100, "minimum": 1, @@ -211,6 +215,10 @@ "remarkTemplate": { "type": "string" }, + "restartXrayOnClientDepleted": { + "nullable": true, + "type": "boolean" + }, "restartXrayOnClientDisable": { "type": "boolean" }, @@ -733,6 +741,7 @@ "networkTrafficInterface", "networkTrafficMode", "nodeDownThreshold", + "nodeTrafficFetchTimeout", "outboundDownThreshold", "pageSize", "panelOutbound", @@ -1075,6 +1084,10 @@ "minimum": 1, "type": "integer" }, + "nodeTrafficFetchTimeout": { + "example": 4, + "type": "integer" + }, "outboundDownThreshold": { "maximum": 100, "minimum": 1, @@ -1109,6 +1122,10 @@ "remarkTemplate": { "type": "string" }, + "restartXrayOnClientDepleted": { + "nullable": true, + "type": "boolean" + }, "restartXrayOnClientDisable": { "type": "boolean" }, @@ -1641,6 +1658,7 @@ "networkTrafficInterface", "networkTrafficMode", "nodeDownThreshold", + "nodeTrafficFetchTimeout", "outboundDownThreshold", "pageSize", "panelOutbound", diff --git a/frontend/public/openapi.json b/frontend/public/openapi.json index 93229c43e..bb735ee53 100644 --- a/frontend/public/openapi.json +++ b/frontend/public/openapi.json @@ -177,6 +177,10 @@ "minimum": 1, "type": "integer" }, + "nodeTrafficFetchTimeout": { + "example": 4, + "type": "integer" + }, "outboundDownThreshold": { "maximum": 100, "minimum": 1, @@ -211,6 +215,10 @@ "remarkTemplate": { "type": "string" }, + "restartXrayOnClientDepleted": { + "nullable": true, + "type": "boolean" + }, "restartXrayOnClientDisable": { "type": "boolean" }, @@ -733,6 +741,7 @@ "networkTrafficInterface", "networkTrafficMode", "nodeDownThreshold", + "nodeTrafficFetchTimeout", "outboundDownThreshold", "pageSize", "panelOutbound", @@ -1075,6 +1084,10 @@ "minimum": 1, "type": "integer" }, + "nodeTrafficFetchTimeout": { + "example": 4, + "type": "integer" + }, "outboundDownThreshold": { "maximum": 100, "minimum": 1, @@ -1109,6 +1122,10 @@ "remarkTemplate": { "type": "string" }, + "restartXrayOnClientDepleted": { + "nullable": true, + "type": "boolean" + }, "restartXrayOnClientDisable": { "type": "boolean" }, @@ -1641,6 +1658,7 @@ "networkTrafficInterface", "networkTrafficMode", "nodeDownThreshold", + "nodeTrafficFetchTimeout", "outboundDownThreshold", "pageSize", "panelOutbound", diff --git a/frontend/src/generated/examples.ts b/frontend/src/generated/examples.ts index f5177877c..c25602e7d 100644 --- a/frontend/src/generated/examples.ts +++ b/frontend/src/generated/examples.ts @@ -44,6 +44,7 @@ export const EXAMPLES: Record = { "networkTrafficInterface": "eth0", "networkTrafficMode": "legacy", "nodeDownThreshold": 1, + "nodeTrafficFetchTimeout": 4, "outboundDownThreshold": 1, "pageSize": 0, "panelOutbound": "", @@ -53,6 +54,7 @@ export const EXAMPLES: Record = { "publicIpv6Override": "", "realityScanCandidates": "", "remarkTemplate": "", + "restartXrayOnClientDepleted": null, "restartXrayOnClientDisable": false, "sessionMaxAge": 1, "smtpCpu": 0, @@ -257,6 +259,7 @@ export const EXAMPLES: Record = { "networkTrafficInterface": "eth0", "networkTrafficMode": "legacy", "nodeDownThreshold": 1, + "nodeTrafficFetchTimeout": 4, "outboundDownThreshold": 1, "pageSize": 0, "panelOutbound": "", @@ -266,6 +269,7 @@ export const EXAMPLES: Record = { "publicIpv6Override": "", "realityScanCandidates": "", "remarkTemplate": "", + "restartXrayOnClientDepleted": null, "restartXrayOnClientDisable": false, "sessionMaxAge": 1, "smtpCpu": 0, diff --git a/frontend/src/generated/schemas.ts b/frontend/src/generated/schemas.ts index 5739c4ed3..f243fe1cb 100644 --- a/frontend/src/generated/schemas.ts +++ b/frontend/src/generated/schemas.ts @@ -151,6 +151,10 @@ export const SCHEMAS: Record = { "minimum": 1, "type": "integer" }, + "nodeTrafficFetchTimeout": { + "example": 4, + "type": "integer" + }, "outboundDownThreshold": { "maximum": 100, "minimum": 1, @@ -185,6 +189,10 @@ export const SCHEMAS: Record = { "remarkTemplate": { "type": "string" }, + "restartXrayOnClientDepleted": { + "nullable": true, + "type": "boolean" + }, "restartXrayOnClientDisable": { "type": "boolean" }, @@ -707,6 +715,7 @@ export const SCHEMAS: Record = { "networkTrafficInterface", "networkTrafficMode", "nodeDownThreshold", + "nodeTrafficFetchTimeout", "outboundDownThreshold", "pageSize", "panelOutbound", @@ -1049,6 +1058,10 @@ export const SCHEMAS: Record = { "minimum": 1, "type": "integer" }, + "nodeTrafficFetchTimeout": { + "example": 4, + "type": "integer" + }, "outboundDownThreshold": { "maximum": 100, "minimum": 1, @@ -1083,6 +1096,10 @@ export const SCHEMAS: Record = { "remarkTemplate": { "type": "string" }, + "restartXrayOnClientDepleted": { + "nullable": true, + "type": "boolean" + }, "restartXrayOnClientDisable": { "type": "boolean" }, @@ -1615,6 +1632,7 @@ export const SCHEMAS: Record = { "networkTrafficInterface", "networkTrafficMode", "nodeDownThreshold", + "nodeTrafficFetchTimeout", "outboundDownThreshold", "pageSize", "panelOutbound", diff --git a/frontend/src/generated/types.ts b/frontend/src/generated/types.ts index 8784dfbdd..04e1c4ff6 100644 --- a/frontend/src/generated/types.ts +++ b/frontend/src/generated/types.ts @@ -49,6 +49,7 @@ export interface AllSetting { networkTrafficInterface: string; networkTrafficMode: string; nodeDownThreshold: number; + nodeTrafficFetchTimeout: number; outboundDownThreshold: number; pageSize: number; panelOutbound: string; @@ -58,6 +59,7 @@ export interface AllSetting { publicIpv6Override: string; realityScanCandidates: string; remarkTemplate: string; + restartXrayOnClientDepleted?: boolean | null; restartXrayOnClientDisable: boolean; sessionMaxAge: number; smtpCpu: number; @@ -263,6 +265,7 @@ export interface AllSettingView { networkTrafficInterface: string; networkTrafficMode: string; nodeDownThreshold: number; + nodeTrafficFetchTimeout: number; outboundDownThreshold: number; pageSize: number; panelOutbound: string; @@ -272,6 +275,7 @@ export interface AllSettingView { publicIpv6Override: string; realityScanCandidates: string; remarkTemplate: string; + restartXrayOnClientDepleted?: boolean | null; restartXrayOnClientDisable: boolean; sessionMaxAge: number; smtpCpu: number; diff --git a/frontend/src/generated/zod.ts b/frontend/src/generated/zod.ts index e61e98f44..9f88ee452 100644 --- a/frontend/src/generated/zod.ts +++ b/frontend/src/generated/zod.ts @@ -59,6 +59,7 @@ export const AllSettingSchema = z.object({ networkTrafficInterface: z.string(), networkTrafficMode: z.enum(['legacy', 'auto', 'manual']), nodeDownThreshold: z.number().int().min(1).max(100), + nodeTrafficFetchTimeout: z.number().int(), outboundDownThreshold: z.number().int().min(1).max(100), pageSize: z.number().int().min(0).max(1000), panelOutbound: z.string(), @@ -68,6 +69,7 @@ export const AllSettingSchema = z.object({ publicIpv6Override: z.string(), realityScanCandidates: z.string(), remarkTemplate: z.string(), + restartXrayOnClientDepleted: z.boolean().nullable().optional(), restartXrayOnClientDisable: z.boolean(), sessionMaxAge: z.number().int().min(1).max(525600), smtpCpu: z.number().int().min(0).max(100), @@ -274,6 +276,7 @@ export const AllSettingViewSchema = z.object({ networkTrafficInterface: z.string(), networkTrafficMode: z.enum(['legacy', 'auto', 'manual']), nodeDownThreshold: z.number().int().min(1).max(100), + nodeTrafficFetchTimeout: z.number().int(), outboundDownThreshold: z.number().int().min(1).max(100), pageSize: z.number().int().min(0).max(1000), panelOutbound: z.string(), @@ -283,6 +286,7 @@ export const AllSettingViewSchema = z.object({ publicIpv6Override: z.string(), realityScanCandidates: z.string(), remarkTemplate: z.string(), + restartXrayOnClientDepleted: z.boolean().nullable().optional(), restartXrayOnClientDisable: z.boolean(), sessionMaxAge: z.number().int().min(1).max(525600), smtpCpu: z.number().int().min(0).max(100), diff --git a/frontend/src/models/setting.ts b/frontend/src/models/setting.ts index ec7e3b5c6..933a228a4 100644 --- a/frontend/src/models/setting.ts +++ b/frontend/src/models/setting.ts @@ -78,6 +78,8 @@ export class AllSetting { externalTrafficInformInterval = 5; externalTrafficInformURI = ''; restartXrayOnClientDisable = true; + restartXrayOnClientDepleted = true; + nodeTrafficFetchTimeout = 4; mcpEnable = false; subCertFile = ''; subKeyFile = ''; diff --git a/frontend/src/pages/settings/GeneralTab.tsx b/frontend/src/pages/settings/GeneralTab.tsx index 571aae5d2..f65525a7a 100644 --- a/frontend/src/pages/settings/GeneralTab.tsx +++ b/frontend/src/pages/settings/GeneralTab.tsx @@ -402,6 +402,26 @@ export default function GeneralTab({ allSetting, updateSetting }: GeneralTabProp onChange={(v) => updateSetting({ restartXrayOnClientDisable: v })} /> + + updateSetting({ restartXrayOnClientDepleted: v })} + /> + + + updateSetting({ nodeTrafficFetchTimeout: v }))} + /> +