mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-19 17:40:59 +00:00
fix(xhttp): stop XMUX maxConcurrency from reverting on save
XHttpXmuxSchema defaulted maxConnections to 6 (added to mirror xray-core v26.6.27's anti-RKN client default), so load-time hydration backfilled a non-zero maxConnections onto every config whose saved xmux lacked the key. Since maxConnections and maxConcurrency are mutually exclusive on the wire, the save-time exclusivity rule then saw both fields set and silently deleted the user's maxConcurrency; the missing key came back as the '16-32' schema default on the next load, so edits appeared to never save. Revert the bare schema default to 0 and seed the anti-RKN maxConnections=6 only when XMUX is freshly toggled on (XMUX_FRESH_DEFAULTS, with maxConcurrency left blank — xray-core parses an empty range string as 0), so the two strategies never start out conflicting. The inbound and outbound XMUX forms now also clear the opposing field live as soon as the user sets one, so whichever strategy was actually typed is the one persisted. Closes #5864
This commit is contained in:
@@ -15,9 +15,14 @@ export type XHttpMode = z.infer<typeof XHttpModeSchema>;
|
||||
// XMUX is the connection-multiplexing layer xHTTP uses to fan out
|
||||
// parallel requests over a small pool of upstream connections. Fields
|
||||
// are strings because they accept dash-range values like '16-32'.
|
||||
// maxConcurrency and maxConnections are mutually exclusive strategies
|
||||
// (xray-core rejects a config that sets both), so the bare schema
|
||||
// default keeps only one of them non-zero — a non-zero maxConnections
|
||||
// default resurrected on load made every re-save silently delete the
|
||||
// user's maxConcurrency.
|
||||
export const XHttpXmuxSchema = z.object({
|
||||
maxConcurrency: z.string().default('16-32'),
|
||||
maxConnections: z.union([z.string(), z.number()]).default(6),
|
||||
maxConnections: z.union([z.string(), z.number()]).default(0),
|
||||
cMaxReuseTimes: z.union([z.string(), z.number()]).default(0),
|
||||
hMaxRequestTimes: z.string().default('600-900'),
|
||||
hMaxReusableSecs: z.string().default('1800-3000'),
|
||||
@@ -25,6 +30,15 @@ export const XHttpXmuxSchema = z.object({
|
||||
});
|
||||
export type XHttpXmux = z.infer<typeof XHttpXmuxSchema>;
|
||||
|
||||
// Seed for freshly enabling XMUX on a config that had no xmux block:
|
||||
// mirrors xray-core v26.6.27's own anti-RKN maxConnections=6 fallback
|
||||
// rather than the concurrency strategy.
|
||||
export const XMUX_FRESH_DEFAULTS: XHttpXmux = {
|
||||
...XHttpXmuxSchema.parse({}),
|
||||
maxConcurrency: '',
|
||||
maxConnections: 6,
|
||||
};
|
||||
|
||||
// Predefined sessionIDTable names xray-core accepts as a shorthand for a
|
||||
// charset (splithttp.PredefinedTable, xray-core #6258). A literal ASCII
|
||||
// charset string is also accepted.
|
||||
|
||||
Reference in New Issue
Block a user