1321 Commits
  • new: vless reverse
    legacy reverse removed
  • 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>
  • subpage: enabled state
    Track and surface a subscription's enabled state from backend to frontend so the UI can show inactive subscriptions and use it in active-state logic.
    
    Changes:
    - sub/subService.go: track hasEnabledClient, set traffic.Enable, add Enabled to PageData and populate it in BuildPageData.
    - sub/subController.go: include enabled in the page context.
    - web/html/settings/panel/subscription/subpage.html: emit data-enabled attribute and render an "inactive" tag when disabled.
    - web/assets/js/subscription.js: read data-enabled and include it in isActive() checks.
    
    This ensures subscriptions with no enabled clients are marked inactive in the UI and excluded from being considered active.
  • feat: add configurable auto-restart on client auto-disable
    Add a configurable option to restart Xray when clients are auto-disabled and persist disable actions.
    
    Changes include:
    - New setting restartXrayOnClientDisable (default true), getters/setters in SettingService, UI toggle in general settings, and translations for multiple locales.
    - AddTraffic signature updated to return a third bool (clientsDisabled). disableInvalidClients now calls Xray API to remove users, marks client_traffics.enable=false, updates inbound.Settings JSON so clients appear disabled in stored settings, and returns appropriate counts/errors.
    - XrayTrafficJob now checks the clientsDisabled flag and restarts Xray when the setting is enabled (with fallback to mark Xray as needing restart on failure).
    - XrayService.GetXrayConfig call adjusted to ignore AddTraffic returns.
    - Subscription generation (subService/subJson/subClash) no longer filters clients by their enable flag when matching subId.
    - Minor fixes: check_client_ip_job now checks scanner.Err and improved API error handling/logging.
    
    These changes ensure auto-disabled clients are propagated to Xray and the stored inbound settings, and provide an option to restart Xray automatically after auto-disable events.
  • Update QUIC params defaults and UI validations
    #4142
    Adjust QUIC parameter defaults and tighten form validation across inbound/outbound components.
    
    - Set default brutalUp/brutalDown to 65537 and only include them in JSON when congestion is 'brutal' or 'force-brutal'.
    - Change keepAlivePeriod defaults (inbound QUIC -> 5s, Hysteria stream -> 2s) and enforce minimums in the UI.
    - Expose and serialize additional QUIC fields in outbound QuicParams: init/max stream windows, init/max connection windows, maxIdleTimeout, disablePathMTUDiscovery, maxIncomingStreams.
    - Add UI min/placeholder constraints: stream/connection receive windows min=16384 and updated placeholders to show defaults, brutal fields min=65537, maxIncomingStreams min=8 (placeholders updated), keepAlive min adjusted.
    - Add Wireguard and Hysteria entries to Protocols.
    
    Touched files: web/assets/js/model/inbound.js, web/assets/js/model/outbound.js, web/html/form/outbound.html, web/html/form/stream/stream_finalmask.html.
  • Check scanner error in GetXrayLogs
    Add a check for scanner.Err() after scanning log lines and return nil if an error occurred. This prevents further processing of potentially incomplete or invalid log entries when the scanner encountered an error.
  • 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
  • xray-setting: pin api routing rule to index 0 on save (#4124)
    when the admin adds a custom outbound (eg vless cascade to a second
    server) and a routing rule sending all inbound traffic to it, that
    catch-all gets evaluated before the existing api->api rule, so the
    panel's internal stats inbound's traffic ends up on the cascade
    outbound. the grpc stats query then can't see anything, GetTraffic
    returns no inbound/user counters, and every client appears offline
    with zero traffic even though the actual proxy path works fine.
    
    before save, find the api rule and move it to the front of
    routing.rules. if it's missing entirely, insert a default. other
    rules keep their relative order.
    
    closes #4113. probably also fixes the long-standing #2818 where the
    documented workaround was "manually move the api rule to the top".
  • kcp: mtu and tti
    Add KCP-specific fields mtu and tti to inbound stream handling in web/assets/js/model/inbound.js. The changes add obj.mtu/obj.tti when serializing the kcp stream and set params for mtu and tti in the various KCP parameter-building branches so these values are preserved and transmitted where KCP is used.
  • Merge pull request #4092 from pwnnex/fix/iplimit-live-only-slot-count
    iplimit: dont count idle db-only ips toward the per-client limit (#4091)
  • iplimit: dont count idle db-only ips toward the per-client limit
    after #4083 the staleness window is 30 minutes, which still lets an ip
    that stopped connecting a few minutes ago sit in the db blob and keep
    the protected slot on the ascending sort. the ip that is actually
    connecting right now gets classified as excess and sent to fail2ban,
    and never lands in inbound_client_ips.ips so the panel doesnt show it
    until you clear the log by hand.
    
    only count ips observed in the current scan toward the limit. db-only
    entries stay in the blob for display but dont participate in the ban
    decision. live subset still uses the "protect oldest, ban newcomer"
    rule.
    
    closes #4091. followup to #4077.
  • 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>
  • hysteria: also accept "hysteria2" protocol string
    UI stores v1 and v2 both as "hysteria" with settings.version, but
    inbounds that came in from imports / manual SQL can carry the
    literal "hysteria2" string and get silently dropped everywhere we
    switch on protocol.
    
    Add Hysteria2 constant + IsHysteria helper, use it in the places
    that gate on protocol (sub SQL, getLink, genHysteriaLink, clash
    buildProxy, json gen, inbound.go validation, xray AddUser).
    
    Existing "hysteria" inbounds are untouched.
    
    closes #4081
  • Merge pull request #4083 from pwnnex/fix/iplimit-stale-db-evict
    Fix IP Limit continuous ban loop after a legitimate ban expires (#4077)
  • Fix IP Limit continuous ban loop from stale DB entries (#4077)
    After 60abeaa flipped the excess-IP selector to "oldest wins,
    newest loses" (to protect the original/current connections), the
    per-client IP table in `inbound_client_ips.ips` never evicted IPs
    that stopped connecting. Their stored timestamp stayed ancient, so
    on every subsequent run they counted as the "oldest protected"
    slot(s) and whichever IP was actually using the config now was
    classified as "new excess" and re-banned via fail2ban.
    
    This is exactly the #4077 scenario: two IPs connect once and get
    recorded, the ban lifts after the configured duration, the lone
    legitimate IP that reconnects gets banned again, and again, and
    again — a permanent 3xipl.log loop with no real abuser anywhere.
    
    Fix: when merging the persisted `old` list with the freshly
    observed `new` log lines, drop entries whose last-seen timestamp
    is older than `ipStaleAfterSeconds` (30 minutes). A client that's
    actually still active refreshes its timestamp any time xray emits
    a new `accepted` line for a fresh TCP, so the cutoff is far above
    even idle streaming sessions; a client that's genuinely gone falls
    out of the table in bounded time and frees its slot.
    
    Extracted the merge into `mergeClientIps` so it can be exercised
    by unit tests without spinning up the full DB-backed job.
    
    Tests cover:
    - stale old entry is dropped (the #4077 regression)
    - fresh old entries are still carried forward (access-log rotation
      is still backed by the persisted table)
    - newer timestamp wins when the same IP appears in both lists
    - a clock-skewed old `new` entry can't resurrect a stale IP
    - a zero cutoff never over-evicts
    
    Closes #4077
  • fix(panel): set ALPN to h3 when switching to Hysteria protocol (#4076)
    - Automatically explicitly set ALPN to ['h3'] for Hysteria to prevent QUIC handshake mismatch.
  • Lower minimum Xray version
    Update GetXrayVersions filter to accept Xray releases >= 26.3.10 instead of the previous >= 26.4.17. This changes the conditional in web/service/server.go so releases from 26.3.10 onward are included when building the versions list.
  • 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>
  • fix timelocation for windows
    Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
  • sub json fix fragment noises effect
    Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
  • Fix xhttp xPadding settings missing from generated links (panel + subs) (#4065)
    * Fix: propagate xhttp xPadding settings into generated subscription links
    
    The four `genXLink` helpers in `sub/subService.go` only copied `path`,
    `host` and `mode` out of `xhttpSettings` when building vmess:// /
    vless:// / trojan:// / ss:// URLs. Everything else — `xPaddingBytes`,
    `xPaddingObfsMode`, `xPaddingKey`, `xPaddingHeader`,
    `xPaddingPlacement`, `xPaddingMethod` — was silently dropped.
    
    That meant an admin who set, say, `xPaddingBytes: "80-600"` plus obfs
    mode with a custom `xPaddingKey` on the inbound had a server config
    that no client could match from the copy-pasted link: the client kept
    the xray/sing-box internal defaults (`100-1000`, `x_padding`,
    `Referer`), hit the server, and was rejected by
    
        invalid padding (queryInHeader=Referer, key=x_padding) length: 0
    
    The user-visible symptom on OpenWRT / Podkop / sing-box was
    "xhttp inbound just won't connect" — no obvious pointer to what was
    actually wrong because the link itself *looks* complete.
    
    Fix:
    
      * New helper `applyXhttpPaddingParams(xhttp, params)` writes
        `x_padding_bytes=<range>` (flat, sing-box family reads this) and
        an `extra=<url-encoded-json>` blob carrying the full set of xhttp
        settings (xray-core family reads this). Both encodings are emitted
        side-by-side so every mainstream client can pick at least one up.
      * All four link generators (`genVmessLink` via the obj map,
        `genVlessLink`, `genTrojanLink`, `genShadowsocksLink`) now invoke
        the copy.
      * Obfs-only fields (`xPaddingKey`, `xPaddingHeader`,
        `xPaddingPlacement`, `xPaddingMethod`) are only included when
        `xPaddingObfsMode` is actually true and the admin filled them in.
        An inbound with no custom padding produces exactly the same URL
        as before — existing subscriptions are unaffected.
    
    * Also propagate xhttp xPadding settings into the panel's own Info/QR links
    
    The previous commit covered the subscription service
    (sub/subService.go). The admin-panel side — the "Copy URL" / QR /
    Info buttons inside inbound details — has four more
    xhttp-emitting link generators in `web/assets/js/model/inbound.js`
    (`genVmessLink`, `genVLESSLink`, `genTrojanLink`, `genSSLink`) that
    had the exact same gap: only `path`, `host` and `mode` were copied.
    
    Mirror the server-side fix on the client:
    
    * Add two static helpers on `Inbound`:
      - `Inbound.applyXhttpPaddingToParams(xhttp, params)` for
        `vless://` / `trojan://` / `ss://` style URLs — writes
        `x_padding_bytes=<range>` (sing-box family) and
        `extra=<url-encoded-json>` (xray-core family).
      - `Inbound.applyXhttpPaddingToObj(xhttp, obj)` for the VMess base64
        JSON body — sets the same fields directly on the object.
    * Call them from all four link generators so an admin who enables
      obfs mode + a custom `xPaddingKey` / `xPaddingHeader` actually
      gets a working URL from the panel.
    * Only non-empty fields are emitted, so default inbounds produce
      exactly the same URL as before.
    
    Also fixes a latent positional-args bug in
    `web/assets/js/model/outbound.js`: both VMess-JSON (L933) and
    `fromParamLink` (L975) were calling
    `new xHTTPStreamSettings(path, host, mode)` — but the 3rd positional
    arg of the constructor is `headers`, not `mode`, so `mode` was
    landing in the `headers` slot and the actual `mode` field stayed at
    its default. Construct explicitly and set `mode` by name; while
    here, also pick up `x_padding_bytes` and the `extra` JSON blob from
    the imported URL so the symmetric case of importing a padded link
    works too.
    
    ---------
    
    Co-authored-by: pwnnex <eternxles@gmail.com>
  • Fix: hysteria link gen crashes when echConfigList is a string (#4064)
    `genHysteriaLink` was calling `.join(',')` on
    `this.stream.tls.settings.echConfigList`, but that field is bound to an
    `<a-input>` (single-line string) in `tls_settings.html` and defaults to
    `''` in `TlsStreamSettings.Settings`. Calling `.join()` on a string
    throws `TypeError: echConfigList.join is not a function`, which breaks
    the Info / QR buttons for every hysteria / hysteria2 inbound.
    
    All three sibling link generators (`genVmessLink`, `genVlessLink`,
    `genTrojanLink`) already pass the value directly:
    
        params.set("ech", this.stream.tls.settings.echConfigList)
    
    `URLSearchParams.set` will stringify arrays with `,` on its own, so the
    same one-liner works for both string and array inputs. Align
    `genHysteriaLink` with the other three.
    
    Fixes #4063
    
    Co-authored-by: pwnnex <eternxles@gmail.com>
  • kcp : default value maxSendingWindow
    MaxSendingWindow must be >= Mtu