Commit Graph
5 Commits
  • 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.
  • 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
  • Fix Hysteria External Proxy + include Hysteria in Clash subscription (#4053) (#4073)
    * Fix Hysteria External Proxy + include Hysteria in Clash subscription (#4053)
    
    Two related gaps on the Hysteria side of the subscription layer:
    
    1) `genHysteriaLink` ignored `externalProxy` entirely, so an admin who
       pointed a Hysteria inbound at an alternate endpoint (e.g. a CDN
       hostname forwarding UDP back to the node) still got a link with the
       original server address. Mirror what `genVlessLink` / `genTrojanLink`
       already do: fan out one link per entry, substituting `dest` / `port`
       and picking up the entry's remark suffix. As a bonus, the salamander
       obfs password is now copied into the URL too — the panel-side link
       generator already did this, so the subscription output was lagging
       behind it.
    
    2) `buildProxy` in `subClashService.go` had a protocol switch with cases
       for VMESS / VLESS / Trojan / Shadowsocks and a `default: return nil`.
       Hysteria inbounds fell into the default branch and silently vanished
       from the Clash YAML. Route Hysteria to a dedicated
       `buildHysteriaProxy` helper before the transport/security helpers run
       (applyTransport / applySecurity model xray streams, which Hysteria
       doesn't use).
    
       `buildHysteriaProxy` reads `inbound.StreamSettings` directly instead
       of going through `streamData` / `tlsData`, because those prune
       fields (`allowInsecure`, the salamander `finalmask.udp` block) that
       the mihomo Hysteria proxy wants preserved. Output shape matches
       mihomo's expectations:
    
         type: hysteria2                  # or "hysteria" for v1
         password / auth-str: <client auth>
         sni, alpn, skip-cert-verify, client-fingerprint
         obfs: salamander
         obfs-password: <finalmask.udp[salamander].settings.password>
    
    The existing `getProxies` fanout over `externalProxy` already plugs in
    for Clash, so with Hysteria now recognised, External Proxy entries
    also flow through to the Clash output for Hysteria inbounds.
    
    Closes #4053
    
    * gofmt: align map keys in buildHysteriaProxy
    
    ---------
    
    Co-authored-by: pwnnex <eternxles@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
  • feat add clash yaml convert (#3916)
    * docs(agents): add AI agent guidance documentation
    
    * feat(sub): add Clash/Mihomo YAML subscription service
    
    Add SubClashService to convert subscription links to Clash/Mihomo
    YAML format for direct client compatibility.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    
    * feat(sub): integrate Clash YAML endpoint into subscription system
    
    - Add Clash route handler in SUBController
    - Update BuildURLs to include Clash URL
    - Pass Clash settings through subscription pipeline
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    
    * feat(web): add Clash settings to entity and service
    
    - Add SubClashEnable, SubClashPath, SubClashURI fields
    - Add getter methods for Clash configuration
    - Set default Clash path to /clash/ and enable by default
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    
    * feat(ui): add Clash settings to subscription panels
    
    - Add Clash enable switch in general subscription settings
    - Add Clash path/URI configuration in formats panel
    - Display Clash QR code on subscription page
    - Rename JSON tab to "Formats" for clarity
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    
    * feat(js): add Clash support to frontend models
    
    - Add subClashEnable, subClashPath, subClashURI to AllSetting
    - Generate and display Clash QR code on subscription page
    - Handle Clash URL in subscription data binding
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    
    * fix
    
    ---------
    
    Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
    Co-authored-by: Sanaei <ho3ein.sanaei@gmail.com>