3x-ui/internal/sub
Rouzbeh† fea3c94b11
feat(xhttp): support sessionID* rename + sessionIDTable/Length (xray v26.6.22) (#5506)
* feat(xhttp): support sessionID* rename + sessionIDTable/Length (xray v26.6.22)

xray-core v26.6.22 (PR #6258) renamed the XHTTP session config keys
sessionPlacement/sessionKey to sessionIDPlacement/sessionIDKey (no fallback
kept in core) and added sessionIDTable (predefined charset name or literal
ASCII) and sessionIDLength (range, e.g. 16-32, lower bound > 0).

Panel changes:
- Schema (xhttp.ts): rename the two keys, add sessionIDTable/sessionIDLength,
  and a z.preprocess that lifts legacy keys off stored configs so an upgraded
  panel never silently drops a saved session setting.
- Wire normalize + share-link build/parse: rename keys, emit the two new
  fields, and accept legacy sessionPlacement/sessionKey from old share links.
- Inbound + outbound XHTTP forms: rename field paths, add a sessionIDTable
  autocomplete (9 predefined tables + free ASCII) and a sessionIDLength range
  input shown only when a table is set, with light client validation (ASCII
  table, length min > 0; xray enforces the room-size minimum server-side).
- Subscription (service.go) and Clash (clash_service.go) builders: emit the
  renamed + new keys, with a legacy fallback for not-yet-resaved inbounds.
- Locales: add sessionIDTable/sessionIDLength labels + hints in all 13 files.

Two sibling v26.6.22 XHTTP commits need no panel change and are covered by the
core bump alone: #6332 (XHTTP/3 closes QUIC/UDP) and #6320 (udpHop honors the
existing dialerProxy).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test(xhttp): add Session ID Table to inbound form-blocks snapshot

The new sessionIDTable input renders by default in the inbound XHTTP form, so
its label joins the field-structure snapshot. sessionIDLength stays conditional
(only shown when a table is set), so it does not appear here.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(xhttp): migrate legacy session keys in the running xray config

The Zod preprocess plus the subscription/Clash fallbacks only covered the
panel UI and share-link output. The config handed to the running xray-core
process is built from the raw stored streamSettings in GetXrayConfig, which
did not rewrite the renamed XHTTP session keys — so a pre-upgrade inbound (or
template outbound) stored with a non-default sessionPlacement was emitted
unchanged and dropped by xray-core v26.6.22, until the admin re-saved it.

Lift sessionPlacement/sessionKey onto sessionIDPlacement/sessionIDKey at
config-generation time, in the existing inbound stream-rewrite block (next to
the tls/reality/externalProxy handling) and across template outbounds. The
lift is idempotent and leaves unchanged configs byte-identical so the
hot-reload diff never sees a spurious change.

Also tighten validateSessionIDLength to reject an inverted range (e.g. 32-16)
in addition to the existing lower-bound > 0 check.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(xray): avoid summed-capacity allocation in mergeSubscriptionOutbounds

CodeQL go/allocation-size-overflow flagged the pre-sized make() whose
capacity was a sum of three slice lengths. Grow the slice via append on
a nil slice instead; same result, no overflow-prone capacity expression.
2026-06-23 17:38:16 +02:00
..
build_urls_test.go fix: resolve a batch of open bug-tagged issues (traffic accounting, share strategy, sub address, CPU) (#5477) 2026-06-22 00:22:28 +02:00
characterization_test.go fix(sub): SS2022 share links must not base64-encode userinfo (#5432) 2026-06-20 11:25:12 +02:00
clash_external.go refactor(frontend): move form-item hints from extra to tooltip 2026-06-17 17:24:16 +02:00
clash_service.go feat(xhttp): support sessionID* rename + sessionIDTable/Length (xray v26.6.22) (#5506) 2026-06-23 17:38:16 +02:00
clash_service_test.go feat(xhttp): support sessionID* rename + sessionIDTable/Length (xray v26.6.22) (#5506) 2026-06-23 17:38:16 +02:00
controller.go feat(sub): add option to hide server settings in subscription (happ) (#5433) 2026-06-21 00:32:56 +02:00
controller_test.go refactor: focused service files, leaf subpackages, and an internal/ layout (#5167) 2026-06-10 15:19:22 +02:00
default.json refactor: focused service files, leaf subpackages, and an internal/ layout (#5167) 2026-06-10 15:19:22 +02:00
dist.go refactor: focused service files, leaf subpackages, and an internal/ layout (#5167) 2026-06-10 15:19:22 +02:00
endpoint.go feat(sub): add dynamic remark variables with Jalali date, transport, and status tokens (#5430) 2026-06-21 02:00:27 +02:00
endpoint_test.go feat(sub): add dynamic remark variables with Jalali date, transport, and status tokens (#5430) 2026-06-21 02:00:27 +02:00
external_config.go feat(sub): per-client external links and remote subscriptions 2026-06-14 20:57:14 +02:00
external_config_test.go feat(hosts): managed Hosts for per-host subscription link overrides (#5409) 2026-06-17 12:06:55 +02:00
external_only_sub_test.go feat(hosts): managed Hosts for per-host subscription link overrides (#5409) 2026-06-17 12:06:55 +02:00
external_subscription.go fix(sub): error instead of silently truncating oversized subscription (#5495) 2026-06-23 10:47:29 +02:00
external_subscription_test.go fix(sub): error instead of silently truncating oversized subscription (#5495) 2026-06-23 10:47:29 +02:00
host_sub.go feat(tls,reality): port xray TLS/REALITY fields, cert-hash helpers, fallback UX 2026-06-21 15:58:42 +02:00
host_sub_test.go feat(hosts): managed Hosts for per-host subscription link overrides (#5409) 2026-06-17 12:06:55 +02:00
json_service.go feat(tls,reality): port xray TLS/REALITY fields, cert-hash helpers, fallback UX 2026-06-21 15:58:42 +02:00
json_service_test.go fix(sub): preserve non-default scMinPostsIntervalMs and use per-inbound xmux in JSON subscriptions (#5393) 2026-06-20 00:57:47 +02:00
links.go feat(hosts): managed Hosts for per-host subscription link overrides (#5409) 2026-06-17 12:06:55 +02:00
links_test.go refactor: focused service files, leaf subpackages, and an internal/ layout (#5167) 2026-06-10 15:19:22 +02:00
mutation_audit_test.go fix(sub): preserve non-default scMinPostsIntervalMs and use per-inbound xmux in JSON subscriptions (#5393) 2026-06-20 00:57:47 +02:00
remark_vars.go feat(sub): add dynamic remark variables with Jalali date, transport, and status tokens (#5430) 2026-06-21 02:00:27 +02:00
remark_vars_test.go feat(sub): add dynamic remark variables with Jalali date, transport, and status tokens (#5430) 2026-06-21 02:00:27 +02:00
service.go feat(xhttp): support sessionID* rename + sessionIDTable/Length (xray v26.6.22) (#5506) 2026-06-23 17:38:16 +02:00
service_dedup_test.go feat(hosts): managed Hosts for per-host subscription link overrides (#5409) 2026-06-17 12:06:55 +02:00
service_flow_test.go feat(hosts): managed Hosts for per-host subscription link overrides (#5409) 2026-06-17 12:06:55 +02:00
service_property_test.go fix(nodes): stop multi-attached client traffic inflating across node inbounds 2026-06-15 19:31:57 +02:00
service_sharelink_test.go feat(hosts): managed Hosts for per-host subscription link overrides (#5409) 2026-06-17 12:06:55 +02:00
service_sort_test.go feat(hosts): managed Hosts for per-host subscription link overrides (#5409) 2026-06-17 12:06:55 +02:00
service_test.go feat(sub): add dynamic remark variables with Jalali date, transport, and status tokens (#5430) 2026-06-21 02:00:27 +02:00
service_userinfo_test.go refactor: focused service files, leaf subpackages, and an internal/ layout (#5167) 2026-06-10 15:19:22 +02:00
sub.go feat(sub): add option to hide server settings in subscription (happ) (#5433) 2026-06-21 00:32:56 +02:00