feat(sub): add Happ client integration, routing presets, and app management (#6434)

* feat(sub): add Happ client integration, routing presets, and app management

Implement comprehensive Happ proxy client integration according to official developer specifications.

- Fix header emission on disabled routing and hidden settings to send explicit '0' headers rather than omitting, allowing Happ clients to reset cached settings.
- Add support for 'happ://routing/off' deeplink in routing validation.
- Preserve '?serverDescription=' query parameters in link fragments without escaping to support Happ server subtitles across VMess, VLESS, Trojan and SS.
- Add Happ application management headers: ProviderID, New-Url, Fallback-Url, Sub-Info banners, Sub-Expire notifications, No-Limit mode, hardware ID enforcement, TUN modes/types, route exclusions, APNS exclusions, and per-app proxy settings.
- Add curated routing presets (Iran Bypass, China Direct, AdBlock, Global) and interactive visual rule generator in frontend settings.
- Synchronize all 13 translation locales with native Persian, Russian, and Chinese translations.

* fix(sub): keep Happ header overrides behind the auto-detect opt-in

The Routing-Enable/Hide-Settings off values were emitted on the
User-Agent alone, so every panel that upgraded would push
"Routing-Enable: 0" — documented by happ.su as disabling routing
globally — to every Happ client without the operator enabling anything.
They now ride subHappAutoDetect like every other Happ header.

Two further mismatches against the vendor spec:

- serverDescription was written as a key of the VMess base64 JSON
  object. happ.su documents it as a "#Title?serverDescription=<base64>"
  link parameter or a JSON "meta" entry, so the caption never reached
  Happ while every other VMess consumer received an unknown key.
  Dropped rather than moved: emitting the documented form is unsafe
  here because our own parser base64-decodes the whole VMess body
  (internal/util/link/outbound.go).

- The TUN Mode dropdown stored the literal "default", forwarded as
  "Tun-Mode: default", where happ.su documents system|gvisor only. It
  now stores the unset value so no header is sent. TUN Type "default"
  is a documented value and is unchanged.

Each fix carries a test that fails without it.
This commit is contained in:
Pejman Yousefi
2026-09-10 17:16:12 +03:30
committed by GitHub
parent d5ab84e8d5
commit 1456658028
35 changed files with 3460 additions and 51 deletions
+25
View File
@@ -112,6 +112,31 @@ type AllSetting struct {
SubThemeDir string `json:"subThemeDir" form:"subThemeDir"`
SubHideSettings bool `json:"subHideSettings" form:"subHideSettings"`
// Happ client customization settings (app-management / routing / UX).
SubHappAutoDetect bool `json:"subHappAutoDetect" form:"subHappAutoDetect"`
SubHappProviderId string `json:"subHappProviderId" form:"subHappProviderId"`
SubHappNewUrl string `json:"subHappNewUrl" form:"subHappNewUrl"`
SubHappFallbackUrl string `json:"subHappFallbackUrl" form:"subHappFallbackUrl"`
SubHappSubInfoColor string `json:"subHappSubInfoColor" form:"subHappSubInfoColor"`
SubHappSubInfoText string `json:"subHappSubInfoText" form:"subHappSubInfoText"`
SubHappSubInfoButtonText string `json:"subHappSubInfoButtonText" form:"subHappSubInfoButtonText"`
SubHappSubInfoButtonLink string `json:"subHappSubInfoButtonLink" form:"subHappSubInfoButtonLink"`
SubHappSubExpire bool `json:"subHappSubExpire" form:"subHappSubExpire"`
SubHappSubExpireButtonLink string `json:"subHappSubExpireButtonLink" form:"subHappSubExpireButtonLink"`
SubHappNotificationExpire bool `json:"subHappNotificationExpire" form:"subHappNotificationExpire"`
SubHappNoLimit bool `json:"subHappNoLimit" form:"subHappNoLimit"`
SubHappAlwaysHwid bool `json:"subHappAlwaysHwid" form:"subHappAlwaysHwid"`
SubHappTunMode string `json:"subHappTunMode" form:"subHappTunMode"`
SubHappTunType string `json:"subHappTunType" form:"subHappTunType"`
SubHappExcludeRoutes string `json:"subHappExcludeRoutes" form:"subHappExcludeRoutes"`
SubHappExcludeApns bool `json:"subHappExcludeApns" form:"subHappExcludeApns"`
SubHappColorProfile string `json:"subHappColorProfile" form:"subHappColorProfile"`
SubHappPingType string `json:"subHappPingType" form:"subHappPingType"`
SubHappAutoConnect bool `json:"subHappAutoConnect" form:"subHappAutoConnect"`
SubHappAutoConnectType string `json:"subHappAutoConnectType" form:"subHappAutoConnectType"`
SubHappPerAppMode string `json:"subHappPerAppMode" form:"subHappPerAppMode"`
SubHappPerAppList string `json:"subHappPerAppList" form:"subHappPerAppList"`
LdapEnable bool `json:"ldapEnable" form:"ldapEnable"`
LdapHost string `json:"ldapHost" form:"ldapHost"`
LdapPort int `json:"ldapPort" form:"ldapPort" validate:"gte=0,lte=65535"`