mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-04 16:34:52 +03:00
feat(sub): report why a subscription balancer emits nothing (#7209)
A subscription balancer whose inbounds were deleted, disabled, changed to a protocol with no JSON outbound, left without clients or closed by their hosts simply vanished from the JSON subscription, and nothing in the panel or the log said why. GET /panel/api/sub-balancers now returns a problems[] array per balancer with stable codes: unknown_inbound, disabled_inbound, json_incapable_protocol, inbound_without_clients, hosts_excluded_from_json and no_members. Settings -> Sub Balancers shows a warning tag whose tooltip names each cause and the affected inbounds, and the log records a balancer's problems when they change instead of on every listing. The advisories are read from the stored rows and never change what a subscription emits: a balancer with no usable member is still omitted. The list of JSON-incapable protocols is pinned to the renderer, the subscription allowlist and the form by tests.
This commit is contained in:
@@ -1444,6 +1444,38 @@ export const EXAMPLES: Record<string, unknown> = {
|
||||
"strategy": "random",
|
||||
"updatedAt": 1710000000000
|
||||
},
|
||||
"SubBalancerProblem": {
|
||||
"code": "unknown_inbound",
|
||||
"detail": "amneziawg",
|
||||
"inboundIds": [
|
||||
7,
|
||||
9
|
||||
]
|
||||
},
|
||||
"SubBalancerWithProblems": {
|
||||
"createdAt": 1710000000000,
|
||||
"enabled": true,
|
||||
"id": 1,
|
||||
"inboundIds": [
|
||||
1,
|
||||
3
|
||||
],
|
||||
"memberWeights": {},
|
||||
"problems": [
|
||||
{
|
||||
"code": "unknown_inbound",
|
||||
"detail": "amneziawg",
|
||||
"inboundIds": [
|
||||
7,
|
||||
9
|
||||
]
|
||||
}
|
||||
],
|
||||
"remark": "auto-fastest",
|
||||
"sortOrder": 1,
|
||||
"strategy": "random",
|
||||
"updatedAt": 1710000000000
|
||||
},
|
||||
"TgBotCapabilities": {
|
||||
"groupPrivacy": false,
|
||||
"inlineEnabled": true,
|
||||
|
||||
@@ -5610,6 +5610,112 @@ export const SCHEMAS: Record<string, unknown> = {
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"SubBalancerProblem": {
|
||||
"description": "SubBalancerProblem is one reason a balancer cannot emit what an operator expects.\nAdvisories never change the emitted config, and per-client losses are out of scope.",
|
||||
"properties": {
|
||||
"code": {
|
||||
"example": "unknown_inbound",
|
||||
"type": "string"
|
||||
},
|
||||
"detail": {
|
||||
"example": "amneziawg",
|
||||
"type": "string"
|
||||
},
|
||||
"inboundIds": {
|
||||
"example": [
|
||||
7,
|
||||
9
|
||||
],
|
||||
"items": {
|
||||
"type": "integer"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"code"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"SubBalancerWithProblems": {
|
||||
"description": "SubBalancerWithProblems embeds the row by value so it marshals flat; Problems is\nalways non-nil so the response shape is stable.",
|
||||
"properties": {
|
||||
"createdAt": {
|
||||
"example": 1710000000000,
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"enabled": {
|
||||
"description": "No gorm default:true — a bool default makes an explicit false at insert\ncollapse back to the column default (zero value is skipped).",
|
||||
"example": true,
|
||||
"type": "boolean"
|
||||
},
|
||||
"id": {
|
||||
"example": 1,
|
||||
"type": "integer"
|
||||
},
|
||||
"inboundIds": {
|
||||
"example": [
|
||||
1,
|
||||
3
|
||||
],
|
||||
"items": {
|
||||
"type": "integer"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"memberWeights": {
|
||||
"additionalProperties": {
|
||||
"type": "number"
|
||||
},
|
||||
"description": "inboundId -\u003e leastLoad weight; absent entries mean 1.0. Only meaningful\nwith Strategy \"leastLoad\" — xray ignores costs on every other strategy.",
|
||||
"type": "object"
|
||||
},
|
||||
"problems": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/SubBalancerProblem"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"remark": {
|
||||
"example": "auto-fastest",
|
||||
"maxLength": 256,
|
||||
"type": "string"
|
||||
},
|
||||
"sortOrder": {
|
||||
"example": 1,
|
||||
"minimum": 1,
|
||||
"type": "integer"
|
||||
},
|
||||
"strategy": {
|
||||
"enum": [
|
||||
"leastLoad",
|
||||
"leastPing",
|
||||
"random",
|
||||
"roundRobin"
|
||||
],
|
||||
"example": "random",
|
||||
"type": "string"
|
||||
},
|
||||
"updatedAt": {
|
||||
"example": 1710000000000,
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"createdAt",
|
||||
"enabled",
|
||||
"id",
|
||||
"inboundIds",
|
||||
"problems",
|
||||
"remark",
|
||||
"sortOrder",
|
||||
"strategy",
|
||||
"updatedAt"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"TgBotCapabilities": {
|
||||
"description": "TgBotCapabilities is the browser-safe shape of the bot's own capabilities.",
|
||||
"properties": {
|
||||
|
||||
@@ -1270,6 +1270,25 @@ export interface SubBalancer {
|
||||
updatedAt: number;
|
||||
}
|
||||
|
||||
export interface SubBalancerProblem {
|
||||
code: string;
|
||||
detail?: string;
|
||||
inboundIds?: number[];
|
||||
}
|
||||
|
||||
export interface SubBalancerWithProblems {
|
||||
createdAt: number;
|
||||
enabled: boolean;
|
||||
id: number;
|
||||
inboundIds: number[];
|
||||
memberWeights?: Record<number, number>;
|
||||
problems: SubBalancerProblem[];
|
||||
remark: string;
|
||||
sortOrder: number;
|
||||
strategy: string;
|
||||
updatedAt: number;
|
||||
}
|
||||
|
||||
export interface TgBotCapabilities {
|
||||
groupPrivacy: boolean;
|
||||
inlineEnabled: boolean;
|
||||
|
||||
@@ -1348,6 +1348,27 @@ export const SubBalancerSchema = z.object({
|
||||
});
|
||||
export type SubBalancer = z.infer<typeof SubBalancerSchema>;
|
||||
|
||||
export const SubBalancerProblemSchema = z.object({
|
||||
code: z.string(),
|
||||
detail: z.string().optional(),
|
||||
inboundIds: z.array(z.number().int()).optional(),
|
||||
});
|
||||
export type SubBalancerProblem = z.infer<typeof SubBalancerProblemSchema>;
|
||||
|
||||
export const SubBalancerWithProblemsSchema = z.object({
|
||||
createdAt: z.number().int(),
|
||||
enabled: z.boolean(),
|
||||
id: z.number().int(),
|
||||
inboundIds: z.array(z.number().int()),
|
||||
memberWeights: z.record(z.number().int(), z.number()).optional(),
|
||||
problems: z.array(z.lazy(() => SubBalancerProblemSchema)),
|
||||
remark: z.string().max(256),
|
||||
sortOrder: z.number().int().min(1),
|
||||
strategy: z.enum(['leastLoad', 'leastPing', 'random', 'roundRobin']),
|
||||
updatedAt: z.number().int(),
|
||||
});
|
||||
export type SubBalancerWithProblems = z.infer<typeof SubBalancerWithProblemsSchema>;
|
||||
|
||||
export const TgBotCapabilitiesSchema = z.object({
|
||||
groupPrivacy: z.boolean(),
|
||||
inlineEnabled: z.boolean(),
|
||||
|
||||
Reference in New Issue
Block a user