Commit Graph

4180 Commits

Author SHA1 Message Date
Sanaei eae4ff8e8f fix(dev): keep the page's Host on the Vite WebSocket proxy
b1108a9e made the panel reject a WebSocket upgrade whose Origin port
differs from the Host port. The dev proxy forwarded /ws with
changeOrigin, which rewrites Host to localhost:2053 while the browser
still sends Origin http://localhost:5173, so every upgrade was refused
with "request origin not allowed by Upgrader.CheckOrigin". Vite then
relayed that response to a socket the browser had already closed and
logged "ws proxy error: write EPIPE" on each reconnect, and live
updates never reached the dev server.

The /ws proxy now leaves Host alone, as a production reverse proxy
does. The HTTP proxies keep changeOrigin; they are not origin-checked.
2026-12-03 19:22:47 +03:30
Sanaei a49720e88a refactor(nodes): build the node list from the panel's Card and Table
ef99e675 (#7342) gave the Nodes page its own design system: a
hand-rolled table and card, a bundled Source Sans Pro font, a private
colour palette, 9-13px type, and page-only overrides of the sidebar
width, content padding and dark background. It no longer looked like
the rest of the panel, and it bypassed the theming every other page
gets (page-cards.css, the dark and ultra-dark tokens).

The list is now the same Ant Design Card and Table the other list
pages use, with the same small table size, default type scale and
theme tokens:

- Add Node and Node mTLS move from the page heading into the card
  toolbar, next to search and the status filter, as on Inbounds/Hosts.
- The page heading and its subtitle are removed; no other page has
  one. pages.nodes.fleet.subtitle goes from all 14 locales with it.
- Row actions are text Buttons, client counts are standard Tags, the
  status tooltip is the default Tooltip.
- The bundled fonts and the page-only shell overrides are deleted.

Everything #7342 added stays: the All nodes and Master rows, the
telemetry columns, search and filter, the row history panel, and the
stacked layout on narrow containers (now below 720px; wider than that
the table scrolls sideways like the other pages).

Horizontal scroll is CSS on the table container, not the Table scroll
prop: that prop adds a hidden measure row which repeats the header's
select-all button, a focusable control inside aria-hidden content. The
Open link takes the Button primary colour because the default link
blue is 4.1:1 on white. Both were caught by the story's axe check.

The story no longer requires the whole table to fit at 1280 and 1440;
with the panel's normal type size it scrolls there. It now asserts the
page itself never overflows and the table fits from 1664 up.
2026-12-03 18:54:56 +03:30
Sanaei bc14a39335 fix(nodes): show the empty state when no node is registered
An empty list page says so. ef99e675 (#7342) replaced the Ant Design
table with a hand-rolled one and rendered it only when a remote node
exists, so the Nodes page lost its "Nothing here yet" row and showed a
blank body under the heading.

The table now always renders its column headings, with the empty state
as a row beneath them. The Master and All nodes rows stay hidden until
a remote is registered; that part of #7342 was deliberate.

The test that pinned "no table at all" asserted the regression together
with the deliberate rule, so it now pins only the system rows.
2026-12-03 18:54:40 +03:30
Hamed 967366e7dc fix(sub): export HTTPUpgrade for Mihomo
Map Xray HTTPUpgrade to Mihomo's supported WebSocket representation.

Mihomo does not accept httpupgrade as a proxy network value. Export
HTTPUpgrade as network: ws and set ws-opts.v2ray-http-upgrade: true,
preserving the configured path and Host for both inbound proxies and
external share links.

Keep HTTPUpgrade entries out of the legacy Clash subscription because
older Clash clients may interpret the WebSocket network label as a
regular WebSocket transport and cannot honor the Mihomo-specific flag.

Regression coverage verifies VMess inbound and external VLESS output,
transport options, Host precedence, and legacy Clash filtering.

Fixes #7381
2026-12-03 18:30:31 +03:30
dependabot[bot] 5be8ab8496 chore(deps): bump @zip.js/zip.js from 2.25.0 to 2.25.1 in /frontend (#7376)
Bumps [@zip.js/zip.js](https://github.com/gildas-lormeau/zip.js) from 2.25.0 to 2.25.1.
- [Release notes](https://github.com/gildas-lormeau/zip.js/releases)
- [Commits](https://github.com/gildas-lormeau/zip.js/compare/v2.25.0...v2.25.1)

---
updated-dependencies:
- dependency-name: "@zip.js/zip.js"
  dependency-version: 2.25.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-12-03 15:24:45 +03:30
dependabot[bot] 5c5dd9ecfb chore(deps): bump @hookform/resolvers from 7.0.9 to 7.0.10 in /frontend (#7375)
Bumps [@hookform/resolvers](https://github.com/react-hook-form/resolvers) from 7.0.9 to 7.0.10.
- [Release notes](https://github.com/react-hook-form/resolvers/releases)
- [Commits](https://github.com/react-hook-form/resolvers/compare/v7.0.9...v7.0.10)

---
updated-dependencies:
- dependency-name: "@hookform/resolvers"
  dependency-version: 7.0.10
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-12-03 15:24:31 +03:30
dependabot[bot] caa5e94959 chore(deps): bump github.com/shirou/gopsutil/v4 from 4.26.10 to 4.26.11 (#7374)
Bumps [github.com/shirou/gopsutil/v4](https://github.com/shirou/gopsutil) from 4.26.10 to 4.26.11.
- [Release notes](https://github.com/shirou/gopsutil/releases)
- [Commits](https://github.com/shirou/gopsutil/compare/v4.26.10...v4.26.11)

---
updated-dependencies:
- dependency-name: github.com/shirou/gopsutil/v4
  dependency-version: 4.26.11
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-12-03 15:24:18 +03:30
dependabot[bot] f0163e9705 chore(deps): bump github.com/modelcontextprotocol/go-sdk (#7373)
Bumps [github.com/modelcontextprotocol/go-sdk](https://github.com/modelcontextprotocol/go-sdk) from 1.8.0 to 1.9.0.
- [Release notes](https://github.com/modelcontextprotocol/go-sdk/releases)
- [Commits](https://github.com/modelcontextprotocol/go-sdk/compare/v1.8.0...v1.9.0)

---
updated-dependencies:
- dependency-name: github.com/modelcontextprotocol/go-sdk
  dependency-version: 1.9.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-12-03 15:23:55 +03:30
dependabot[bot] 9a2ba4d028 chore(deps): bump github.com/valyala/fasthttp from 1.80.0 to 1.81.0 (#7372)
Bumps [github.com/valyala/fasthttp](https://github.com/valyala/fasthttp) from 1.80.0 to 1.81.0.
- [Release notes](https://github.com/valyala/fasthttp/releases)
- [Commits](https://github.com/valyala/fasthttp/compare/v1.80.0...v1.81.0)

---
updated-dependencies:
- dependency-name: github.com/valyala/fasthttp
  dependency-version: 1.81.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-12-03 15:23:25 +03:30
z-Fng 8c47df6e3c fix(i18n): translate subscription format labels in Chinese and Japanese (#7371)
zh-CN, zh-TW and ja-JP still rendered the English menu entry
"Sub Formats" and the Clash remote-DNS toggle, so users browsing the
panel in those languages saw raw English in Settings. Follow the labels
already used around them in each file: 全局路由规则 / 全域路由規則 /
グローバルルーティングルール, 範本, サブスクリプション形式.
2026-12-03 15:06:49 +03:30
Hamed 71cef6f55a fix(hosts): isolate form sessions and improve address editing
Fix Host form state leaking across Add/Edit modal sessions by creating a fresh form session for each opening and ignoring stale asynchronous completions after a session closes.

Improve the Address field with per-tag copy, multi-address paste, and accessible inline editing with validation, ordered replacement, Escape cancellation, and focus restoration. Preserve existing address formats, tag removal, schema validation, and host-port rewriting.

Guard keyboard event propagation from Edit/Copy controls to prevent Backspace from unintentionally removing a tag. Add regression coverage for form lifecycle, async races, clipboard interactions, inline editing, validation, focus, and keyboard behavior.

Verified by GitHub Actions CI on the reviewed head: 12/12 jobs successful.
2026-12-03 15:06:37 +03:30
Hamed Sanaei 7cd9b92581 fix(hosts): prevent Backspace from removing tags on action buttons 2026-12-03 14:46:54 +03:30
Hamed c483882e56 fix(inbounds): keep Detach Clients responsive on large inbounds (#7332)
Replace the unbounded Detach Clients modal with server-paged candidate loading, debounced search and a virtualized list. Preserve explicit-ID selection and add frozen all-matching scopes with exclusions so selection remains stable across pages and searches without sending an N-sized client list from the browser.

Execute large detach requests as idempotent background jobs. Revalidate source-inbound membership in bounded batches, atomically apply membership deltas, preserve ClientRecords and traffic, and queue reconciliation for remote nodes. Keep the legacy email-based bulkDetach API compatible.

Add PostgreSQL/SQLite regression coverage for concurrent membership changes, stale scopes, exclusions, retries, rollback and legacy callers, plus real master/node coverage for offline-node reconciliation. Regenerate and validate the API contract and OpenAPI artifacts.
2026-12-03 14:24:47 +03:30
Hamed Sanaei 597266e801 fix(hosts): commit address tag edits before saving 2026-12-03 14:21:55 +03:30
Hamed Sanaei 8aa99a0663 Merge remote-tracking branch 'origin/main' into codex/pr-7327 2026-12-03 14:18:05 +03:30
Benjamin Mitchell 45f6596663 fix(clients): generate unique subIds in Bulk Add (#7360)
Fixes the Bulk Add regression where a manually entered subscription ID was copied to every generated client, causing all but the first client to be rejected as duplicates. For multi-client batches, treat the entered value as a readable prefix and append an independent cryptographically random suffix; preserve the exact value for a single client and independent random IDs when the field is empty. Remove the process-wide allocation lock to avoid blocking unrelated requests during remote-node dispatch, and cover concurrent BulkCreate/Create, deleted-ID reuse, and uniqueness regressions. Document subIdPrefix in the API contract and regenerate the OpenAPI/API reference artifacts. Validation: CI 12/12 and Docs CI passed on the reviewed head.
2026-12-03 13:57:47 +03:30
Hamed 55dacd145f fix(groups): page client dialogs and submit server-resolved scopes (#7334)
Resolve the Groups page scalability issue by moving client enumeration, filtering, selection resolution, and bulk operations to bounded server-side workflows.

- Paginate candidate clients, group members, and subscription-link rows in fixed batches; perform filtering and exact totals in SQL.
- Preserve cross-page explicit selection and freeze all-matching selections with a server-issued scope token plus ID exclusions; revalidate the frozen scope before mutation.
- Resolve group-wide Adjust/Delete and inbound-wide Add-to-Group on the server while retaining backward-compatible explicit-email API behavior.
- Generate complete subscription exports from a private temporary file before sending the response, preventing partial exports if generation/read fails.
- Make frozen group Adjust updates atomic across inbound settings, normalized ClientRecord state, and ClientTraffic expiry/quota limits. Roll back the complete DB mutation if the traffic write fails.
- Add deterministic concurrency and rollback regression tests, SQLite/PostgreSQL coverage, large-group browser workflow coverage, and regenerate OpenAPI/API documentation.

Final verification on reviewed head 7421c0f462:
- CI run 47069019604: all 12 jobs passed, including race, PostgreSQL durable-first/migration, Go tests, frontend, codegen, fuzz smoke, and Node/Xray E2E.
- Docs CI run 47069019736: passed.
- PR was 6 commits ahead of main, 0 behind, and GitHub reported MERGEABLE / CLEAN.

Closes #7328.
2026-12-03 12:43:47 +03:30
Hamed Sanaei 7421c0f462 Merge upstream maintenance fencing into group client paging 2026-12-03 12:10:00 +03:30
Hamed Sanaei b0d94724f3 fix(groups): commit adjustment limits with inbound settings 2026-12-03 12:08:10 +03:30
Hamed 12e0b076a8 fix(database): coordinate migrations and restores across processes (#7322)
Coordinate database maintenance across panel, CLI, node synchronization, and restore paths.

- Add cross-process PostgreSQL advisory locks and pinned execution fences; cancel CLI work when its lease session is lost.
- Serialize SQLite file replacement with OS-level process locks and stable lock identity.
- Drain traffic writers and node-sync work before restore, then resume after migration and validation.
- Persist PostgreSQL restore-pending state and recover interrupted restores on startup.
- Add regression coverage for concurrent migrations/restores, session-loss fencing, CLI work cancellation, and recovery.

Closes #7318.
2026-12-03 12:05:51 +03:30
Hamed Sanaei 2aafa4e9b5 Merge upstream main into group client paging 2026-12-03 11:00:41 +03:30
Hamed Sanaei 51c60d4637 fix(groups): preserve frozen bulk client identity 2026-12-03 11:00:34 +03:30
Sanaei d107effd3c fix(geodata): update Iran rules source
Switch Iran geodata downloads, updater references, tests, and README acknowledgments from chocolate4u to FDeghy.
2026-12-03 10:51:47 +03:30
Hamed 52f5fb5205 fix(nodes): preserve stored API token on edit
Keep the existing node API token unless an operator explicitly requests a replacement.

Initialize edit sessions with an empty replacement draft and keep the credential field unmounted by default. Omit apiToken from Test Connection, Save, fingerprint, and inbound-loading requests in keep mode, while preserving explicit replacement, token clearing, and tokenless mTLS behavior.

Accept historyUndo/historyRedo input events so undoing and redoing an explicit replacement remains synchronized with form state. Add regression coverage for the default keep path, replacement flow, and Undo/Redo.

The first edit after a page refresh could otherwise submit an unintended non-empty password value as a replacement token, causing Test Connection and Save to fail. The exact browser/password-manager trigger was not independently reproduced; this change fixes the unsafe form/payload behavior at its source.

Addresses #7349.
2026-12-03 10:46:34 +03:30
Hamed fda676e62a fix(inbounds): page inbound info and stream peer exports (#7341)
Replace full inbound hydration in Show Info with owner-scoped, no-store reads of one display client or up to 50 WireGuard/AmneziaWG peers. Preserve absolute peer numbering, Host/node endpoint projection, selected tab and IP logs across live traffic updates; keep edit and clone on full detail.

Stream ordered NDJSON pages from a single stored inbound snapshot for explicit Export All Peers. Generate an ordered ZIP64 archive with existing client config/link generators; validate page offsets, protocol and total, and reject incomplete or cancelled exports. Renew the per-page HTTP write deadline through the original response writer before gzip wrapping, keeping ordinary endpoint timeouts unchanged.

Validated on head 0f853351: all 12 CI jobs and Docs CI passed, including 2,350 frontend tests, bounded-info Chromium stories, live-traffic and archive regressions, Go/race, PostgreSQL, and node/Xray E2E. The final review also verified a conflict-free test merge with main 38452eac, matching regenerated API contracts and passing focused controller tests, including the real HTTP deadline regression for identity and gzip.

The author's synthetic 50,000-peer fixture reduces the uncompressed Show Info response from 2,650,526 to 3,184 bytes. Stored JSON still requires a linear scan per page; explicit ZIP export retains archive data in browser memory. Slow individual writes and reverse-proxy timeouts remain operational limits. No production latency or memory guarantee is implied.

Fixes #7330.
2026-12-03 04:57:45 +03:30
Hamed 38452eacf5 fix(database): guard inbound migrations against active PostgreSQL writes (#7321)
Prevent inbound data migration from waiting behind concurrent PostgreSQL node/client writes: acquire the complete write-table set with EXCLUSIVE NOWAIT before any DML, use ACCESS EXCLUSIVE only for tables requiring legacy DDL, and surface SQLSTATE 55P03 as retryable contention. Plain SELECT remains compatible with the normal lock set.

Commit inbound normalization, orphan traffic cleanup and Vision flow repair together; propagate failures to CLI and restore callers and record transaction duration. Keep the reopened database pool private during host-settings restoration and inbound migration, with bounded retries of lock acquisition.

Remove duplicate post-start migration and fail installation/update before service startup when migration fails. Preserve the stopped/disabled service unit so systemd and OpenRC updates can be retried; replace the unit only after successful migration.

Verified reviewed head 56e0372a09: all 12 CI jobs passed, including PostgreSQL contention/reader/private-pool regressions and Go/race. Detached test merge against main d6afe0ef3c was conflict-free and git diff --check passed. Integrated local targeted tests passed for private pool, telemetry migration, SQLite rollback, and shared descendant selection (all eight subcases); PostgreSQL-specific tests skipped locally and verified in PR CI. Full integrated CI and live service-manager testing were not rerun.

This is a scoped fix, not an atomic whole-database restore or proof of resolution of the historical 41-second SQL tail. Persistent external writers or post-import migration errors can still leave an already committed import requiring recovery; broader schema/restore maintenance coordination and writer occupancy investigation remain open.

Review: https://github.com/MHSanaei/3x-ui/pull/7321#issuecomment-7364094359
Refs #7305 (keep open).
2026-12-03 04:48:16 +03:30
Hamed d6afe0ef3c fix(routing): bound client suggestions in the user picker (#7338)
Replace the eager unpaged client catalog request in the routing rule editor with an admin-only, email-only suggestions endpoint. Project the email column in SQL, enforce a fixed 50-result limit, and use parameterized literal substring matching with request cancellation.

Fetch only while the User picker is open, debounce nonempty searches by 250 ms, and cancel superseded queries. Preserve saved and manual tags, comma-separated entry, the routing rule user array, and Save when suggestions fail.

Add HTTP regression coverage for 50,002 records, token scopes, response shape and literal wildcards, component coverage for stale requests and tag preservation, and browser stories for 1k/10k/50k synthetic catalogs. Update OpenAPI and API reference.

Reviewed head: c01ec35f99. All 13 CI/Docs jobs on the PR head passed. A detached local test merge against main ef99e67507 completed without conflicts; regenerated Go schemas and OpenAPI matched the staged merge, with identical frontend/docs OpenAPI copies (101 schemas, 214 paths, 227 operations). Full CI on the latest integrated tree and independent PostgreSQL-specific execution were not performed. See https://github.com/MHSanaei/3x-ui/pull/7338#issuecomment-7363795973.

Closes #7329
2026-12-03 04:38:56 +03:30
Hamed ef99e67507 feat(nodes): add fleet monitoring and implement the Penpot layout (#7342)
Expose sampled CPU topology, absolute RAM, TCP/UDP counts, load averages and network throughput through the existing heartbeat and descendant contracts, preserving measured zero versus unavailable values. Add an explicit nullable telemetry migration and freshness/availability checks.

Provide read-only All nodes and Master rows with deduplicated host/client totals, grouped SQL aggregation and reporting coverage. Preserve known descendants during parent outages and prefer the freshest valid observation of shared GUIDs. Keep the ordinary heartbeat broadcast free of fleet-wide totals.

Implement the approved compact Penpot-inspired Nodes layout, responsive stacked details, status diagnostics and existing remote actions. Preserve cached rows, search and controls on overview refresh failures. By maintainer decision, hide both system rows when no remote nodes are registered.

Final review of 44ed457985: no outstanding HIGH or MEDIUM findings. CI and Docs CI passed (13 jobs; 2342 frontend tests in 269 files), including Go/race and mixed-version node E2E. Feature-specific PostgreSQL regression execution was not independently verified in the selected CI logs. See https://github.com/MHSanaei/3x-ui/pull/7342#issuecomment-7363599190.

Closes #7335
Closes #7336
Closes #7337
2026-12-03 04:19:48 +03:30
Hamed 0afa11ddff fix(nodes): share lightweight remote inbound catalog refreshes (#7313)
Replace full inbound/client-list downloads on cold remote ID lookups with an owner-scoped six-field catalog projected directly from the database. Coalesce concurrent catalog refreshes per remote while preserving independent caller cancellation and rejecting stale ID mappings after topology mutations.

Seed reconciliation from the catalog, create missing inbounds directly, preserve prefixed/adopted aliases and invalidate pushed state when remote IDs change. Avoid invalidating catalog generations on unchanged-ID settings pushes. Retain client-membership-aware reconciliation state and legacy full-list fallback only on HTTP 404/405.

Cover permissions, query projection, concurrent refresh/cancellation, deletion/recreation, reconciliation request counts and mixed-version node compatibility. Integrated CI and Docs CI passed, including race, node E2E and PostgreSQL catalog projection. Synthetic response-size comparison is not a production latency benchmark.

Fixes #7303.
2026-12-03 03:26:44 +03:30
Hamed 8a686cd8bd perf(frontend): reuse inbound client rollups (#7288)
Cache online-independent client rollups by inbound row identity, reuse unchanged per-GUID online sets, and update only affected online overlays. Defer email popover rendering until opened and cooperatively schedule large-list rollups.

Keep the table mounted during structural refresh and detail hydration, withholding mismatched-generation counts and guarding delete-all confirmations. Preserve search, node filters and selection, and use the current cache for subscribed WebSocket updates. Retain #7289's unavailable, pending, idle, legacy and partial-report attribution semantics.

Validated on the reviewed head: all 12 CI jobs passed, including 2,338 frontend tests, ten identity regressions, the synthetic 120,000-membership Chromium story, PostgreSQL online attribution regressions, race checks, and Xray/node E2E. Includes test-only stabilization of existing relay and Telegram assertions. Production latency improvement has not been independently measured against main.

Fixes #7281.
2026-12-03 03:00:12 +03:30
Hamed fb14c8358a fix(inbounds): distinguish unavailable online attribution (#7289)
Distinguish unavailable, pending, explicitly idle and legacy inbound online reports across REST, WebSocket and node snapshots. Require hosting-node emails and matching inbound activity; use a labeled node-wide fallback only for confirmed unsupported endpoints (HTTP 404/405).

Track Xray freshness separately from sidecar observations and prevent accounting retries from publishing online state across core replacement. Preserve partial sidecar reports through mixed-version relays using the reserved nonempty NUL marker. Retain GUID/tag remapping and attached-client filtering.

Validated on the reviewed head: all 12 CI jobs and Docs CI passed, including 2,332 frontend tests, mandatory PostgreSQL attribution regressions, race checks, Xray/node E2E and all four master/node version combinations. Exact client attribution across simultaneously active shared-client inbounds remains an estimate; older nodes may omit idle GUIDs during rollout.

Fixes #7283.
2026-12-03 02:37:40 +03:30
Hamed 6f59a79bc2 perf(inbounds): cache slim settings by structural revision (#7287)
Avoid repeatedly loading and decoding full inbound settings on the slim UI list path. Read scoped inbound metadata without Settings, reuse immutable projections keyed by database handle, inbound ID and structural revision, and fetch cold or changed rows in bounded batches. Preserve row-version consistency on misses, exclude deleted rows, and bound the LRU to 2,048 entries and 32 MiB of settings content. Existing SQLite/PostgreSQL revision triggers cover structural/direct SQL edits; counter-only changes retain cache reuse. Keep shared-client stats, fallback annotations, global traffic overlays and full-list/detail contracts intact.

Add an exact-PASS PostgreSQL regression gate and a production-shaped benchmark with 30 inbounds, 7,100 clients and 115,000 actual membership rows.

Validation: [final review](https://github.com/MHSanaei/3x-ui/pull/7287#issuecomment-7360333998), [CI 12/12](https://github.com/MHSanaei/3x-ui/actions/runs/46976935406), PostgreSQL 16 regression PASS, race, frontend 2,311 tests and four node-version pairings. Independent Lenovo SQLite/PG18 tests and [benchmark](https://github.com/MHSanaei/3x-ui/pull/7287#issuecomment-7359646826): stable JSON identical (39,246,921 bytes); warm p95 2670 -> 1031 ms, settings 46,122,401 -> 0 bytes, allocations -36.2%; concurrent structural edits p95 2673 -> 1148 ms, settings bytes -97.1%. Cold full reads remain and allocations increase 1.8%. Eight samples, same-binary baseline, synthetic topology, no production latency guarantee.

The reviewed head is one commit behind main solely due to nonoverlapping #7277 dashboard/docs changes; both trees passed their own CI, but combined-tree CI remains to be verified after merge. No schema or wire-format change.

Refs #7009
2026-12-03 01:42:49 +03:30
Hamed b351b08601 feat(dashboard): persist one overview time range (#7277)
Consolidate the six overview range selectors into a single translated action-bar control beside Xray Metrics. Persist the validated selection per browser origin and panel base path with a safe 2m fallback, including unavailable storage. Restore the preference before history fetching and retain live status sampling while viewing longer ranges.

Avoid overlapping delayed live-history seeds, track sampled scope epochs, use separate scoped/unscoped boundaries and reject stale responses. Cover scope transitions, clock skew bounds, storage failures and range propagation. Update English and Persian documentation without changing schema or backend API contracts.

Validation: all 12 CI jobs and Docs CI passed on 2d3992766b277974f2cb4b4b44af1a6a456653dd; frontend 265 files / 2,330 tests, including 12 global-range, 11 ranged-history and 8 container-history cases. Browser restart and responsive/RTL checks reported by author, not independently rerun. Persistence is browser-local; arbitrary clock skew cannot guarantee complete live history.

Closes #7276
2026-12-03 01:18:05 +03:30
Hamed 1e1b32247e perf(clients): avoid repeated inbound settings reads (#7312)
Reduce repeated inbound settings materialization with a protocol-aware preparation projection that retains node_id. Reuse the locked validation/mutation snapshot while preserving the transaction-time settings reread and three-way rebase. Gate effective Create/Attach Flow before grouped payload construction; retain public Add and bulk/copy semantics.

Preserve #7367 grouped Create, intended-payload fingerprint CAS, ordered turns, cancellation, metadata ordering, durable delete/reattachment safeguards, node outcomes and PostgreSQL lock ordering. Add a mandatory PostgreSQL gate for nine read/protocol regressions without weakening the existing 21 ordering/grouped-create cases.

Validation: all 12 CI jobs passed on 9062e5cf94 (run 46971334865), including PostgreSQL 9/9 and 21/21 focused gates, race, and all four version pairings. Author-reported paired PostgreSQL 16 fixture: 44 -> 22 full reads, 64.82 -> 32.41 MiB materialized per local Create, p95 497.0 -> 400.9 ms; contended Create p95 994.2 -> 633.5 ms and Update 1118.4 -> 937.5 ms. Single-node grouped Create stays one RPC. Necessary protocol/Flow reads and Attach preparation remain; no WAL redesign or production latency claim.

Refs #7300
2026-12-03 00:56:57 +03:30
Hamed 91d5ff400d perf(clients): batch client creation by destination node (#7367)
Group compatible client creates by destination and effective payload via the existing clients/add API. Resolve node-local inbound IDs, preserve distinct flow/address/credential payloads, bound delivery concurrency and use a shared four-second remote delivery budget after local commits.

Advance reconciliation fingerprints only for acknowledged intended settings, retaining previous-fingerprint CAS rather than stamping unrelated rebased changes. Preserve FIFO turns, node-wide barriers, dirty generations, durable delete supersession, partial and uncertain delivery recovery and downstream outcomes. Protect later reattachments in final Delete cleanup and complete Create metadata before remote delivery.

Validation: all 12 CI jobs passed on 63e70cda38 (run 46935177853). PostgreSQL logs confirm 21 ordering/grouped-create tests and prior reporter-lock, reconciliation and traffic contention gates; node E2E confirms all four version pairings. Author reports SQLite/PostgreSQL race tests, make verify and isolated full make race.

Author-reported paired PostgreSQL 18 benchmark: 11 -> 1 RPC, fixed 200 ms peer delay 11-target p95 1552.0 -> 731.9 ms, timeout probe 12.41–12.42 -> 4.41–4.50 s. Size-dependent peer cost can instead cause pending delivery (1.74 -> 4.51 s with 0.74 s recovery); four stalled nodes can defer a fifth. Monitor production convergence and pending rate. No general production latency or allocation improvement claimed.

Refs #7299
2026-12-03 00:08:12 +03:30
Hamed 32e4b8bcfe perf(ip-sync): batch node client IP attribution writes (#7347)
Batch changed node_client_ips rows in bounded deterministic 190-row statements with snapshot CAS, affected-row/replacement-ID checks, whole-GUID rollback and retry, insert-only RETURNING id and guarded pruning. Preserve exact timestamps, canonical no-op skipping, GUID scoping and flat IP-limit behavior.

Integrate independent node polling with transactional reporter eligibility and identity fences. Avoid the reproduced PostgreSQL flat-IP/node ABBA cycle by ordering flat IP DML before reporter validation at commit; retain node-before-attribution ordering for GUID writes and node deletion. Prelock rename and bulk cleanup targets in byte order and reject stale email CAS attempts. Preserve SQLite immediate write transactions, ordered dispatch, durable deletion and existing traffic reconciliation. No network I/O under the new DB locks or global IP-sync serialization.

Validation: all 12 CI jobs passed on c2831ca52f (run 46915194728). PostgreSQL logs confirm delete/rename/bulk lock order, independent reporter progress, lifecycle rollback on disable/delete/endpoint/GUID changes, guarded prune, scanner enforcement and existing durable-delete/reconciliation regressions. Author reports RED SQLSTATE 40P01 on af77a55d, focused SQLite/PostgreSQL race tests, make verify and all four node E2E version pairings.

Author-reported PostgreSQL 16 fixture: 552 -> 4 UPSERTs/round, unchanged 70,656 affected rows, merge p95 387.8–391.1 -> 72.3–81.4 ms, handler p95 16.9–19.5 -> 8.9–11.7 ms. Contention: 2 -> 0 observed deadlocks; corrected 192/192 reports succeeded. Loaded-host tails increased; idle-host repeats did not show a consistent material regression. WAL reduction and production latency improvement are not established. Monitor lock waits and CRUD tail latency separately.

Fixes #7298
2026-12-02 19:46:44 +03:30
Hamed 7a5a25fae2 perf(nodes): reuse client link changes during full reconciliation (#7344)
Reuse client records and successful link diffs during full node snapshot reconciliation. Preserve master-owned comments on existing records while importing new comments; omit comment writes so concurrent operator updates survive. Deduplicate detached IDs across successful inbound savepoints and mark only globally unattached clients in bounded 400-ID batches inside the existing transaction; roll back on orphan-mark write failure.

Integrate against current main while preserving #7314 target-node pending-delete cancellation and cross-node recreation guarantees, #7315 staged traffic and batched baseline writes, and #7308 serialized eligibility checks. Preserve orphan recovery, degraded-inbound safeguards and idempotent snapshot replay.

Validation: all 12 CI jobs passed on 51e627739e (run 46895213148). PostgreSQL logs confirm four new reconciliation tests, both contention/baseline regressions and eight ordering/durable-delete regressions. Author reports focused SQLite/PostgreSQL 18 race tests, make verify and all four mixed-version node E2E pairings.

Author-reported controlled 4096-client PostgreSQL 18 fixture: idle SQL statements 350 -> 270, changing-counter statements 552 -> 472, rows read 151832 -> 102680. Idle writer p50/p95 490/597 -> 430/466 ms; counter writer 489/521 -> 449/519 ms. Idle cycle p50/p95 1118/1277 -> 1015/1050 ms; counter cycle 1121/1172 -> 1046/1135 ms. Worst counter cycle effectively unchanged. These fixture results are not independent production measurements. Production tail latency, shared-client compact-cache reuse and migration coordination remain separate follow-ups.

Refs #7305
2026-12-02 17:44:17 +03:30
Hamed 0db9503228 fix(nodes): isolate traffic sync and report client apply outcomes (#7308)
Isolate traffic synchronization with bounded round-robin per-node workers, independent maintenance and publication, cancellation and ordered shutdown drain. Recheck online eligibility inside the serialized writer before merging snapshots and retain the latest valid speed sample per node, with expiry and explicit empty publication.

Report direct per-node applied/pending/failed outcomes without changing local-save success semantics. Propagate downstream pending separately from direct ACKs so acknowledged batch items do not abort subsequent work. Integrate live admission into the existing #7314 ordered dispatcher with separate four-second queue and batch budgets, retaining monotonic dirty generations, exclusive full-delete/reconcile turns, durable deletion outbox, generation-matched settlement, cross-node recreation safeguards and targeted fingerprint invalidation. Preserve legacy peer compatibility and update generated API documentation.

Validation: all 12 CI jobs and Docs CI passed on reviewed head d13850474f (runs 46871519847 and 46871519831). PostgreSQL logs confirm eight ordering regressions, including saturation, lost ACK, cross-node recreation and bulk recovery. Author reports make verify, focused SQLite/PostgreSQL race tests, four mixed-version node E2E pairings and Xray E2E. No independent production-scale latency measurement or universal HTTP timeout guarantee.

Residual follow-ups: possible conservative false-pending result when a final full delete settles an intermediate superseded intent on the same node; add per-logical-operation settlement regression. Verify shutdown drain under a blocked writer/maintenance worker. These static-review concerns remain open for follow-up, not demonstrated data loss or a new deadlock.

Refs #7293
2026-12-02 16:47:26 +03:30
Hamed 2e0c751a80 fix(nodes): order client pushes outside inbound mutation locks (#7314)
Release inbound mutation locks after durable local commit and reserve conflicting remote dispatch turns in writer commit order. Allow independent inbounds to progress concurrently while reconciliation and full client deletes retain node-wide ordering. Bound queue waits and live batches separately, advance dirty revisions strictly, and invalidate only affected remote fingerprints.

Persist permanent-delete intents transactionally per node/email and replay bounded pages during reconciliation. Match acknowledgements to the queued generation and retain failed/ambiguous deliveries. Supersede pending deletes only when the client is desired on the target node, so recreation on another node does not leave an old orphan record. Preserve pending rows during database migration and accept legacy backups without the outbox table.

Validation: reproduced the cross-node orphan on the previous head; fixed regression passed locally on Lenovo with focused SQLite (9/9) and PostgreSQL 16 (7/7). All 12 CI jobs passed on 5459316fbd (run 46862646487), including race, PostgreSQL migration and durable-first, and node/Xray E2E. PostgreSQL logs confirm all seven ordering tests including cross-node recreation, lost acknowledgement and bulk recovery after database reopen. Branch is up to date with main. No measured production latency claim; requests still wait for their own bounded ordered remote apply. Coordinate overlapping #7308 before its integration.

Fixes #7304.
2026-12-02 14:23:45 +03:30
Hamed bdddb08249 fix(nodes): shorten the traffic merge lock window (#7315)
Stage existing client traffic updates in snapshot order and flush them after client reconciliation to shorten PostgreSQL row-lock lifetime. Keep configuration, traffic counters, renewals and baselines atomic in the same serialized transaction, preserve concurrent last_sub_fetch updates, and retain rollback and idempotent replay semantics.

Batch baseline upserts by (node_id, email) within SQLite parameter limits. Decode snapshot claims before opening the transaction while retaining transactional ownership checks. Add debug metrics for queue wait, writer execution and transaction duration.

Validation: all 12 GitHub CI jobs passed on reviewed head 6dc504b675, including race, PostgreSQL, node and Xray E2E. PostgreSQL CI logs explicitly confirm both contention and baseline batching regressions. The author reports PostgreSQL 16/18 validation, rollback/replay coverage and a reduction from 4,187 baseline upserts to 28 in a local fixture.

Scope: this resolves the reproduced subscription row-lock window, not the full serialized writer hold, shared-client cache restriction, historical 41-second SQL tail or cross-process migration/restore deadlock. These require follow-up. No independent production measurements or successful CI run on the exact latest combined revision were verified before merge.

Refs #7305
2026-12-02 13:02:15 +03:30
Hamed 9f483d9465 fix(inbounds): check WebSocket snapshot size before loading (#7309)
Avoid materializing full inbound settings and client statistics only to discard the snapshot above the existing 5,000-row WebSocket cutoff. Probe user-scoped direct and sibling-backed traffic rows with bounded SQL before loading the snapshot; skip work without subscribers, fall back to invalidation on probe failure, and retain the post-read guard for concurrent growth.

Coalesce WebSocket invalidations by resource in a 200 ms window so paired Inbounds and Clients events refresh both query roots without duplicate same-resource refetches.

Regression coverage exercises the real inbound mutation route and WebSocket hub at and above the cutoff, shared traffic, user scoping, no subscribers, and frontend paired invalidations. All 12 CI jobs passed on the reviewed PR head. The author also reports SQLite/PostgreSQL 16 validation and make verify. Static review of the current merge candidate found no overlapping file changes with main; CI on that exact combined revision was not independently run before merge.

The reported synthetic SQLite notification benchmark (30 inbounds, 7,101 clients, 115,041 associations) improved from 323.87 ms to 0.24 ms and from 324,751,126 to 5,393 allocated bytes per operation. These figures do not establish production HTTP or browser latency improvements.

Fixes #7297
2026-12-02 12:30:15 +03:30
Hamed b2d7a9bb08 fix(panel): break Xray restart deadlock and bound panel reload (#7346)
Fix the production-confirmed ABBA lock inversion introduced in v3.12.0: Xray restart held the lifecycle mutex while synchronously waiting for the serialized traffic writer, which needed the same mutex to amend the committed live configuration snapshot. This blocked API writes and node synchronization, and made panel reload wait indefinitely for cron shutdown.

Run traffic maintenance before acquiring the Xray lifecycle mutex, keep config generation free of writer submissions, and retain the live-snapshot generation guard. Bound panel-only reload with one 75-second deadline across shutdown and startup; fence replacement workers until the old generation drains, and exit nonzero for supervised recovery on failure. Preserve Xray on healthy reloads, gracefully handle termination signals, log phase timings and bounded function-only stack diagnostics, and distinguish accepted restart requests from successful completion.

Validation: all 13 GitHub checks passed on the reviewed head, including Go tests, race, PostgreSQL durable-first/migration, node and Xray E2E, frontend, lint, codegen, vulnerability check and docs. PR validation reports isolated SQLite/PostgreSQL 18 reload tests with 15,844 clients and 30,270 memberships, stable real Xray PIDs, and legacy/current node interoperability.

Addresses the primary deadlock and bounded panel reload; writer cancellation and per-source listener admission diagnostics remain follow-ups. Supervised failure recovery may interrupt Xray sessions.

Fixes #7345
2026-12-02 11:40:21 +03:30
Hamed Sanaei 7e6f64cd01 fix(groups): reject incomplete subscription exports
Finish generating the export in a private temporary file before sending a success response. Keep memory bounded, send the complete length, and discard staged data when the database read fails.
2026-12-01 12:16:34 +03:30
Hamed Sanaei 1ac11c7783 fix(groups): page client dialogs and submit server-resolved scopes
Keep group client tables and bulk requests bounded with paged queries, frozen selections, and a streamed subscription export. Reuse existing bulk mutations and preserve the explicit-email contracts.
2026-12-01 11:36:45 +03:30
Hamed Sanaei 678816c3ff fix(hosts): reset form sessions and support address tag editing 2026-12-01 10:02:26 +03:30
Sanaei 267379456a chore(wirecodec): pin the node encoder's retained-memory budget
Two of the three options that bound the encoder had no test. With the
worker cap removed, or zstd's low-memory mode dropped, every test stayed
green while an encoder built for 64 CPUs retained 154 MiB or 13.7 MiB
instead of 9.1 MiB. Only the 1 MiB window was pinned, through the frame
header.

Build the encoder in newEncoder(cpus) so a test can size it for a
many-core host whatever machine runs it, warm every pooled workspace and
fail above 12 MiB.
2026-11-30 23:20:38 +03:30
Hamed Sanaei bd8648de73 perf(wirecodec): bound node envelope compression memory (#7275)
The shared zstd encoder for master-to-node request bodies was built with
library defaults: one workspace per CPU, each holding a 16 MiB history for
the default 8 MiB window. The pool hands its workspaces out in rotation and
never frees them, so a 4-vCPU master kept about 70 MiB alive after its
first few pushes and a 16-core one about 280 MiB.

Build it with a 1 MiB window, at most four workers and zstd's low-memory
mode, which retains about 10 MiB whatever the CPU count. Callers queue for
a worker on a slot channel, so a cancelled push stops waiting instead of
blocking inside EncodeAll. Frames stay standard zstd: capability
negotiation, the SHA-256 of the uncompressed body and the node's decode
bounds are unchanged.

Closes #7274
2026-11-30 23:16:52 +03:30
Hamed 4a680cb859 fix(sub): export Loon REALITY with the Chrome 147 profile (#7248)
* fix(sub): export Loon REALITY with the Chrome 147 profile

* fix(sub): detect Loon on the default subscription URL

* docs(sub): translate the Loon REALITY import section into fa, ru and zh

The Loon section added to the English REALITY page had no counterpart in
the other three locales, so readers of those pages never learned that the
default subscription URL now serves Loon's native format, or that
format=loon and format=raw select it by hand.

---------

Co-authored-by: Sanaei <ho3ein.sanaei@gmail.com>
2026-11-30 22:54:25 +03:30
delifer 6e2589e6c9 Add LibreSpeed functionality to x-ui.sh (#7224)
* Add LibreSpeed functionality to x-ui.sh

I have applied the fixes we discussed earlier to the current version of the PR; please let me know if you have any further questions or comments.

A hashsum check has been added, and the application itself runs with very restricted privileges, as it should.

* Update selection range in x-ui.sh to 0-29
2026-11-30 22:08:05 +03:30
Sanaei 15feed9ea7 chore(security): run the scanner's real-core tests against the go.mod core
The OSS Scanner image pointed XRAY_E2E_BINARY at the release binary that
DockerInit.sh downloads, while CI's `make xray-e2e` builds the core from the
commit go.mod pins. The two are the same commit today (v26.11.9), but they
part whenever go.mod moves to an unreleased commit, and the scanner's baseline
would then run the gRPC tests against a core the panel code was not written for.

The image now builds that core as xray-e2e and points the variable at it; the
release binary stays as /usr/local/bin/xray, which is what a live panel runs.
The comment also named two of the three packages the variable turns on.
2026-11-29 23:37:40 +03:30