Commit Graph

872 Commits

Author SHA1 Message Date
Hamed 36f462ca94 fix(frontend): show inbound loading and retry states (#7286)
Expose separate loading feedback for the inbound list and client rollups, and retry only failed online-attribution requests.

Finish in-flight rollup snapshots during WebSocket churn and coalesce subsequent updates. Invalidate published counts on structural generation changes, including slim refetch and detail hydration, while keeping the table mounted and preserving operator context. Preserve the per-inbound cache and attribution semantics from #7288 and #7289.

Add regression coverage for continuous live updates, structural refresh and hydration, and failed-then-successful attribution retries.

Validation: CI 47166924945 passed all 12 jobs, including 2,394 frontend tests, 13 inbound identity tests and the 120,000-membership Chromium story. No backend, database or API changes.

Fixes #7282.
2026-12-03 21:43:34 +03:30
Sanaei 952f293b4e fix(overview): report the CPU clock speed 2026-12-03 19:23:42 +03:30
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
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
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 Sanaei b0d94724f3 fix(groups): commit adjustment limits with inbound settings 2026-12-03 12:08:10 +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 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 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 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 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 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 645a114d03 chore(deps): update go, frontend, docs and toolchain dependencies
Go: quic-go/quic-go 0.65.0 -> 0.66.0, grpc 1.86.0-dev -> 1.87.0-dev, and
the indirect pion/transport/v5 5.1.6, segmentio/asm 1.2.1, x/oauth2
0.38.0, blake3 1.5.3, x/exp, x509roots/fallback and genproto rpc.
apernet/quic-go, gvisor and xtls/reality stay where xray-core pins them.

Frontend: vite 8.3.8 -> 8.4.0, oxlint 1.90.0 -> 1.95.0, oxfmt 0.78.0 ->
0.80.0, the vitest group 5.1.1 -> 5.1.2 with its @storybook/addon-vitest
overrides, and patch moves of storybook, react-router, react-query,
i18next, msw, @hookform/resolvers, @types/react, lint-staged and
oxlint-tsgolint. fsevents joins allowScripts as denied: it ships a
prebuilt binding, and npm warned about it on every install.

Docs: lucide-react 1.83.0, mermaid 12.4.0, oxlint 1.95.0, oxfmt 0.80.0,
vitest 5.1.2 and patch moves. pnpm appended no release-age waiver and
gen:api leaves the API reference untouched.

Toolchain: pnpm 12.16.1 -> 12.23.0 in docs packageManager with its
sha512 hash. Go 1.27.4 and Node 26 are already current.

oxlint 1.95.0 puts the React Compiler rules in the correctness category
and reported 15 errors in 12 files, fixed here rather than silenced:

- The log, version, geodata and API-token loaders fetch inside their
  effect and drop a reply the user has already moved past, so a slow
  response no longer overwrites a newer one (test added for LogModal).
- ClientsPage, ClientFormModal, CloneInboundModal and DnsTab reset
  state while rendering instead of in an effect; on the clients page a
  filter change no longer issues a request for the stale page first.
- Refs are no longer written during render: the clients row lookup and
  the advanced JSON editors seed them outside it, and
  OutboundSubtreeJsonForm reports through useEffectEvent.
- The mobile client card's info action is a real Button, like the
  action next to it.

Four antd props that lint:deprecated already rejected on main are
replaced too: Space direction, and filterOption / optionFilterProp
outside showSearch.
2026-11-29 22:47:27 +03:30
Hamed 1ec55aed30 perf(node-sync): avoid redundant full inbound snapshots (#7014)
Every five seconds the master fetched each node's complete inbound list, settings JSON and enrichment included, parsed it and reconciled every client, whether anything had changed or not.

A node that advertises traffic-snapshot-v1 now answers a revisioned endpoint: counters and lifecycle state on every poll, inbound configuration and attachments only when its revision changed. The master skips structural parsing and client reconciliation while the node's revision, its own rows for that node, the lifecycle state and the full remote-to-central inbound mapping are all unchanged; anything else falls back to the full merge. Old and new panels keep talking through the previous endpoints.

Revisions come from a hidden per-row token on inbounds and clients, maintained by database triggers on SQLite and PostgreSQL so that direct and background writes count too. Counter and timestamp updates leave it alone. The triggers are dropped before migrations and recreated after them, and the previous build runs unchanged on a database that carries them.

Measured here at 20,000 clients on one node, per idle poll: master SQL statements 551 -> 44, node statements 55 -> 4, transfer 23.0 MB -> 4.8 MB. When every client is shared between nodes the ownership checks keep the full master merge, so only the node and the transfer get cheaper. The node still reads every membership and counter on each poll.

Closes #7007
2026-11-29 18:38:51 +03:30
Hamed a9d22498c2 feat(traffic): separate depletion restarts from client disables (#7267)
One switch decided two things: whether Xray restarts when a client is disabled or deleted by hand, and whether it restarts when a client runs out of quota or expires. A panel that takes many API deletes had to choose between a restart on each of them and leaving depleted clients' open connections alive.

Add a switch for the quota and expiry case. It inherits the old switch until it is saved, and older settings clients may omit it. A depletion asks for one restart per affected running core per committed batch: the local core when a local inbound served the client, and each affected node through the node API. A master whose nodes alone served the client is not restarted. With the new switch off, a depleted client is still removed from the running core and from its config snapshot, so a later reconcile does not restart for it either.

Also add a node traffic fetch timeout setting (1 to 30 seconds, default 4).

Run on a panel with real cores: with the old switch off and the new one on, a stream through a client that crossed its quota was cut within one poll and the lifecycle log names client_depletion; with them swapped, the stream and the core survived. A depletion a node detects itself follows that node's own switches.

Refs #7145
2026-11-29 18:25:19 +03:30
Hamed 4954b032f1 feat(nodes): show live network throughput (#7249)
Comparing current traffic across nodes meant opening each node's history chart. The heartbeat already carries every node's upload and download rate.

Show both rates in a stacked column of the Nodes table, between Memory and Xray Version, and in the mobile detail dialog, which now follows heartbeat updates. A measured idle link reads 0 B/s; a disabled, offline or transitive node, a peer too old to report throughput, and a sample older than 30 seconds read as a dash. The sample's age is computed on the master and anchored to when the browser received it, so a skewed browser clock does not blank the column.

The probe now records a missing or invalid direction as unavailable where it used to store zero, so such peers also stop adding zero points to the history chart.

Fixes #7238
2026-11-29 17:44:53 +03:30
Hamed 5d2d068484 feat(traffic): make the external traffic inform interval configurable (#7266)
The external traffic webhook was sent from inside the 5-second accounting job: its cadence could not be changed, and a slow receiver held up accounting.

Add an interval setting (5 to 3600 seconds, default 5). The accounting poll only sums each tick's deltas per client email and per inbound or outbound tag; once the interval has passed, the batch is posted from its own goroutine. Accounting, quota enforcement and online updates keep their 5-second cadence.

Delivery semantics are unchanged: each batch is posted once. A failure drops it, warns once with the reason (never the URI) and reports when deliveries resume. Destinations are checked at dial time and redirects are refused. A settings client that omits the interval keeps the stored value.

Fixes #7028
2026-11-29 17:28:55 +03:30
Sanaei 8205a5be6a chore(repo): untrack the node_modules link that #7263 carried in
The squash of #7263 included frontend/node_modules as a symlink to a local
path. It was a worktree link that the node_modules/ rule does not ignore: a
trailing slash matches only a real directory. Pulling that commit replaced an
installed, ignored frontend/node_modules directory with the dangling link.

Remove the link and ignore node_modules whether it is a directory or a link.
Anyone who pulled main in between needs npm ci in frontend/ again.
2026-11-29 17:05:44 +03:30
Hamed 47565b71d3 fix(traffic): require a URI for external traffic notifications (#7263)
External Traffic Inform could be saved enabled with a blank URI. Every traffic tick then built the full payload and POSTed it nowhere, logging one "missing port in address" warning per tick (about 17,000 a day in the report).

Refuse the save when the switch is on and the URI is empty. A database that already holds that state skips the notification before the payload is built and warns once per episode, naming why the destination was refused without echoing a malformed URI. Local traffic counters and last-online times are still committed on the skip path.

Fixes #7261
2026-11-29 16:35:47 +03:30
Sanaei af917bc0af fix(clients): keep the client form footer inside a phone screen
The "Usage & change history" button made the edit form's footer four
labelled buttons in one row that cannot wrap. On a phone that row is
wider than the modal, so the modal grew past the screen and Cancel and
Save ended up outside it.

Below 768px the two extra actions, Reset Traffic and the history button,
now show only their icon and keep their name as an aria-label, so the
row fits again. The row may also wrap, as a guard for a locale whose
Cancel and Save labels are unusually long. Wider screens are unchanged.

Layout is out of reach of the jsdom tests. Measured in headless Chromium
at 360px on a running panel: before, three of the four buttons lay
outside the viewport; after, all four sit on one row inside it in
en-US, fa-IR and ru-RU, and at 1280px the labels are still shown.
2026-11-29 15:00:25 +03:30
Sanaei c23e1cb231 feat(nodes): show how many clients are online on the node itself
Since a69f2dee a node's online report is cut to the clients linked to
its inbounds on this panel, so a node that also serves inbounds the
panel does not import (inboundSyncMode=selected, or inbounds created on
the node) shows only part of its load, and an operator cannot tell a
busy node from an idle one.

The panel now counts the distinct clients in the node's own entry of
that report before the cut and keeps the number only: the emails of
clients it does not manage are still dropped, so they cannot mark
another client online or reach the IP limit. The count needs no new
node endpoint, so nodes on older builds report it too, and it is
dropped together with the node's online clients when the node is no
longer synced.

The Nodes page shows it as "synced / total" in the online tag when the
node reports more than the synced count. Transitive sub-nodes carry no
total: the panel takes no counts from an intermediate node.
2026-11-29 13:47:59 +03:30
Sanaei 32615e1d76 fix(mtproto): stop claiming mtg auto-detects the public IP for ad-tags
The Public IPv4/IPv6 hint told operators to leave the field blank so mtg
would detect the address itself. mtg-multi has no such detection for the
middle proxy: with the field empty it feeds its socket's local address
into the middle-proxy key schedule, which only matches what Telegram
sees when the public IP sits on the server's own interface.

Behind NAT or a Docker bridge the handshake is refused, so every
connection of an ad-tagged client spends 5-7 seconds on the middle proxy
before falling back to a direct connection, and the sponsored channel
never appears. Measured against real Telegram with a tagged and three
untagged clients; the untagged ones were unaffected.

The hint in all 14 locales now says when blank is correct and when the
address must be entered. The two code comments repeating the claim are
corrected with it.
2026-11-29 13:21:29 +03:30
Hamed 75dc6dc61c fix(inbounds): scale bulk client attachment selection (#7243)
With around 10,000 clients both attach dialogs loaded every client, pre-selected all of them and rendered every row, which locked the browser for minutes.

Both dialogs now ask the server for 100 rows at a time and render only the visible ones. Select All freezes the eligible client IDs that match the current search and group into a small server-issued token; the browser keeps that token plus the clients the operator unticked instead of thousands of emails, and the listing marks each row against the frozen filter so rows outside it stay unselected. On submit the server re-derives the same set and rejects the job before any write when its membership changed; clients created after the freeze stay outside it. The attach runs as a background job the dialog polls for counts.

Requests that post an email list keep their synchronous response. The Postgres job now runs the selection tests, which build their predicates by hand for both dialects.

Fixes #7236
2026-11-28 18:00:53 +03:30
Sanaei 44a9dc7ff5 chore(deps): bump antd, react-query and swagger-ui-react in /frontend (#7254)
antd 6.7.1 -> 6.7.2, @tanstack/react-query and its devtools 5.108.2 -> 5.108.3, swagger-ui-react 5.35.1 -> 5.36.0: the four updates dependabot proposed in #7213, #7214, #7215 and #7216, taken together so the lockfile changes once. It changes exactly those packages plus @tanstack/query-core and @tanstack/query-devtools.

The oxlint 1.94 bump (#7212) is not part of this: it flags six existing effects and needs its own change.
2026-11-28 10:07:15 +03:30
amirim e071f220e9 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.
2026-11-28 09:53:14 +03:30
Sanaei d0dc4550c2 fix(settings): do not wait 90 s for a restart target on another origin
Since #7205 the page polls its post-restart address before navigating.
When the restart changes the panel's port or turns its TLS on or off, that
address is another origin, and the panel's own CSP (connect-src 'self')
rejects the probe exactly like a refused connection. The poll could never
succeed, so every such restart showed the spinner for the full 90 seconds
although the panel was back after five.

Poll only a same-origin target, which is the reverse-proxy case the wait
was added for. Another origin gets the restart delay alone, as before
#7205. The mixed-content fallback goes with it: its only source was the
http:// target the page used to build behind a TLS proxy.
2026-11-25 17:39:46 +03:30
Sanaei 606d988839 fix(settings): build the post-restart URL from the panel's own listener
After Restart Panel the page guessed its next address from stored
settings: https only when a certificate was configured, and on an IP entry
the stored webPort. Behind a TLS-terminating proxy on a non-default port
that sent the browser to http://host:port and onto the proxy's "plain
HTTP request sent to HTTPS port" page; behind a published port it sent
the browser to the panel's internal port. XUI_PORT and a certificate pair
that does not load were not accounted for either.

The restart call now answers with the listener that took it and the one
the restarted panel opens, both computed where the truth is. The page
follows a scheme or port change only where its own address matches the
serving listener, so a proxy or port mapping keeps the address the
browser reached it on. A panel reached directly by name now also follows
a changed port instead of staying on the dead one.
2026-11-25 17:26:08 +03:30
Sanaei 2450e64258 docs(api): mark keepTraffic optional on the client delete endpoints
Both delete routes read keepTraffic with c.Query and treat a missing
value as "drop the traffic row", but the registry listed it without
optional, so the OpenAPI document and every client generated from it
required the parameter.
2026-11-25 17:16:25 +03:30
Nethmina Yasas e95d17a7db feat(groups): assign host rules from client groups (#7064)
Host rules could only be given to clients one by one, so giving a set of customers their own endpoints meant editing every client. A client group can now carry host rules, chosen when the group is created, from its edit dialog or from a quick-assign action on the Groups page.

A subscription resolves a client's hosts in this order: the client's own host rules, then the host rules of its group, then the inbound's default pool. A group whose bound rules are all disabled or excluded from the requested format renders nothing for that inbound instead of falling back to the default pool. Binding a rule to a group narrows what its members get; other clients still see that rule in the default pool.

Group names are now matched case-insensitively. On upgrade, labels that differ only in case (VIP and vip) are merged into one group, the first by name order.

Adds POST /panel/api/clients/groups/:name/hosts and an optional hostGroupIds on group create and rename.
2026-11-25 15:51:43 +03:30
Aleksey Fedorov 4013219698 fix(settings): wait for the panel to answer before reloading after a restart (#7205)
After Restart Panel, and after a database import, the page slept a fixed 5 seconds and reloaded. When the panel took longer to come back, the reload reached a reverse proxy with nothing listening upstream and the browser showed its 502/504 page.

Keep the 5 second delay, then poll the address the page is about to open every 2 seconds until it answers below 500, and give up after 90 seconds so the page never hangs. A new port or protocol is probed with no-cors; an https page whose target is http would be blocked as mixed content, so it probes its own origin, which is the proxy that answers 502 while the panel is down.

Closes #7190
2026-11-25 15:38:34 +03:30
Бат-Орших 64ca67706f fix(sub): show the MTProto inbound's remark in the sub page Configs tab (#7206)
tg://proxy links carry no #remark on purpose, so the Configs tab of the subscription page had nothing to title an MTProto row with and fell back to "Link N" on the raw, JSON and Clash pages.

While the page data is built, record each MTProto link's remark and send it to the page as linkRemarks, aligned with links; the tab uses it when the link itself has no name. The link, the subscription bodies and the ?format=info JSON are unchanged.

Closes #7198
2026-11-25 15:11:44 +03:30
Mahdi Fallahnejhad ee760de2c8 feat(clients): show a client's usage and change history in the editor (#7031)
The client editor gets a "Usage & change history" button: lifetime traffic
(every closed cycle plus the open one), usage per node since the last reset,
the past cycles, and a log of what changed on the client and from where.

A cycle is archived in one place, whenever a traffic reset or an auto-renewal
zeroes a client's counters. Both tables are bounded per client: the newest 100
cycles are kept and older ones fold into a single "earlier" row, so the
lifetime total does not change; the change log keeps the newest 200 rows and
is taken from the stored record before and after an operation (editor save,
bulk adjust, bulk enable/disable, bot setters, auto-renewal). A rename moves
the history to the new email.

The history belongs to the client. Nothing is archived on delete;
ReapSyncOrphansJob drops the history of emails no client holds, every five
minutes. It lists them outside the traffic writer by walking the email index
(about 10 ms on SQLite for 10k clients with 3M history rows) and enters the
writer only to delete.

Known limit: a client re-created under a deleted client's email before that
job runs keeps the old client's history. Edits through an API token are
logged with the source "panel".
2026-11-25 12:06:45 +03:30
Mr Cortex 05e8f17268 feat(dashboard): choose the time range of the overview charts (#7139)
Every overview chart gets the same range selector: 2m, 5m, 30m, 1h, 6h and 12h. The 2m default is the live trend the page already drew, one point per status poll, so nothing changes until a longer range is picked. A longer range is read from the server's stored rollups through the new GET /panel/api/server/overviewHistory/:bucket, which returns all eight overview series in one response, and is refreshed once per point, at most once a minute.

A metric the host cannot report stays empty in a ranged window instead of drawing zeros, a range change clears the chart rather than showing the old range under the new label, and avg/peak labels keep their number order in RTL locales.
2026-11-25 01:04:29 +03:30