Commit Graph

854 Commits

Author SHA1 Message Date
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
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
PluS98 142a1ab28e feat(inbounds): replace a dead REALITY target with a tested spare (#6967)
The target scanner finds good REALITY targets, but nothing noticed when the one in use stopped working: every client of the inbound then failed until an admin edited it by hand.

A REALITY inbound can now keep spare targets. The panel checks each watched target every 10 minutes with the scanner's own probe, and after three failed checks in a row an inbound with automatic replacement on moves to the first spare that passes both that probe and a real REALITY connection through a throwaway Xray server and client. Only target and serverNames change, saved through UpdateInbound like an admin's edit; nothing changes when no spare passes, and node inbounds are neither checked nor switched from the master. Off until spares are added and automatic replacement is turned on.
2026-11-25 00:50:24 +03:30
Sepehr Radmard ac31455d99 feat(mcp): add a built-in MCP server at /panel/api/mcp (#6956)
AI agents (Claude, Cursor, VS Code) can manage the panel through a stateless streamable-HTTP MCP endpoint. Every tool re-enters the router with the caller's credentials, so authentication, token scopes, CSRF and runtime.Runtime dispatch apply exactly as for the REST API; a restricted token scope is refused, log text is fenced as untrusted data, and each tool call is written to the panel log.

The endpoint hands an API token's whole reach to the agent that holds it, so it is off by default: a panel answers 404 until the MCP server is enabled under Settings -> Security -> API Token (the mcpEnable setting).
2026-11-25 00:32:22 +03:30
Artem K f25cecfb40 feat(wireguard): support multiple devices per client (#7143)
A WireGuard client had one key pair and one tunnel address, so an operator who gave the same config to a phone and a laptop saw the two fight over the peer endpoint.

One client can now own extra devices, up to a per-client limit: each has its own keys and address, shares the client's quota, expiry and switch, and gets its own config, QR code and subscription. Devices become extra peers under the client's email, built by the same core-user map the other paths use, and a device change is applied to the running inbound in place instead of rebuilding it.

Nodes advertise a wg-devices capability; the master refuses a device for a node that would ignore it, before storing it and again when pushing the inbound.
2026-11-24 22:16:16 +03:30
17 3cb5bb7187 feat(wechat): add WeCom and webhook notifications (#7086)
Panel alerts and the scheduled status report could go to Telegram, Discord or email, but not to a WeCom group robot or a generic webhook.

Add a WeChat channel, off by default, with two modes: a WeCom group robot, or a webhook that receives a small signed-free JSON envelope with an optional bearer token. It carries the same events as the other channels (logins, CPU and memory, Xray crash, node and outbound state) and a scheduled text report. Delivery goes through the SSRF-guarded dialer, follows no redirects, and the URL and token are stored and redacted like the other notification secrets.
2026-11-24 21:54:39 +03:30
animesha3 6bc7e81c90 feat(clients): add per-subscription HWID device bans (#7133)
An operator could remove a device from a subscription, but it simply registered again on its next refresh; there was no way to keep one device out.

Add Block and Unblock to the device list. A banned device is refused on every subscription route whether or not the client has a device limit, does not hold a registration slot, and survives trimming and clearing the list. Unblocking needs a free slot, so registered devices never exceed the limit, and a banned device whose configs are replaced is told it is blocked.
2026-11-24 21:26:44 +03:30
animesha3 77719154f6 feat(sub): optionally replace configs rejected by HWID limits (#7106)
When a device is removed and the device limit lowered, its next subscription refresh gets an empty 404, and most apps keep the working nodes they downloaded earlier.

Add a setting, off by default: a refresh the device limit rejects, or one that arrives with no HWID, gets a normal response holding a single dead node in the format that was asked for, so an app that accepts the update replaces its saved nodes. The dead node comes from the same status-node builder the expired and depleted cases use, with no subscriber credentials and no local fallback.
2026-11-24 21:15:23 +03:30
Gleb Kochergin 6f162d03a1 feat(xhttp): configure a separate download endpoint and preserve it in subscriptions (#7187)
An operator who wanted XHTTP downloads to go through another endpoint, such as a relay or a CDN, had no field for it, and downloadSettings typed into the advanced JSON editor was dropped the next time the inbound was saved (#6307).

Add a separate-download switch to the inbound and outbound XHTTP forms, keep the download stream through save, share links, JSON and Clash output, and validate it before it is stored: transport, address, port, REALITY key and short id, and a uTLS fingerprint the core accepts. Saving an inbound re-applies its own session, sequence and padding rules to the download leg, since the listener checks the download request against them.
2026-11-24 21:04:55 +03:30
amirim f9e15a6b9b feat(sub): opt-in per-client rate limit for the subscription server (#6966)
A loop probing subscription ids, or one misbehaving app, could turn the subscription server into a database load generator, and there was nothing to cap it.

Add a setting, off by default, that limits how many subscription fetches one client address may make per minute (60 by default, 1 to 1000); requests over it get 429 with Retry-After. Static assets stay outside the guard. The client address comes from the same resolution the panel's login limiter uses, now shared in internal/util/clientip, so trustedProxyCIDRs decides it in one place for the panel and the subscription server.
2026-11-24 20:51:32 +03:30
Bazil Bazikov e65b5cbd65 feat(nodes): show per-client live speed for clients served by nodes (#7100)
The clients page showed live upload/download speed only for clients the master's own Xray or TUIC served; a client connected through a managed node showed none, although the master already polls that node's counters.

Derive per-client deltas from each node snapshot in the traffic sync job and broadcast them as their own speed source, so they add to local speed instead of overwriting it. A client's diverging per-inbound counter copies fold to the per-field max, the rule the traffic merge applies (#5274).
2026-11-24 20:07:14 +03:30
Hamed e0c01942ec feat(monitoring): allow selecting the network interface for traffic statistics (#6972)
The panel's network totals and speed add up every interface that is not on a fixed list of virtual names. On hosts where a second interface carries the same traffic, such as an SR-IOV function beside eth0, the dashboard and the bot reports counted it twice (#6906).

Add a traffic mode to General settings: legacy keeps today's sum, auto follows the default-route interface, manual names one. An interface that is not available shows as unavailable in the dashboard and in the Telegram and Discord reports instead of 0 B, and a saved manual choice is only re-checked when it changes.
2026-11-24 19:55:55 +03:30
Hamed 447b2d036a feat(clients): append external links in bulk adjustments (#6948)
The Links tab of the client editor was the only way to give a client external share links or subscriptions, and it replaces the whole list, one client at a time (#6816).

Add an "Append external links" tab to Bulk Adjust: the same links are appended to every selected client, existing ones stay, and a link a client already has is skipped. The request is exclusive with the other adjustments. clientRecordsByEmail no longer accumulates WHERE clauses across chunks, which reported clients past the first 400 as not found. Share links are validated with the now-async link parser.
2026-11-24 17:51:49 +03:30
Hamed e409ed7244 feat(nodes): add remote Xray and panel restart actions (#6970)
An operator running a master with sub-nodes could probe or update a node from the Nodes page but had to log in to the node, or SSH into it, to restart Xray or the panel (#6937).

Add Restart Xray and Restart panel to the node actions, behind a confirmation. Xray restarts through the node runtime; the panel restart is a new Remote call that the node accepts with node-admin credentials, the authority that already covers updatePanel. Both are refused for a disabled node.
2026-11-24 16:55:08 +03:30
dkgks 5d76c0a1c6 fix(traffic): preserve client usage on scheduled inbound resets (#7136)
A client attached to several inbounds shares one usage counter. When any one of those inbounds reached its scheduled reset, the job zeroed the client's whole usage, across inbounds and nodes, although the client's own cycle resets on another day (#7135).

Add a per-inbound "Keep client usage" switch, off by default: with it on, the scheduled reset clears only the inbound's own counters. The setting is pushed to nodes and read back from their snapshots. A node that does not advertise the capability is refused when the switch is saved, not later at push time, so an older node never ends up with a config it cannot apply.
2026-11-24 16:32:13 +03:30
Nikan Zeyaei e7bef4813d feat(outbound): import AmneziaWG vpn:// links and subscriptions as outbounds (#7097)
An AmneziaWG outbound could only be set up by copying keys and obfuscation values from a .conf into the form by hand (#7056).

Parse vpn:// links, from another panel or an AmneziaVPN app key, in the Go link parser and in the outbound form, and keep AmneziaWG outbounds that arrive through an outbound subscription running. Inflation is capped per key and per subscription, absent S3/S4 stay 0, a ranged keepalive keeps its lower bound, and the identity includes the client key so two clients of one server do not collide.
2026-11-24 16:07:37 +03:30
ridersaying 2bfcda96f4 feat(frontend): add a follow-system theme mode (#7026)
The theme had three settings, light, dark and ultra dark, so anyone whose desktop switches appearance on a schedule had to change the panel by hand.

Add a System step to the theme button on the sidebar, the login page, the command palette and the subscription page. In that mode the panel follows the OS light/dark setting and repaints when it changes, without a reload. The stored preference moves to theme-mode; the legacy dark-mode boolean is still read on first load and still written, so existing users keep their theme.
2026-11-24 15:44:25 +03:30
Justin 809b7c5501 feat(sub): allow switching the inline QR code format on the subscription page (#7157)
The large QR card on the subscription page always encoded the raw link, so a Clash/Mihomo or JSON user who scanned it got a profile their client could not parse.

Add a SUB / JSON / CLASH switch under the card for the enabled formats. The card starts on the format of the route the page was opened through: the server puts subFormat into the page data, so the /mihomo/ and /clash-legacy/ aliases start on CLASH as well.
2026-11-24 15:06:56 +03:30
Eugene Stsefankou 3a27c1c169 feat(sub): serve Clash/Mihomo YAML to the Rabbit-Hole client (#7063)
RabbitHole runs a Mihomo core and sends a Rabbit-Hole/ User-Agent. The default matcher only knew clash and mihomo, so with automatic format detection on it received the raw link list.

Add rabbit-hole to the default Clash/Mihomo User-Agent regex. A panel with its own regex is unaffected. The client's User-Agent joins the auto-serve test table, and the settings placeholder and subscription docs show the new default.
2026-11-24 14:40:23 +03:30
Nikan Zeyaei b39ac90f1e feat(settings): configurable public IP refresh, IPv6 detection and override (#7189)
Since 3.11.0 the panel asks outside IP-echo services for its public address every five minutes, and on a server with no IPv6 it retried the IPv6 services forever. Operators with static addresses had no way to stop it (#7176).

Add four General settings: the refresh interval (0 keeps the first answer), a switch for IPv6 detection, and a fixed IPv4 and IPv6 address that replace the lookup. The defaults keep today's behaviour. Clearing an override forgets the earlier success, so the next lookup is not timed from before the pin.
2026-11-24 14:29:32 +03:30