Commit Graph
143 Commits
  • fix(panel): silence update-check WARN spam when offline
    The panel polls api.github.com on every page load. When the host has no
    internet (DNS fails, GitHub blocked, etc.) jsonMsg's auto-WARN logging
    floods the log with the same error every poll.
    
    Bypass jsonMsg for getPanelUpdateInfo: log the error at Debug level and
    return Success:false with the existing localized message so the frontend
    popover behavior is unchanged.
    
    Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
  • refactor(websocket): split controller into service + thin controller
    Move per-connection lifecycle out of the controller and into a new
    service.WebSocketService. The controller is now HTTP-layer only:
    authenticate, validate origin, upgrade, and hand the connection off.
    
    - web/service/websocket.go (new): owns the read/write pumps, hub
      registration, and connection lifetime. Pump constants are prefixed
      (wsWriteWait, wsPongWait, wsPingPeriod, wsClientReadLimit) to avoid
      collisions in the larger service package namespace.
    - web/controller/websocket.go: trimmed to the upgrader, same-origin
      check, auth gate, and hand-off to the service.
    - web/web.go: wires controller.NewWebSocketController(service.NewWebSocketService(hub)).
    
    The hub package (web/websocket) stays as low-level fan-out
    infrastructure. Behavior is unchanged — this is a structural cleanup
    to align with the rest of the codebase's controller/service split.
    
    Also includes a small range-int modernization in login_limiter_test.go
    that gopls flagged.
    
    Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
  • Implement CSRF protection and security hardening across the application (#4179)
    * Implement CSRF protection and security hardening across the application
    
    - Added CSRF token handling in axios requests and HTML templates.
    - Introduced CSRF middleware to validate tokens for unsafe HTTP methods.
    - Implemented login limiter to prevent brute-force attacks.
    - Enhanced security headers in middleware for improved response security.
    - Updated login notification to include safe metadata without passwords.
    - Added tests for CSRF middleware and login limiter functionality.
    
    * fix
  • ws/inbounds: realtime fixes + perf for 10k+ client inbounds (#4123)
    * ws/inbounds: realtime fixes + perf for 10k+ client inbounds
    
    - hub: dedup, throttle, panic-restart, deadlock fix, race tests
    - client: backoff cap + slow-retry instead of giving up
    - broadcast: delta-only payload, count-based invalidate fallback
    - filter: fix empty online list (Inbound has no .id, use dbInbound.toInbound)
    - perf: O(N²)→O(N) traffic merge, bulk delete, /setEnable endpoint
    - traffic: monotonic all_time + UI clamp + propagate in delta handler
    - session: persist on update/logout (fixes logout-after-password-change)
    - ui: protocol tags flex, traffic bar normalize
    
    * Remove hub_test.go file
    
    * fix: ws hub, inbound service, and frontend correctness
    
    - propagate DelInbound error on disable path in SetInboundEnable
    - skip empty emails in updateClientTraffics to avoid constraint violations
    - use consistent IN ? clause, drop redundant ErrRecordNotFound guards
    - Hub.Unregister: direct removeClient fallback when channel is full
    - applyClientStatsDelta: O(1) email lookup via per-inbound Map cache
    - WS payload size check: Blob.size instead of .length for real byte count
    
    * fix: chunk large IN ? queries and fix IPv6 same-origin check
    
    * fix: chunk large IN ? queries and fix IPv6 same-origin check
    
    * fix: unify clientStats cache, throttle clarity, hub constants
    
    * fix(ui): align traffic/expiry cell columns across all rows
    
    * style(ui): redesign outbounds table for visual consistency
    
    * style(ui): redesign routing table for visual consistency
    
    * fix:
    
    * fix:
    
    * fix:
    
    * fix:
    
    * fix:
    
    * fix: font
    
    * refactor: simplify outbound tone functions for consistency and maintainability
    
    ---------
    
    Co-authored-by: lolka1333 <test123@gmail.com>
  • feat: add panel update functionality via web GUI (#4117)
    * feat: add panel update functionality via web GUI
    
    * feat: enhance panel update notifications in web GUI
    
    * feat: implement panel update modal and enhance translation strings
    
    * fix design
  • Feature: Copy clients between inbounds (#4087)
    * feat: copy clients between inbounds
    
    * fix: copy clients modal not opening
    
    * fix: copy clients modal not opening
    
    * fix: copy clients modal not opening
    
    * fix: copy clients modal not opening
    
    * fix: copy clients modal not opening
    
    * fix: copy clients modal not opening
    
    * fix: copy clients modal not opening
    
    * fix: copy clients modal not opening
    
    * fix: copy clients modal not opening
    
    * revert: undo install.sh/deploy.sh changes; i18n: add copy-clients translations for all languages
    
    ---------
    
    Co-authored-by: Нестеров Руслан <r.nesterov@comagic.dev>
  • Fix blank Xray Settings page from wrapped xrayTemplateConfig (#4059) (#4069)
    `getXraySetting` builds its response as
    
        { "xraySetting": <db value>, "inboundTags": ..., "outboundTestUrl": ... }
    
    and embeds the raw DB value as the `xraySetting` field without
    checking whether the stored value already has that exact shape.
    
    The frontend pulls the textarea content from `result.xraySetting`
    and saves it back verbatim. If the DB ever ends up holding the
    response-shaped wrapper instead of a real xray config (older
    installs where this happened at least once, users who imported a
    copy-pasted response into the textarea, a botched migration, etc.),
    the next save nests another layer, the one after that nests a
    third, and the Vue-side JSON.parse of the resulting blob silently
    fails — the Xray Settings page goes blank.
    
    Fix both ends of the round-trip:
    
    * Add `service.UnwrapXrayTemplateConfig`. It peels off any number of
      `xraySetting`-keyed layers, leaving a real xray config behind.
      The check is conservative: if the outer object already contains
      any top-level xray key (`inbounds`, `outbounds`, `routing`, `api`,
      `dns`, `log`, `policy`, `stats`), it is returned unchanged, and
      there is a depth cap to avoid pathological inputs.
    
    * `SaveXraySetting` unwraps before validation so a round-tripped
      wrapper from an already-corrupted page can no longer re-poison
      the DB on save.
    
    * `getXraySetting` unwraps on read and, when it finds a wrapper,
      rewrites the DB with the corrected value. Existing broken installs
      heal themselves on the next visit to the page.
    
    Includes unit tests for the passthrough, single-wrap, multi-wrap,
    string-encoded-inner, and false-positive cases.
    
    Co-authored-by: pwnnex <eternxles@gmail.com>
  • Centralize session options and adjust cookies
    Configure session cookie options centrally in initRouter and remove per-login MaxAge handling. Deleted SetMaxAge helper and its use in the login flow; session.Options are now applied once using basePath with HttpOnly and SameSite defaults, and MaxAge is set only when the stored setting is available and >0. Also make CookieManager.setCookie treat exdays as optional (only add expires when provided) and stop using a hardcoded 150-day expiry for the lang cookie in the JS language manager.
    
    Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
  • feat: Add NordVPN NordLynx (WireGuard) integration (#3827)
    * feat: Add NordVPN NordLynx (WireGuard) integration with dedicated UI and backend services.
    
    * remove limit=10 to get all servers
    
    * feat: add city selector to NordVPN modal
    
    * feat: auto-select best server on country/city change
    
    * feat: simplify filter logic and enforce > 7% load
    
    * fix
    
    ---------
    
    Co-authored-by: Sanaei <ho3ein.sanaei@gmail.com>
  • Add SSRF protection (#4044)
    * Add SSRF protection for custom geo downloads
    
    Introduce SSRF-safe HTTP transport for custom geo operations by adding ssrfSafeTransport and isBlockedIP helpers. The transport resolves hosts and blocks loopback, private, link-local and unspecified addresses, returning ErrCustomGeoSSRFBlocked on violations. Update probeCustomGeoURLWithGET, probeCustomGeoURL and downloadToPathOnce to use the safe transport. Also add the new error ErrCustomGeoSSRFBlocked and necessary imports. Minor whitespace/formatting adjustments in subClashService.go, web/entity/entity.go and web/service/setting.go.
    
    * Add path traversal protection for custom geo
    
    Prevent path traversal when handling custom geo downloads by adding ErrCustomGeoPathTraversal and a validateDestPath() helper that ensures destination paths stay inside the bin folder. Call validateDestPath from downloadToPathOnce, Update and Delete paths and wrap errors appropriately. Reconstruct sanitized URLs in sanitizeURL to break taint propagation before use. Map the new path-traversal error to a user-facing i18n message in the controller.
    
    * fix
  • Add custom geosite/geoip URL sources (#3980)
    * feat: add custom geosite/geoip URL sources
    
    Register DB model, panel API, index/xray UI, and i18n.
    
    * fix
  • fix: enhance WebSocket stability, resolve XHTTP configurations and fix UI loading shifts (#3997)
    * feat: implement real-time traffic monitoring and UI updates using a high-performance WebSocket hub and background job system
    
    * feat: add bulk client management support and improve inbound data handling
    
    * Fix bug
    
    * **Fixes & Changes:**
    1. **Fixed XPadding Placement Dropdown**:
       - Added the missing `cookie` and `query` options to `xPaddingPlacement` (`stream_xhttp.html`).
       - *Why:* Previously, users wanting `cookie` obfuscation were forced to use the `header` placement string. This caused Xray-core to blindly intercept the entire monolithic HTTP Cookie header, failing internal padding-length validations and causing the inbound to silently drop the connection.
    2. **Fixed Uplink Data Placement Validation**:
       - Replaced the unsupported `query` option with `cookie` in `uplinkDataPlacement`.
       - *Why:* Xray-core's `transport_internet.go` explicitly forbids `query` as an uplink placement option. Selecting it from the UI previously sent a payload that would cause Xray-core to instantly throw an `unsupported uplink data placement: query` panic. Adding `cookie` perfectly aligns the UI with Xray-core restrictions.
    ### Related Issues
    - Resolves #3992
    
    * This commit fixes structural payload issues preventing XHTTP from functioning correctly and eliminates WebSocket log spam.
    - **[Fix X-Padding UI]** Added missing `cookie` and `query` options to X-Padding Placement. Fixes the issue where using Cookie fallback triggers whole HTTP Cookie header interception and silent drop in Xray-core. (Resolves [#3992](https://github.com/MHSanaei/3x-ui/issues/3992))
    - **[Fix Uplink Data Options]** Replaced the invalid `query` option with `cookie` in Uplink Data Placement dropdown to prevent Xray-core backend panic `unsupported uplink data placement: query`.
    - **[Fix WebSockets Spam]** Boosted `maxMessageSize` boundary to 100MB and gracefully handled fallback fetch signals via `broadcastInvalidate` to avoid buffer dropping spam. (Resolves [#3984](https://github.com/MHSanaei/3x-ui/issues/3984))
    
    * Fix
    
    * gofmt
    
    * fix(websocket): resolve channel race condition and graceful shutdown deadlock
    
    * Fix: inbounds switch
    
    * Change max quantity from 10000 to 500
    
    * fix
  • Add url speed test for outbound (#3767)
    * add outbound testing functionality with configurable test URL
    
    * use no kernel tun for conflict errors
  • Refactor code and fix linter warnings (#3627)
    * refactor: use any instead of empty interface
    
    * refactor: code cleanup
  • feat: Add WebSocket support for real-time updates and enhance VLESS settings (#3605)
    * feat: add support for trusted X-Forwarded-For and testseed parameters in VLESS settings
    
    * chore: update Xray Core version to 25.12.8 in release workflow
    
    * chore: update Xray Core version to 25.12.8 in Docker initialization script
    
    * chore: bump version to 2.8.6 and add watcher for security changes in inbound modal
    
    * refactor: remove default and random seed buttons from outbound form
    
    * refactor: update VLESS form to rename 'Test Seed' to 'Vision Seed' and change button functionality for seed generation
    
    * refactor: enhance TLS settings form layout with improved button styling and spacing
    
    * feat: integrate WebSocket support for real-time updates on inbounds and Xray service status
    
    * chore: downgrade version to 2.8.5
    
    * refactor: translate comments to English
    
    * fix: ensure testseed is initialized correctly for VLESS protocol and improve client handling in inbound modal
    
    * refactor: simplify VLESS divider condition by removing unnecessary flow checks
    
    * fix: add fallback date formatting for cases when IntlUtil is not available
    
    * refactor: simplify WebSocket message handling by removing batching and ensuring individual message delivery
    
    * refactor: disable WebSocket notifications in inbound and index HTML files
    
    * refactor: enhance VLESS testseed initialization and button functionality in inbound modal
    
    * fix:
    
    * refactor: ensure proper WebSocket URL construction by normalizing basePath
    
    * fix:
    
    * fix:
    
    * fix:
    
    * refactor: update testseed methods for improved reactivity and binding in VLESS form
    
    * logger info to debug
    
    ---------
    
    Co-authored-by: lolka1333 <test123@gmail.com>
  • Vlessenc (#3426)
    * mlkem768
    
    * VlessEnc
  • feat: add "Last Online" column to client list and modal (Closes #3402) (#3405)
    * feat: persist client last online and expose API
    
    * feat(ui): show client last online in table and info modal
    
    * i18n: add “Last Online” across locales
    
    * chore: format timestamps as HH:mm:ss
  • Added Update all geofiles button (#3318)
    * added Update all geofiles button
    
    * localized update all string
  • Added filters to the xray logs viewer (#3314)
    * added filters to xray logs viewer
    
    * better freedom/blackhole tags handling
    
    * better freedom/blackhole tags handling 2
    
    * fix comments
    
    * fix comments 2
  • Added xray access log viewer (#3309)
    * added xray access log viewer
    
    * made modal window width adaptive
    
    * hide logs button if xray logs are disabled
  • add ech support (#3310)
    Co-authored-by: Alireza Ahmadi <alireza7@gmail.com>
  • Endpoint for updating client traffic by email (#3259)
    * Update api.go
    
    * Update inbound.go
    
    * Update inbound.go
  • fix: handle inbounds interaction errors (#3009)
    eliminates messages like: “Inbound created successfully (Port 100 is already busy)”.
  • chore: implement 2fa auth (#2968)
    * chore: implement 2fa auth
    
    from #2786
    
    * chore: format code
    
    * chore: replace two factor token input with qr-code
    
    * chore: requesting confirmation of setting/removing two-factor authentication
    
    otpauth library was taken from cdnjs
    
    * chore: revert changes in `ClipboardManager`
    
    don't need it.
    
    * chore: removing twoFactor prop in settings page
    
    * chore: remove `twoFactorQr` object in `mounted` function
  • revert group management (#2656)
    * Revert "json post base path bug fixed (#2647)"
    
    This reverts commit 04cf250a54.
    
    * Revert "Group Management of Subscription Clients"
    
    * Revert "fix getSubGroupClients for enable/disable and edit clients."
    
    * Revert "Enhance database initialization in db.go (#2645)"
    
    This reverts commit 66fe84181b.
    
    * Revert "Add checkpoint handling in CloseDB function (#2646)"
    
    This reverts commit 4dd40f6f19.
    
    * Revert "Improved database model migration and added indexing (#2655)"
    
    This reverts commit b922d986d6.
  • Group Management of Subscription Clients (#2644)
    * add group user with the same subscription id to all inbounds
    
    * code format compare
    
    * add await for reset client traffic
    
    * en language changed
    
    * added client traffic syncer job
    
    * handle exist email duplicate in sub group
    
    * multi reset and delete request for clients group
    
    * add client traffic syncer setting option
    
    * vi translate file updated
    
    * auto open qr-modal bug fixed
  • fix session
    twice  set-cookie bug fixed