Commit Graph
209 Commits
  • fix(online): scope online status per node instead of a global union
    The inbounds page and Nodes page checked each client's email against a
    single deduped union of every node's online clients, so a client connected
    to one node showed as online on every inbound across every node. The local
    online set was also derived from the email-keyed client_traffics.last_online
    column, which remote-node syncs bump too, leaking remote-only clients onto
    local inbounds.
    
    Track online clients per node: the local panel's own xray clients under key
    0 (derived from live traffic-poll deltas via RefreshLocalOnline, kept in
    memory and independent of the shared last_online column) and each remote
    node under its id. Add GetOnlineClientsByNode plus a /clients/onlinesByNode
    endpoint and onlineByNode WS field; node.go and the inbounds rollup now scope
    online by node. The flat GetOnlineClients union is kept for client-centric and
    total-count views (Clients page, dashboard, telegram).
    
    Closes #4809
  • fix(tls): correct pinned cert SHA-256 hint to hex, not base64
    xray-core hex-decodes pinnedPeerCertSha256 and the panel forwards the value as-is into share links and the JSON subscription, so clients hex-decode it too. The tooltip/placeholder wrongly said base64 (copied from the retired pinnedPeerCertificateChainSha256 field), and the "generate random hash" button emitted base64 via btoa, producing an unusable pin. Tooltip/placeholder now say hex across all locales and the generator emits hex.
    
    Closes #4793
  • feat(hysteria2): emit UDP port hopping in subscriptions and share links
    UDP Hop (finalmask.quicParams.udpHop.ports) was configurable but never surfaced in generated configs, so clients kept using the single listening port (#4789).
    
    Share links (frontend genHysteriaLink + sub genHysteriaLink) now keep a numeric port in the authority and carry the hop range as the v2rayN-compatible mport query param, so v2rayN and other System.Uri-based importers can parse the link. Clash output sets mihomos native ports field.
    
    Closes #4789
  • fix(settings): allow pagination size of 0 to disable pagination
    The pageSize setting described '(0 = disable)' and the inbounds table already treated 0 as show-all, but every validation layer enforced a minimum of 1. Relax the bound to gte=0 in the AllSetting struct tag (source of truth for the generated frontend schemas), regenerate zod, and lower the min on the hand-written schema and the InputNumber control.
  • feat(clients): show filtered count in clients list
    Surface a "Showing X of Y" counter in the clients filter bar that appears whenever a search term or any filter is active, using the server-provided filtered and total counts. Added the showingCount string across all 13 locales.
    
    Closes #4808
  • feat(clients,routing): label inbounds by remark with tag fallback
    Inbound pickers and chips across the Users area, the inbounds attach-clients modals, and the routing rule inbound-tags selector showed the auto-generated tag (in-443-tcp). Show the inbound remark when set, falling back to the tag.
    
    Only display labels change; option values keep using the inbound id (or tag for routing rules, which match inbounds by tag), so filtering, attaching, and saved rules are unaffected. Routing reads remarks via a shared useInboundOptions hook that reuses the existing options query cache.
  • fix(node): fix "invalid input" on save and gate save on connectivity
    The pinnedCertSha256 form field unmounts for non-pin TLS modes, so antd dropped it from the onFinish values and Zod rejected the missing string (the user-facing "invalid input"). Make it optional with a default so saving works in every TLS mode.
    
    Saving now runs the connection test first and only persists when the probe is online; the add/update endpoints enforce the same probe so an unreachable node cannot be stored via the API either.
    
    Selecting the http scheme forces TLS verify mode to skip and disables the control, normalized on open for existing http nodes.
    
    http-vs-https probe failures report a clear "set the node scheme to http" message across the test button, save, and the backend gate.
    
    Closes #4794
  • fix(clients): keep Add Client modal in viewport with internal scroll
    Open the modal near the top (top: 20) and let the body scroll internally (maxHeight + overflowY auto, overflowX hidden) so the tall vertical-layout form no longer leaves a large gap above and runs off the bottom.
  • fix(xray): clear dirty state after saving unchanged config
    Editing an outbound and re-saving it without real changes left the top Save button stuck enabled, and clicking it never cleared it. The form re-normalizes values into deeply-equal config, so react-query keeps the same configQuery.data reference on refetch and the seed effect that resets the dirty baseline never re-runs. Advance the baseline to the persisted value in saveMut.onSuccess instead of relying solely on the refetch.
  • feat(outbounds): pick dialerProxy from other outbound tags for proxy chaining
    Turn the outbound sockopt dialerProxy free-text input into a searchable Select populated with the other outbound tags, so users can build a proxy chain (route one outbound through another) without typing tags by hand. The list excludes the current outbound, so self-reference cycles cannot be selected. A tooltip and placeholder explain the chaining concept. Adds dialerProxyPlaceholder and dialerProxyHint to all 13 locales.
    
    Closes #4446
  • chore(generated): sync node types/zod with TLS verification fields (#4757)
    Regenerated frontend types from the model.Node change in the previous commit (adds tlsVerifyMode and pinnedCertSha256).
  • feat(nodes): add per-node TLS verification mode for self-signed certs (#4757)
    Adds a per-node TLS verification mode to the Add/Edit Node dialog so the panel can reach nodes that serve HTTPS with a self-signed certificate:
    
    - verify (default): normal CA validation.
    - skip: InsecureSkipVerify, with a clear UI warning that it drops MITM protection.
    - pin: validates the leaf certificate's SHA-256 (base64 or hex) via VerifyConnection while bypassing the default chain/name check — keeps MITM protection for self-signed certs, the secure alternative to skip.
    
    New Node model fields tlsVerifyMode + pinnedCertSha256 (gorm auto-migrated). Probe() selects the HTTP client per node via nodeHTTPClientFor, keeping the SSRF-guarded dialer. A new POST /panel/api/nodes/certFingerprint endpoint (FetchCertFingerprint) lets the UI fetch and pin the node's current certificate in one click. Endpoint documented in api-docs/openapi; i18n added across all locales. Verified end-to-end in Docker (verify rejects, skip bypasses, fetch matches, pin accepts correct / rejects wrong).
  • feat(inbounds): support Unix domain socket path in Listen field (#4429)
    UDS listen already worked for proxying (the listen string is passed to xray verbatim and port 0 is accepted), and the Go sub/link layer already ignores the bind listen. The only gap was the frontend resolveAddr, which would put a socket-path listen into share/sub links (e.g. vless://uuid@/run/xray/x.sock:0). resolveAddr now treats a path-style listen (starting with / or @) as having no client-reachable address and falls back to hostOverride/hostname. Adds a test and a Listen-field help hint across all locales.
  • fix(fallbacks): allow free-form dest entries for external servers (#4748)
    Since v3.1.0 every fallback row had to reference a panel inbound via childId, so rows with only a free-form dest (e.g. 8080 or 127.0.0.1:8080 to an external Nginx) were silently dropped at three layers: the frontend save filter, the backend SetByMaster guard, and BuildFallbacksJSON. A row is now valid when it has a child OR an explicit dest; self-references normalize to childId 0, and BuildFallbacksJSON prefers an explicit dest (also fixing rows whose child was deleted). UI gains allowClear on the child picker; help text updated across all locales. Verified end-to-end in Docker: a free-form dest fallback now persists and is injected into the live xray config. Refs #4554, #4639.
  • fix(raw): complete the HTTP header section for inbound and outbound
    Align both raw (TCP) transport forms with the Xray docs: request {version, method, path, headers} + response {version, status, reason, headers}. The outbound form was missing the request.path input, so panel-created outbounds were stuck on GET / and could not match a custom inbound path; add it with the same comma-separated array handling as the inbound. Also drop a stale inbound comment that claimed xray-core ignores the inbound request object, which contradicts both the code and the docs (request and response must match on both sides).
  • fix(inbounds): allow port 0 for UDS inbounds (#4783)
    Unix Domain Socket inbounds (listen path starting with /) use port 0, which xray-core ignores. Validation was hard-locked to a minimum of 1 in three places: the shared Zod PortSchema, the AntD InputNumber, and the Go Inbound model tag. Adds an InboundPortSchema (min 0) for the inbound form/API schemas, makes the port InputNumber min UDS-aware, and relaxes the Inbound model validate tag to gte=0. PortSchema and the Node model stay min 1.
  • fix(warp): persist client_id so WARP outbound gets reserved bytes (#4781)
    RegWarp now stores config.client_id from the Cloudflare registration, and WarpModal sources the reserved bytes from the live config response (falling back to stored creds). Previously reservedFor read an always-missing client_id, producing an empty reserved array.
  • fix(hysteria): use pinSHA256 for pinned cert and emit ech in share links
    Hysteria links now carry the pinned peer cert under the hysteria2-standard pinSHA256 key instead of pcs (frontend genHysteriaLink + outbound importer round-trip), and the Go subscription generator emits ech from echConfigList. Also drops the dead allowInsecure guard in genHysteriaLink, which read a field that does not exist on TlsClientSettings.
  • fix(outbound): add None option to uTLS fingerprint in TLS form (#4760)
    Hysteria doesn't use uTLS, but the outbound TLS form's uTLS dropdown only listed concrete fingerprints (chrome, firefox, ...) with no explicit empty entry. Add a None option, matching the inbound TLS form, so the fingerprint can be left empty.
  • fix(outbound): carry ALPN, fingerprint and UDP mask when importing a Hysteria2 link (#4760)
    parseHysteria2Link hardcoded alpn to h3 and never read fp, ech, or the fm (finalmask) param, so importing a Hysteria2 client URL as an outbound dropped the configured ALPN, fingerprint, and salamander UDP mask. Parse alpn (falling back to h3 only when absent), fp, ech, and the pcs pinned-cert key, and restore the UDP mask via applyFinalMaskParam.
  • fix(sockopt): rename interfaceName to interface so xray honors it
    xray-core reads the bind-interface sockopt as json:"interface", but the schema and forms used interfaceName. Go's JSON unmarshal is case-insensitive, yet interfacename != interface, so the value never reached xray and interface binding silently did nothing. Rename the field across the schema, the inbound/outbound forms, and the golden fixture to match xray-core and the official docs.
  • fix(settings): enforce trafficDiff max of 100 in UI (#4769)
    The trafficDiff InputNumber and form schema lacked an upper bound, so values above 100 were accepted in the UI but rejected by the backend (gte=0,lte=100), failing the entire settings save with a misleading 'request body failed validation' error. Add max=100 to the input and .max(100) to the schema.
  • fix(outbound): fill encryption and pqv when importing VLESS link
    The link-to-JSON importer dropped two VLESS Reality fields:
    
    - pqv (post-quantum ML-DSA-65 verify key) was never parsed; map it back
      to realitySettings.mldsa65Verify, matching the inbound link generator.
    - encryption was force-reset to 'none' in the form adapter regardless of
      the parsed value, discarding post-quantum encryption strings.
    
    Add regression tests for both paths.
  • feat(outbound): sync DNS outbound config with Xray core changes
    Rename the DNS rule wire key qtype to qType (reading the legacy qtype on parse for back-compat), add the new rCode response-code field for the return action (omitted when zero), and rename the reject action to return. Align the DNS rule action set across the form dropdown, schema, and adapter to the core's valid values (direct/drop/return/hijack), dropping the never-valid rejectIPv4/rejectIPv6 entries.
  • feat(finalmask): sync transport with upstream Xray core changes
    Consolidate the eight legacy mKCP/header UDP mask types into a single mkcp-legacy type ({header, value}), simplify xicmp to {dgram, ips}, and add the new realm UDP mask type, matching the updated Xray-core wire format. Update the FinalMask schema enum, the transport form, the mKCP seeding default, and the backend KCP share-link translation. Refresh golden fixtures/snapshots and add backend coverage for the mapping.
  • fix(inbounds): refresh routing inbound-tag list after inbound changes
    The routing-rule tag picker reads inboundTags from the xray config query
    (['xray','config']), but refresh() only invalidated the inbounds/clients
    buckets. So after adding, editing or deleting an inbound the tag list stayed
    stale until a hard refresh wiped the react-query cache. Invalidate the xray
    config query too, alongside the existing inbounds-options fix.
  • fix(inbounds): drop listen address from auto-generated inbound tag
    A non-empty, non-any Address (listen) leaked into the tag as
    in-<listen>:<port>-<transport> (e.g. in-127.0.0.1:443-tcp). The tag is
    now always in-<port>-<transport>, with the node prefix and numeric dedup
    suffix still handling uniqueness across nodes and same-port/different-listen
    inbounds. Mirrored in the Go authority and the TS form preview, kept in
    parity by tests.
    
    Existing colon-form tags are now treated as custom, so editing such an
    inbound preserves its tag rather than rewriting it; new inbounds (or a
    cleared tag field) get the clean form.
  • fix(test): drain macrotasks via setTimeout, not setImmediate
    setImmediate is a Node global not declared in the frontend's DOM tsconfig,
    so tsc --noEmit failed with 'Cannot find name setImmediate'. setTimeout is
    universally typed and still flushes React's pending setImmediate: looping
    the awaits keeps afterEach unresolved across several event-loop iterations,
    so the queued check-phase callback fires while window still exists.
  • fix(test): drain React scheduler macrotask before jsdom teardown
    React 19 defers passive-effect flushes onto a setImmediate callback that
    reads window.event. When one was still queued as vitest tore down the
    jsdom environment, it fired after window was deleted and surfaced as an
    unhandled 'window is not defined' error, failing the run with exit 1
    despite all tests passing. Drain the macrotask queue in afterEach so any
    pending callback runs while window still exists.
  • feat(clients): show last-online tooltip on the depleted tag too
    The Online column already surfaced last-online on the offline tag; extend the same tooltip to the depleted (ended) tag so a depleted client's last activity is visible without enabling it.
  • fix(inbounds): correct per-inbound client counts and align stat colors
    The client column under-counted clients attached to an inbound whose shared client_traffics row is keyed to a different inbound: rollupClients filtered settings.clients down to emails that had a stat row on that inbound. Count from settings.clients membership instead. Also surface all/active/disable/depleted/online with the Clients-page color scheme and widen the column.
  • fix(clients): refresh summary counts after a client mutation
    The summary card derived active/bucket counts from the live client_stats snapshot, which only refreshed on the next traffic broadcast (up to 5s). A removal therefore left the counts stale while only total tracked the refetched server summary. Clear the snapshot in invalidateAll so the card falls back to the authoritative server summary immediately; the next stats event repopulates it for live tracking.
  • fix(ui): exit infinite spinner with a retry card on failed initial load
    List pages wrapped content in <Spin spinning={!fetched}> where 'fetched' only flipped true once data arrived. With staleTime: Infinity + retry: 1, a transient network error on first load left the query in a permanent error state and the spinner stuck forever.
    
    Now 'fetched' also settles on query.isError, and a failed load shows a Result error card with a Refresh button that self-heals when the backend returns, mirroring the existing XrayPage pattern. Applied to clients, inbounds, groups, nodes, and the dashboard.
    
    Fixes #4723
  • feat(inbounds): attach existing clients to an inbound in one click
    Adds an 'Attach Existing Clients' row action on multi-user inbounds (shown even when the inbound is empty). It opens a modal listing the whole client pool with search and group filter, all attachable clients pre-selected, and attaches the selection to that inbound via the existing bulkAttach endpoint. Clients already on the inbound are shown disabled and skipped. Translations added for all 13 locales.
  • feat(nodes): bulk panel self-update with live online indicator
    Adds the ability to update node panels to the latest release from the Nodes
    page: select online, enabled nodes (checkboxes) and trigger their official
    self-updater, or use the per-row Update action. A node whose reported panel
    version trails the latest GitHub release is flagged with an 'update available'
    tag (compared via lib/panel-version, mirroring the Go isNewerVersion).
    
    Backend: Remote.UpdatePanel calls the node's existing
    POST /panel/api/server/updatePanel; NodeService.UpdatePanels fans out over the
    selected ids, skipping disabled/offline nodes with a per-node reason; exposed
    as POST /panel/api/nodes/updatePanel (documented in endpoints.ts + openapi.json).
    
    The bulk request sends a JSON body, so it sets Content-Type: application/json
    explicitly — axios defaults POST to form-urlencoded, which made ShouldBindJSON
    fail with 'invalid character i'.
    
    Also reuses the clients-page online cue on the Nodes page: a pulsing green dot
    plus green label for an online node. The .online-dot style moved to the shared
    styles/utils.css so both pages load it.
    
    Translations for all new node keys added across every language file.
  • feat(clients): live online dot + last-online tooltip on offline
    Two small UX cues on the clients table online column:
    
    - a pulsing green dot next to the Online tag so an active client reads as
      live at a glance (honors prefers-reduced-motion).
    - hovering the Offline tag shows the client's last-online timestamp from
      record.traffic.lastOnline, formatted with the panel's calendar setting
      (or "-" when the client has never connected).
  • fix(clients): keep the summary card live without a page refresh
    The clients page summary counters (Online / Depleted / Depleting / Disabled
    / Active) came only from the paged-list response (staleTime: Infinity), so
    they stayed frozen until a manual refresh or a mutation-triggered refetch —
    the per-row columns updated over WebSocket but the summary card did not.
    
    The client_stats WS event already broadcasts every client's traffic
    (enable/up/down/total/expiryTime) every few seconds, so recompute the summary
    client-side from it: computeClientsSummary mirrors the server's
    buildClientsSummary, the latest event is stored in allClientStats, and the
    summary is a useMemo over that plus the live onlines set. Falls back to the
    server summary until the first event lands and keeps the server's
    authoritative total. No extra polling, consistent with the existing
    no-REST-fallback traffic design.
  • fix(inbound): re-derive auto tags on edit and keep node tags consistent
    Auto-generated inbound tags (in-<port>-<l4>, n<id>- prefixed for node inbounds) now re-derive when port/listen/transport change on update instead of keeping the stale round-tripped value. The resolved tag is mirrored onto the API response, and NodeID is pinned to the stored row so a node inbound never loses its n<id>- prefix on edit. The edit form recomputes the tag live via a Go-parity helper so the JSON preview matches what gets saved.
    
    Make node/central tag matching prefix-agnostic in all three places (traffic attribution, remote-id resolution, and the orphan sweep) so an n<id>- prefix present on only one side can no longer spawn duplicate inbounds or drop traffic on sync.
    
    Force LF on shell scripts via .gitattributes (CRLF broke the Docker build shebang when the repo is checked out on Windows) and add a .dockerignore to keep node_modules/.git out of the build context.
    
    Adds Go and frontend tests covering tag re-derivation, prefix-agnostic matching, and node-snapshot prefix mismatch.
  • fix(frontend): add missing react-hooks/exhaustive-deps
    ESLint failed the frontend build on four react-hooks/exhaustive-deps errors. Add the missing dependencies: the hysteria streamSettings effect now lists form, and the inbounds page prompt/import/general-action callbacks now list t. Both form (Form.useForm) and t (useTranslation) are stable references, so no extra re-renders or loops.
  • feat(inbounds): clearer client validation errors on save
    When an inbound save fails Zod validation, the toast previously showed a
    raw path like `settings.clients.494.tgId: Invalid input`, which gave no
    hint which of hundreds of clients was at fault. Resolve the client array
    index back to the client email, name the field, and append a "(+N more)"
    count when several fields fail. console.error now logs a readable list of
    every issue instead of dumping the whole form.
    
    Adds the invalidClientField/invalidField/moreIssues toast strings across
    all 13 translations.
  • refactor(inbounds): remove column sorter from inbound list
    Drop the table header sorter on the inbounds page: the sortKey/sortOrder
    state, the sortedInbounds memo and onChange handler, the per-column
    sorterFor spreads, the SORT_FNS comparator map, and the now-unused
    SortKey/SortOrder types. The list renders in DB order.
  • fix(outbounds): prevent freedom save crash, complete its fields (#4686)
    freedomToWire called Object.entries(s.fragment), but getFieldsValue(true)
    returns freedom settings without a fragment object when the Fragment switch
    is off (its sub-fields never register). That threw 'Cannot convert undefined
    or null to object' and silently killed the save. Guard fragment with a
    fallback so an unset value is treated as empty.
    
    While verifying against xray-core's freedom config, also:
    - add the missing userLevel field (schema, form schema, adapter, UI)
    - fix noise applyTo enum to ip/ipv4/ipv6 (xray rejects the old host/all)
    
    Closes #4686
  • fix(settings): sync generated schemas
    - entity.go: tighten SessionMaxAge validate tag gte=0 -> gte=1 to match the panel UI (min 60) and the hand-written setting.ts schema
    
    - GeneralTab.tsx: add max bounds to sessionMaxAge (525600) and pageSize (1000), raise pageSize min to 1
    
    - regenerate zod.ts/types.ts, picking up pending drift: panelProxy field, client group field, InboundFallback.dest, and dropping the stale hysteria2 protocol enum value
  • feat(postgres): in-panel backup/restore and consistent CLI backend
    Two PostgreSQL gaps on the panel:
    
    1. x-ui setting and other CLI subcommands read XUI_DB_TYPE/XUI_DB_DSN from
       the process environment, which systemd injects via EnvironmentFile but a
       plain shell invocation does not. On a PostgreSQL install the CLI silently
       fell back to SQLite, so changes made from the management menu never
       reached the panel's database. Load the systemd EnvironmentFile
       (/etc/default/x-ui and distro equivalents) at startup; godotenv.Load does
       not override existing vars, so it stays a no-op for the managed service.
    
    2. DB backup/restore (panel endpoints and the Telegram bot) only handled the
       SQLite file, so on PostgreSQL Back Up returned a stale/absent x-ui.db and
       Restore silently did nothing. Add pg_dump/pg_restore based backup/restore:
       - GetDb/ImportDB run pg_dump (custom format) / pg_restore, passing
         credentials via the PG* environment instead of argv.
       - getDb downloads x-ui.dump on Postgres, x-ui.db on SQLite.
       - Telegram backup sends the matching file via GetDb.
       - BackupModal shows a Postgres note and accepts .dump; the dist page
         injects window.X_UI_DB_TYPE; new strings translated for all locales.
       - install.sh installs postgresql-client for the external-DSN path and
         points the user to in-panel Backup & Restore.
    
    Closes #4658
  • fix(inbounds): auto-increment WireGuard peer IP
    New peers were always seeded with allowedIPs 10.0.0.2/32, so each "Add
    peer" reused the same address. Derive the next address from the highest
    IPv4 already present across existing peers (max + 1, keeping its prefix),
    falling back to 10.0.0.2/32 when there are no peers yet.
    
    Closes #4682
  • fix(clients): persist group for node-inbound clients
    The client create/edit form left `group` out of the request payload, so choosing a group in the form was silently dropped (bulkAdd from the Groups page still worked because it writes the column directly). Add `group` to the payload next to `comment`.
    
    SyncInbound also overwrote group_name unconditionally; a group set via bulkAdd is never pushed to the node, so the next node snapshot — which lacks it — wiped the column. Keep group sticky (only overwrite when the incoming value is non-empty); group is only ever set/cleared via the Groups page. Preserve comment for node clients during snapshot sync the same way. Add tests.
  • fix(clients): persist sort selection across navigation
    The clients page saved searchKey and filters to localStorage but not
    the sort selection, so leaving the page and returning reset sort to the
    default (Oldest). Persist the chosen sort alongside the existing filter
    state and restore it on mount, matching the filter-persistence pattern.
  • feat(inbounds): add multi-select and bulk delete
    Mirror the clients page: checkbox selection on the desktop table and on
    mobile cards, with a danger Delete button in the toolbar that removes all
    selected inbounds in one call.
    
    Backend adds POST /panel/api/inbounds/bulkDel, which loops the existing
    DelInbound per id (xray restarts at most once) and returns {deleted,
    skipped}. Frontend shows a confirm modal plus a result toast, clears the
    selection on success, adds bulk-delete i18n keys across all 13 languages,
    and documents the endpoint in the in-panel API docs.