Commit Graph

176 Commits

Author SHA1 Message Date
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
pcxzs d15b72a11a feat(tgbot): add Get one, a links header and setup guides to the screen bot (#6952)
A customer whose links ran past one Telegram caption could not turn the page, and one holding several configs was shown a client-card button the bot then ignored.

Customers can now page long screens and only admins see the card. "Get one" lists a config's links and opens the chosen one alone with its own QR code, naming VMess links by their remark; the links pages open with the config's expiry and remaining traffic; and setup guides for five platforms are reached from the customer's home. The new per-client callbacks pass the same ownership check as the existing link screens.
2026-11-24 21:39:42 +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
Mikail Katsiev ccdda6f728 docs(config): add a routing guide for Happ, Clash/Mihomo and Incy (#7183)
Explain, in English and Russian, how the subscription settings feed routing profiles to Happ, Clash/Mihomo and Incy: inline values and remote HTTPS sources, how the panel caches and validates a remote file, the size limits, and what each client receives.

The guide states the limits and checks the code applies: the 8 KiB Happ value after Base64 encoding, remote Clash files validated on their own, Incy URLs handed to the app without being fetched, and the log line each source writes.
2026-11-24 16:10:48 +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
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
Sanaei a2bc42c3a1 chore(deps): update go, frontend and docs dependencies
Go: amneziawg-go, pgx 5.13, telego 1.14, fasthttp 1.80, x/net 0.63,
klauspost/compress and matching indirect modules.
Frontend: vitest group 5.1.1 with addon-vitest overrides, storybook
10.6.8, react-query, antd, i18next, react-router, msw, playwright.
Docs: fumadocs 16.19, next 16.4.6, mermaid 12.3, tailwind 4.3.5,
vitest 5.1.1; release-age waivers pruned, none appended.
Toolchain: restore the pnpm packageManager hash, align the oss-scanner
image with Go 1.27.4.

Held: xray-core untagged pins (gvisor, apernet/quic-go, utls, reality);
modules and oxlint 1.95 / oxfmt 0.80 released under a day ago.
2026-11-23 22:36:08 +03:30
Nikan Zeyaei 21aa662629 docs(nodes): note that updating an mTLS node needs a node-admin token (#6957)
A master that reaches a node over mTLS with no bearer token is treated as
node-sync, which cannot call /server/updatePanel, so "Update panel" on such a
node fails with HTTP 403. That is intended, but the multi-node guide said the
API token is "not needed in mTLS mode" (#6953).

The guide (en/fa/ru/zh) and the node form's mTLS hint (all 14 locales) now say
that updating the node from the master still needs a token with the
node-admin scope. No logic changes.

The CI workflow's path filter does not cover internal/web/translation or docs,
so only Docs CI ran on this head; the locale-dependent tests were run locally.
2026-11-13 16:54:30 +01:00
Sanaei 35921b95a2 fix(xray): show the Google Drive defaults in the XDRIVE tuning fields
xray-core 26.11.9 (#7340, #7352) gives the Google Drive backend its own
defaults for the knobs a config leaves empty: flushIntervalMs 10,
maxPollIntervalMs 200 and concurrency 64. The other services keep 20, 500
and 8.

The tuning placeholders stand for "what the core uses when this is empty",
so they now follow the selected service, and the transports page in all
four doc languages names the Google Drive values.
2026-11-12 19:26:57 +01:00
Aleksey Fedorov e4935be861 fix(api): preserve omitted client fields in partial updates (#7042)
Keep omitted client fields and per-inbound flows unchanged while honoring explicit clears. Support the query aliases used to recover legacy dot-name clients and regenerate the API reference. Add an HTTP regression covering partial updates through those aliases.
2026-11-05 18:06:16 +01:00
Benjamin Mitchell cd176faf4e fix(clients): reject dot names and recover legacy clients (#7062)
Reject reserved dot-segment client names and recover legacy records through query aliases. Preserve token scopes and path identity precedence, and update the generated API reference.
2026-11-05 18:02:39 +01:00
25f2002654 83ea59fb69 fix(tgbot): restore the admin's client link and QR buttons (#6986)
The v3.11.0 bot rebuild left the admin's client card without the subscription link, individual links and QR code, so an admin could not hand a config to a client who cannot reach Telegram yet. The card now carries Links and QR code buttons that open the existing screens. Closes #6984.
2026-11-03 15:52:35 +01:00
Hamed 19f2f21d81 fix(inbounds): reject incompatible VLESS fallbacks and prevent Xray crashes (#7003)
Xray refuses a VLESS inbound with server decryption whenever fallbacks is non-nil, even an empty list, so an API or imported inbound with decryption and fallbacks: [] took every inbound down. Empty fallback arrays are now normalized away on add, update, config build and node push; non-empty ones are refused with decryption, enabling decryption over stored fallback rules is refused, and a legacy conflicting row holds back the running core instead of stopping it. The form, API docs and locales follow. Closes #7001.
2026-11-03 15:52:30 +01:00
MHSanaei cbf596d889 chore(deps): bump docs and frontend dependencies
Bump docs deps (fumadocs-core/ui 16.17.9, fumadocs-openapi 12.5.7, lucide-react 1.66, oxfmt 0.75, oxlint 1.90, postcss, @types/node) and pnpm to 12.16.1. Drop the now-unneeded minimumReleaseAge excludes for the old fumadocs versions.

Frontend: override minimatch to ^11.0.3 for swagger-ui-react and glob to ^14.0.3 for the docgen vite plugin, which updates the lockfile.

Also fix the AmneziaWG kernel Alert to use the Ant Design 6 `title` prop instead of the deprecated `message`.
2026-11-01 15:58:11 +01:00
MHSanaei 62d27d54d5 feat(xray): support the XDRIVE s3 storage service
xray-core 26.10.31 (#7231) added an "s3" XDRIVE service that carries the
stream through S3-compatible storage: secrets are AccessKeyID,
SecretAccessKey and an optional SessionToken, an "s3" object names the
endpoint, region, bucket and pathStyle, and remoteFolder becomes the
object prefix.

The schema and the shared XDRIVE form offer the service with a field for
every S3 key, so an outbound or inbound keeps its storage on save. The
save path refused "s3" as an unknown service; it now runs the vendored
loader, whose ValidateS3Config would otherwise only fire when the
listener starts and stop every inbound. A node refuses a pushed S3
storage like a pushed template one, since its endpoint is any URL the
node would dial, including its own panel. Labels in all 14 locales;
docs updated in en/fa/ru/zh.
2026-11-01 14:56:26 +01:00
MHSanaei a9191cb468 fix(amneziawg): let an emptied forwardedPorts withdraw a client's forwards
UpdateInboundClient carried the stored forwardedPorts forward whenever
the incoming value was empty, and Client.ForwardedPorts was a plain
omitempty string, so clearing the field in the client editor, as its
hint says to, reported success while the settings kept the old ports
and the host kept relaying them to the client's device.

The field is now a pointer, as KeepAlive is: nil (not sent) keeps the
stored spec and "" withdraws it. The client record follows the live
spec on every update, and a one-time seeder fills records that still
hold their creation value from the inbound settings, so the editor no
longer posts an empty field that would drop forwards added later.
2026-11-01 08:55:38 +01:00
MHSanaei 7f64a67ba5 fix(clients): re-enable only quota-disabled clients on a traffic reset
Every traffic reset re-enabled its clients unconditionally, in the
client record and in the traffic row a master treats as the client's
state. A master forwards an inbound's scheduled reset and "reset all"
to its nodes through the per-client reset calls, so a client disabled
by hand on a node inbound came back on at the next scheduled reset.

Each reset now decides, before it zeroes the counters, which of its
clients the quota switched off, counting cross-panel usage, and
re-enables only those; a client disabled below its quota keeps its
record and traffic row off. The reset API docs say so.
2026-11-01 08:31:27 +01:00
MHSanaei daf5b16eda fix(wireguard): hold /0 allowedIPs to the overlap guard
The tunnel overlap guard treated every /0 allowedIPs entry as claiming
no address, while the entry was stored with its host bits and the
consumers read them back: the AmneziaWG port forwarder resolves a peer's
target from them and the device routes the /0 by longest prefix. An
entry such as 10.8.1.2/0 therefore passed next to another client's
10.8.1.2/32, and forwarded ports reached that client's device.

A written entry now counts with its whole range, so a /0 collides with
every held address of its family. On the stored side only a literal
0.0.0.0/0 or ::/0 default route keeps nobody out, and a /0 with host
bits claims that host. Editing a legacy peer that echoes its stored
default route still works.
2026-11-01 00:06:09 +01:00
Hamed 8eb58a4a14 perf(ip-sync): avoid redundant client IP reads and writes (#6930)
The access-log scanner and the cross-node merge stored the same IP list in
opposite orders, so neither saw a row as unchanged, and the merge re-read
every preloaded row and re-upserted every attribution row each sync cycle.
All writers now share one canonical encoder (timestamp, then IP ascending),
the first CAS is seeded from the preload, and identical attribution rows are
skipped. A create race between the scanner and node sync now merges into the
winning row instead of dropping the loser's IPs, which on PostgreSQL also
aborted the scanner's whole scan transaction.

Closes #6927
2026-10-25 14:13:18 +01:00
Hamed 952c1c751a perf(inbounds): batch client identities for stats enrichment (#6929)
backfillClientStats loaded every column of every client once per inbound,
although enrichment only reads UUID, email and subscription ID. Each inbound
list read (panel list, the master's node traffic poll, Xray config builds,
bots) repeated that wide join per inbound. Identities now come from one narrow
clients/client_inbounds projection per 400 inbounds, honouring the supplied
transaction; stats output, sibling-traffic append order and the #6436
clients-table source of truth are unchanged.

Closes #6926
2026-10-25 14:01:46 +01:00
YoungReckless4 56ac8d0fc7 feat(amneziawg): add opt-in Linux kernel datapath (#6877)
* feat(amneziawg): add opt-in Linux kernel datapath

Add the kernel backend as an explicit per-inbound option while keeping the embedded backend as the default. Include host preflight, UI/API support, the bundled installer CLI, lifecycle and accounting integration, regression tests, and upstream-facing documentation. Kernel mode is NAT-only and rejects unsupported routing, IPv6, forwarding, and pinned-listen configurations. Local saves check the local host; remote nodes check their own host during apply.

Preserve adopted interface accounting across panel restarts, retain manager state after failed teardown so the job can retry, prevent embedded startup while a kernel interface remains live, and prune collector state for removed peers. Tested the restart accounting path on Debian 13 with XanMod 7.1.11 on x86_64; Docker and cross-kernel coverage are not claimed.

* fix(amneziawg): align readiness and endpoint reporting

Expire endpoint sightings using the latest handshake and sweep stale addresses for the polled interface. Keep the readiness API schema, generated client types, and ready-host empty blocker list consistent; watch the nested form field and defer local readiness checks for remote targets. Document safe rollback before using a build without kernel support.

Regression evidence: the idle endpoint test failed before the collector change because the old address remained visible after 31 minutes; endpoint tests pass after the fix. The form component suite passes 3 tests; restoring the invalid array watch made its off-mode severity test fail, while the corrected dot-path watch passes. Targeted Go regressions across amneziawgkern, job, and service pass.

* style(amneziawg): format readiness test

* test: reproduce kernel AWG client validation gaps

* test(service): cover kernel AWG shared client fanout

* fix(amneziawg): validate kernel client fanout and config values

* test(amneziawgkern): cover owned interface lifecycle recovery

* fix(amneziawgkern): recover owned interfaces on restart

* test(amneziawgkern): retain visibility after recovered cleanup failure

* fix(amneziawgkern): report recovered interfaces while cleanup retries

* style(amneziawgkern): satisfy static analysis

* test(amneziawgkern): cover long rendered peer comments

* fix(amneziawgkern): accept long generated config comments

* test(amneziawgkern): refuse foreign occupied interfaces

Capture the current Ensure ordering failure with real temporary config paths and manager side-effect boundaries.

* test(amneziawgkern): cover stale interface collisions

Extend the Ensure regression across absent links, mismatched live interfaces, cached manager state, and Remove teardown.

* fix(amneziawgkern): verify interface ownership before mutation

Refuse to replace or tear down links unless the canonical config is a valid panel-owned file and its key matches the live interface. Preserve normal adoption and key rotation, and document migration of legacy unmarked configs.

Validation: go test ./internal/amneziawgkern -count=1; go test -race ./internal/amneziawgkern -count=1; golangci-lint run ./internal/amneziawgkern/...; git diff --check.

* build: update Go toolchain to 1.27.3

* test(amneziawg): reproduce unsafe key rotation recovery

Keep the previous owned config authoritative until teardown succeeds, and require fresh managers to rebuild structural key changes. These regressions expose the stuck live-key/disk-key mismatch after teardown failure.

* fix(amneziawg): recover interrupted key rotations

Keep the old owned config on disk until a structural rebuild has confirmed the previous interface is down. Fresh managers only adopt when the live config and desired structural identity match, so retries and removals retain the key needed to prove ownership.

* fix(scanner): align Go image with module version

* fix(docs): pin pnpm release with bootstrap fix

pnpm 12.9.1 restores a Node launcher before its postinstall replaces the target with ELF; pnpm 11 then runs that binary as JavaScript. Pin 12.10.0, which includes the shim fix, so the docs CI bootstrap can switch versions safely.

* fix(xray): build core from pinned module

The configured Xray release asset tag is unpublished, and the latest published binary lacks GetUsersStats used by the panel. Build the packaged core from the exact Xray module version already selected in go.mod for Docker and release targets.

* fix(tests): stabilize local network fixtures

Keep the TUIC stream fragmentation check on a working UDP loopback path,
allocate the AmneziaWG fixture ports dynamically, and wait for a real
Xray stats response before starting API mutation assertions. Recreate
failed readiness channels so an early connection cannot stall the probe.

Verified host and offline parallel Go suites, repeated occupied-port and
UDP tests, race/shuffle runs, and golangci-lint. Production behavior and
dependency versions are unchanged.

* fix(i18n): add the kernel-mode AmneziaWG keys to sk-SK

main gained the sk-SK locale after this branch added its kernel-mode keys
to the other 13, so i18n-dead-keys.test.ts failed on the merged tree.

* refactor(amneziawgkern): apply kernel interfaces with direct commands, no awg-quick

awg-quick evaluates PostUp/PostDown through a root shell, so every value the
panel rendered into its config was one validation slip away from root command
execution. The interface is now built with direct ip/awg/nft execs from a
setconf-only file: link add, awg setconf, address, mtu, an atomically replaced
nftables table per inbound, and the IPv4 forwarding sysctl written directly.

- Panel-owned names and paths: xui-awg<id> interfaces, xui_awg<id> NAT tables
  and configs under the panel's data dir, so nothing collides with an
  operator's own awg0/awg1 awg-quick tunnels in /etc/amnezia/amneziawg.
- FORWARD accepts (comment 3x-ui:xui-awg<id>) when iptables is present: Docker
  and ufw set the FORWARD policy to DROP, which silently black-holed the tunnel.
- A full panel stop records the final counters and tears the interfaces down,
  like the embedded datapath; a stopped panel enforces no quota or expiry.
  Crash survivors are still adopted without a rebuild.
- The job reads counters before reconciling, and from every managed interface,
  so a client disabled for quota, or a removed inbound, is charged for its last
  interval instead of losing it with the dropped peer.
- An unchanged reconcile tick forks no process (it probed the live key with
  `awg show` every 10s); readiness no longer loads the module from a GET.

Verified on the real module (WSL2 6.6 kernel, v3.1.20260906): create, peer and
egress changes in place, SIGKILL adoption with the same ifindex, SIGTERM
teardown leaving no link, table, FORWARD rule or config behind.

* fix(amneziawg): gate kernel host readiness only when a save starts the datapath

Every save of a kernel-mode inbound re-ran the host preflight, so a host that
lost its module (a kernel upgrade without a DKMS rebuild) refused even
disabling the inbound or switching it back to embedded mode. Host blockers now
apply only when the save starts the kernel datapath: a new inbound, a switch
from embedded, or enabling a disabled one. Feature blockers (IPv6, forwarded
ports, pinned listen) still apply to every save.

* feat(nodes): refuse kernel-mode AmneziaWG pushes to nodes that predate it

A node built before kernel mode drops the unknown kernelMode field and serves
the inbound on the embedded datapath while the master's form shows kernel
mode on. Nodes now advertise awg-kernel in X-3x-Node-Caps, and Remote refuses
to push a kernel-mode inbound to a node that has not advertised it, learning
the caps with an inbound list first when this Remote has not heard from it.

* fix(amneziawg): pin the kernel module installer to verified commits

The installer ran as root and built whatever upstream tag sorted newest at
install time. It now clones fixed tags (module v3.1.20260906, tools
v3.1.20260812) and refuses unless each resolves to its recorded commit. The
udp_tunnel perl patch is gone: those releases carry the kernel 7.1.5 compat
upstream, so the patch never matched.

* fix(i18n): translate the kernel-mode AmneziaWG strings

All thirteen non-English locales carried the English text verbatim.

* fix(amneziawg): skip the kernel traffic flush when no kernel interface runs

Shutdown listed the desired AmneziaWG inbounds from the database even on a
panel with no kernel interface, an unneeded query on every stop. A server
stopped before its database was opened panicked on it, which turned
TestServerStopWhenXrayNotRunningSucceeds red whenever it ran first.

---------

Co-authored-by: MHSanaei <ho3ein.sanaei@gmail.com>
2026-10-25 13:24:50 +01:00
Hamed 64a7697f56 perf(traffic): skip unchanged global writes between heartbeats (#6931)
* perf(traffic): skip unchanged global writes between heartbeats

Persist directional usage changes immediately, including lower resets, while
refreshing identical global totals only at an inclusive one-hour heartbeat.
Use the GORM clock consistently for the existing 24-hour freshness window and
preserve local-only snapshots, quota enforcement, and downstream forwarding.

Fixes #6928

* docs(traffic): describe persisted global heartbeat timestamps

Replace the stale every-push model comment with the change-or-hourly-heartbeat
rule. Keep the local-counter separation, delta accounting, MAX fold and reset
semantics explicit without treating UpdatedAt as a last-push timestamp.

Address the nonblocking review feedback on PR #6931 without rewriting
published history.

Refs #6928
2026-10-25 08:44:05 +01:00
Pejman Yousefi 8da3b3c344 feat(hosts): give a host a pool of SNIs, random per config or shared (#6923)
Rotating SNIs meant one host entry per domain. A host now takes a pool of
SNIs: with more than one, every generated config gets a random entry,
or, with the shared switch on, the whole host group uses one pick per
subscription fetch. Raw, JSON and Clash output, the panel's link preview
and node adoption all carry the pool.

sni stays the pool's first entry, so a rolled-back binary and API callers
that only know the single field keep working; an sni outside the pool
becomes its primary. A host with one SNI renders exactly as before.
2026-10-24 21:05:42 +02:00
VAIO73 746bdbe9f4 fix(monitoring): read LXC CPU, swap and uptime from the container (#6920)
In an LXC container with LXCFS the Overview showed the container's RAM
beside the host's swap, the host's CPU topology and a CPU percentage from
the host's view. Swap and uptime now come from LXCFS's virtualised files
and CPU from the container's cgroup v2 counter, normalised by the visible
vCPUs and any quota; container CPU and swap history is kept apart from
the earlier host samples.

A value the reader cannot measure (the first CPU sample, or a layout it
cannot verify such as cgroup v1) is reported as unavailable instead of 0:
the dashboard, the node list, node CPU history and the Telegram and
Discord uptime show a dash, and nodes keep the flags in a new
unavailable_metrics column.
2026-10-24 20:24:34 +02:00
DIMFLIX 15fee2a035 feat(tgbot): rebuild the Telegram bot around editable screens and inline lists (#6760)
The bot answered every action with a new message, so a chat filled with stale
menus whose buttons still acted, and long client or inbound lists were paged
through dozens of buttons. Each chat now has one live screen that is edited in
place: the menu is grouped into Server, Clients, Traffic and Maintenance, lists
open through inline search, the add-client flow starts from a draft card, QR
codes arrive as one labelled sheet, and repeated notices collapse into one with
a counter. A client's /start and /usage show only that client's own links and
usage, groups are refused, and the settings page warns when the bot's inline
mode is off. Admin topics, the indexed Telegram lookup and every locale,
Slovak included, carry over.
2026-10-24 12:39:56 +02:00
Nethmina Yasas bc1b750e00 feat(clients): bind host rules to individual clients in subscriptions (#6620)
Host rules applied per inbound only, so every client of an inbound got the same
subscription endpoints (#6618). A client can now be bound to one or more host
rules, and its raw, JSON and Clash subscriptions render only those hosts, in
either subscription order; an unbound client is unchanged. A binding whose hosts
are deleted, disabled or excluded from the format fails closed: the client gets
no links there but stays in traffic accounting. Host edits keep row ids, so
bindings survive them; nil leaves a stored binding alone and an empty list
clears it.
2026-10-24 12:33:02 +02:00
VAIO73 052b11d2bc feat(i18n): add the Slovak (sk-SK) panel locale (#6889)
Adds a complete Slovak translation of every panel and bot string, registers
sk-SK in the language picker (a browser set to sk now lands on it instead of
English) and loads Ant Design's Slovak locale. The locale count in the READMEs,
docs and contributor guides moves from 13 to 14.
2026-10-24 07:35:28 +02:00
Hamed 136c1c4d50 feat(hosts): add drag-and-drop and global subscription ordering (#6895)
Hosts already had one saved order on the Hosts page, but subscriptions honoured
it only inside each inbound, so a host of a later inbound could never come before
one of an earlier inbound (#6894). A new opt-in setting makes raw/base64,
Clash/Mihomo and JSON subscriptions follow the Hosts page order across inbounds;
the default keeps today's inbound-first output unchanged. The Hosts table gains
drag-and-drop reordering next to the Up/Down buttons, on a pointer-reorder hook
the Routing Rules table now shares.
2026-10-24 07:27:47 +02:00
YoungReckless4 35e09191de feat(amneziawg): support persistent keepalive ranges (#6881)
AmneziaWG clients accept a randomised PersistentKeepalive range such as 15-25,
which makes keepalive timing harder to fingerprint; the panel only stored a
single number. A client's keepalive may now be a range, validated the way
AmneziaWG parses it. The downloadable .conf and vpn:// profile carry the range,
Clash/Mihomo output gets its lower bound, and plain WireGuard stays scalar-only.
The range lives in an additive wg_keep_alive_range column, so the integer
column and an older panel binary keep working after a rollback.
2026-10-24 06:36:49 +02:00
Egor 207c705300 fix(tuic): preserve client identity for Xray user routing (#6875)
TUIC traffic reached Xray through a loopback SOCKS relay that took no login,
so Xray never learned which client a connection belonged to and user routing
rules never matched TUIC (#6874). The relay now carries one account per client
email, so per-user rules match on TCP and both UDP modes; admission stays with
the native TUIC server.

Adding, removing or renaming a TUIC client swaps only that inbound's relay
instead of restarting Xray: new sessions wait behind a bounded gate while live
streams and UDP associations continue, accounts are verified after the swap and
rolled back on failure, one failing relay no longer strands the others or blocks
unrelated live changes, and emails over SOCKS5's 255-byte limit are excluded
with a warning.
2026-10-24 06:20:39 +02:00
clearlove13 49c0600f35 fix(iplimit): keep recording client IPs with fail2ban disabled (#6830)
With XUI_ENABLE_FAIL2BAN off, the IP job returned early, so the panel stopped
recording and showing client IPs altogether, although only enforcement needs
fail2ban. Only enforcement is now gated on it: collection-only runs go through
the merge, 30-minute window and compare-and-swap path, so the IP list stays
current. Tied timestamps sort by IP, so an unchanged client no longer rewrites
its row every scan and the ban pick among tied IPs is stable. Closes #6722.
2026-10-24 06:09:01 +02:00
Aleksey 41bafb3fd5 feat(sub): make the host "Mihomo X25519" switch drop ML-KEM (#6803)
The per-host Mihomo X25519 switch has been stored since managed hosts landed,
but no renderer read it, while every REALITY proxy was forced to
support-x25519mlkem768: true. On some networks DPI drops the second segment of
an ML-KEM ClientHello and blackholes the server for that client. A host with the
switch on now gets support-x25519mlkem768: false and no ML-KEM hint in its vless
link; switches saved while they had no effect are cleared once, so upgrading
does not silently change existing subscriptions.

A REALITY host's fingerprint now reaches the Clash and JSON outputs, and every
host endpoint gets its own deep copy of the stream, so one host's blank SNI,
fingerprint, Host header or path no longer inherits another host's value.
2026-10-24 06:01:48 +02:00
Tuyến Trần a403faee23 feat(tgbot): route admin notifications to a forum topic (#6879)
Admins who run the bot in a forum supergroup got every notification in the
General topic. An admin chat ID may now carry a topic, chatId:topicId, and the
bot's admin messages and reports go to that topic. Repeated chats collapse into
one entry and a second, different topic for the same chat is rejected, in the
panel and in the docs setup helper alike. The chat ID hint in every locale and
the English, Persian, Russian and Chinese guides describe the form.
2026-10-24 05:55:55 +02:00
Pejman Yousefi 40cea0c2fe feat(sub): generate random IPs from CIDR host addresses (#6784)
Operators who front a server with an IP range (a CDN or anycast prefix) had to
list each address as its own host. A host address may now be a CIDR, and every
subscription fetch expands it into up to randomCount (1–100, default 1) unique
random host IPs from the range, IPv4 and IPv6 alike, skipping the network and
broadcast addresses. The panel's own previews, QR codes and tunnel config
exports (WireGuard, AmneziaWG, TUIC, MTProto) expand it the same way, and the
externalProxy importer writes the model's default count so the re-sync still
recognises untouched imported hosts.
2026-10-24 05:13:44 +02:00
CHANGAO MA 0516a1f87c feat(api): add client lookup by subscription ID (#6908)
Integrations could only find a client by subscription ID through a substring
search over the paged client list followed by a second lookup by email.
GET /panel/api/clients/get/subId/:subId now returns the full client records
(settings, attached inbounds, external links, traffic, tunnel addresses) for an
exact subId match, as a list because older rows may share an ID. It sits behind
the same admin login or admin-token check as the email lookup.
2026-10-24 04:54:14 +02:00
Grigoriy 2f62dadd25 feat(notifications): add a failed-check threshold for node.down alerts (#6768)
One lost heartbeat on a lossy link flipped a node offline and sent node.down,
and the next probe sent node.up, so a flaky node flooded Telegram, email and
Discord with alert pairs.

A new nodeDownThreshold setting (default 1, today's behaviour) works like
outboundDownThreshold: node.down fires once the failed-check streak reaches it,
once per outage, and node.up only after a node.down was sent. The announcement
is persisted in nodes.down_notified, so a restart inside the threshold window
neither drops the outage's node.down nor re-announces nodes already reported
offline; nodes offline at upgrade are seeded as announced.
2026-10-24 04:26:13 +02:00