mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-04 16:34:52 +03:00
feat(traffic): separate depletion restarts from client disables (#7267)
One switch decided two things: whether Xray restarts when a client is disabled or deleted by hand, and whether it restarts when a client runs out of quota or expires. A panel that takes many API deletes had to choose between a restart on each of them and leaving depleted clients' open connections alive. Add a switch for the quota and expiry case. It inherits the old switch until it is saved, and older settings clients may omit it. A depletion asks for one restart per affected running core per committed batch: the local core when a local inbound served the client, and each affected node through the node API. A master whose nodes alone served the client is not restarted. With the new switch off, a depleted client is still removed from the running core and from its config snapshot, so a later reconcile does not restart for it either. Also add a node traffic fetch timeout setting (1 to 30 seconds, default 4). Run on a panel with real cores: with the old switch off and the new one on, a stream through a client that crossed its quota was cut within one poll and the lifecycle log names client_depletion; with them swapped, the stream and the core survived. A depletion a node detects itself follows that node's own switches. Refs #7145
This commit is contained in:
@@ -44,6 +44,7 @@ export const EXAMPLES: Record<string, unknown> = {
|
||||
"networkTrafficInterface": "eth0",
|
||||
"networkTrafficMode": "legacy",
|
||||
"nodeDownThreshold": 1,
|
||||
"nodeTrafficFetchTimeout": 4,
|
||||
"outboundDownThreshold": 1,
|
||||
"pageSize": 0,
|
||||
"panelOutbound": "",
|
||||
@@ -53,6 +54,7 @@ export const EXAMPLES: Record<string, unknown> = {
|
||||
"publicIpv6Override": "",
|
||||
"realityScanCandidates": "",
|
||||
"remarkTemplate": "",
|
||||
"restartXrayOnClientDepleted": null,
|
||||
"restartXrayOnClientDisable": false,
|
||||
"sessionMaxAge": 1,
|
||||
"smtpCpu": 0,
|
||||
@@ -257,6 +259,7 @@ export const EXAMPLES: Record<string, unknown> = {
|
||||
"networkTrafficInterface": "eth0",
|
||||
"networkTrafficMode": "legacy",
|
||||
"nodeDownThreshold": 1,
|
||||
"nodeTrafficFetchTimeout": 4,
|
||||
"outboundDownThreshold": 1,
|
||||
"pageSize": 0,
|
||||
"panelOutbound": "",
|
||||
@@ -266,6 +269,7 @@ export const EXAMPLES: Record<string, unknown> = {
|
||||
"publicIpv6Override": "",
|
||||
"realityScanCandidates": "",
|
||||
"remarkTemplate": "",
|
||||
"restartXrayOnClientDepleted": null,
|
||||
"restartXrayOnClientDisable": false,
|
||||
"sessionMaxAge": 1,
|
||||
"smtpCpu": 0,
|
||||
|
||||
@@ -151,6 +151,10 @@ export const SCHEMAS: Record<string, unknown> = {
|
||||
"minimum": 1,
|
||||
"type": "integer"
|
||||
},
|
||||
"nodeTrafficFetchTimeout": {
|
||||
"example": 4,
|
||||
"type": "integer"
|
||||
},
|
||||
"outboundDownThreshold": {
|
||||
"maximum": 100,
|
||||
"minimum": 1,
|
||||
@@ -185,6 +189,10 @@ export const SCHEMAS: Record<string, unknown> = {
|
||||
"remarkTemplate": {
|
||||
"type": "string"
|
||||
},
|
||||
"restartXrayOnClientDepleted": {
|
||||
"nullable": true,
|
||||
"type": "boolean"
|
||||
},
|
||||
"restartXrayOnClientDisable": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -707,6 +715,7 @@ export const SCHEMAS: Record<string, unknown> = {
|
||||
"networkTrafficInterface",
|
||||
"networkTrafficMode",
|
||||
"nodeDownThreshold",
|
||||
"nodeTrafficFetchTimeout",
|
||||
"outboundDownThreshold",
|
||||
"pageSize",
|
||||
"panelOutbound",
|
||||
@@ -1049,6 +1058,10 @@ export const SCHEMAS: Record<string, unknown> = {
|
||||
"minimum": 1,
|
||||
"type": "integer"
|
||||
},
|
||||
"nodeTrafficFetchTimeout": {
|
||||
"example": 4,
|
||||
"type": "integer"
|
||||
},
|
||||
"outboundDownThreshold": {
|
||||
"maximum": 100,
|
||||
"minimum": 1,
|
||||
@@ -1083,6 +1096,10 @@ export const SCHEMAS: Record<string, unknown> = {
|
||||
"remarkTemplate": {
|
||||
"type": "string"
|
||||
},
|
||||
"restartXrayOnClientDepleted": {
|
||||
"nullable": true,
|
||||
"type": "boolean"
|
||||
},
|
||||
"restartXrayOnClientDisable": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -1615,6 +1632,7 @@ export const SCHEMAS: Record<string, unknown> = {
|
||||
"networkTrafficInterface",
|
||||
"networkTrafficMode",
|
||||
"nodeDownThreshold",
|
||||
"nodeTrafficFetchTimeout",
|
||||
"outboundDownThreshold",
|
||||
"pageSize",
|
||||
"panelOutbound",
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user