mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-02 19:25:05 +03:00
feat(clients): bind host rules to individual clients in subscriptions (#6620)
Host rules applied per inbound only, so every client of an inbound got the same subscription endpoints (#6618). A client can now be bound to one or more host rules, and its raw, JSON and Clash subscriptions render only those hosts, in either subscription order; an unbound client is unchanged. A binding whose hosts are deleted, disabled or excluded from the format fails closed: the client gets no links there but stays in traffic accounting. Host edits keep row ids, so bindings survive them; nil leaves a stored binding alone and an empty list clears it.
This commit is contained in:
@@ -417,6 +417,10 @@ export const EXAMPLES: Record<string, unknown> = {
|
||||
],
|
||||
"allowedIPsByInbound": {},
|
||||
"auth": "",
|
||||
"clientHostRuleIds": [
|
||||
1,
|
||||
2
|
||||
],
|
||||
"comment": "",
|
||||
"created_at": 0,
|
||||
"email": "",
|
||||
@@ -506,6 +510,10 @@ export const EXAMPLES: Record<string, unknown> = {
|
||||
"adTag": "",
|
||||
"allowedIPs": "",
|
||||
"auth": "",
|
||||
"clientHostRuleIds": [
|
||||
1,
|
||||
2
|
||||
],
|
||||
"comment": "",
|
||||
"createdAt": 0,
|
||||
"email": "",
|
||||
|
||||
@@ -1704,6 +1704,17 @@ export const SCHEMAS: Record<string, unknown> = {
|
||||
"description": "Auth password (Hysteria)",
|
||||
"type": "string"
|
||||
},
|
||||
"clientHostRuleIds": {
|
||||
"description": "ClientHostRuleIds binds the client to these host rules, one link each; nil preserves, empty\nclears, and bindings with no usable host leave that inbound out of the subscription.",
|
||||
"example": [
|
||||
1,
|
||||
2
|
||||
],
|
||||
"items": {
|
||||
"type": "integer"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"comment": {
|
||||
"description": "Client comment",
|
||||
"type": "string"
|
||||
@@ -1941,6 +1952,16 @@ export const SCHEMAS: Record<string, unknown> = {
|
||||
"auth": {
|
||||
"type": "string"
|
||||
},
|
||||
"clientHostRuleIds": {
|
||||
"example": [
|
||||
1,
|
||||
2
|
||||
],
|
||||
"items": {
|
||||
"type": "integer"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"comment": {
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
@@ -413,6 +413,7 @@ export interface Client {
|
||||
allowedIPs?: string[];
|
||||
allowedIPsByInbound?: Record<number, string[]>;
|
||||
auth?: string;
|
||||
clientHostRuleIds?: number[];
|
||||
comment: string;
|
||||
created_at?: number;
|
||||
email: string;
|
||||
@@ -464,6 +465,7 @@ export interface ClientRecord {
|
||||
adTag: string;
|
||||
allowedIPs: string;
|
||||
auth: string;
|
||||
clientHostRuleIds?: number[];
|
||||
comment: string;
|
||||
createdAt: number;
|
||||
email: string;
|
||||
|
||||
@@ -434,6 +434,7 @@ export const ClientSchema = z.object({
|
||||
allowedIPs: z.array(z.string()).optional(),
|
||||
allowedIPsByInbound: z.record(z.number().int(), z.array(z.string())).optional(),
|
||||
auth: z.string().optional(),
|
||||
clientHostRuleIds: z.array(z.number().int()).optional(),
|
||||
comment: z.string(),
|
||||
created_at: z.number().int().optional(),
|
||||
email: z.string(),
|
||||
@@ -488,6 +489,7 @@ export const ClientRecordSchema = z.object({
|
||||
adTag: z.string(),
|
||||
allowedIPs: z.string(),
|
||||
auth: z.string(),
|
||||
clientHostRuleIds: z.array(z.number().int()).optional(),
|
||||
comment: z.string(),
|
||||
createdAt: z.number().int(),
|
||||
email: z.string(),
|
||||
|
||||
Reference in New Issue
Block a user