[PR #6434] [MERGED] feat(sub): add Happ client integration, routing presets, and app management #6268

Closed
opened 2026-11-02 04:07:32 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6434
Author: @Pejman-Yousefi-Official
Created: 9/7/2026
Status: ✅ Merged
Merged: 9/10/2026
Merged by: @MHSanaei

Base: main ← Head: feat/happ-customization


📝 Commits (3)

  • 72b7189 feat(sub): add Happ client integration, routing presets, and app management
  • 15ac222 Merge branch 'main' into feat/happ-customization
  • 6544be8 fix(sub): keep Happ header overrides behind the auto-detect opt-in

📊 Changes

35 files changed (+3460 additions, -51 deletions)

View changed files

📝 docs/public/openapi.json (+186 -0)
📝 frontend/public/openapi.json (+186 -0)
📝 frontend/src/generated/examples.ts (+46 -0)
📝 frontend/src/generated/schemas.ts (+186 -0)
📝 frontend/src/generated/types.ts (+46 -0)
📝 frontend/src/generated/zod.ts (+46 -0)
📝 frontend/src/models/setting.ts (+23 -0)
➕ frontend/src/pages/settings/HappSettingsContent.tsx (+637 -0)
📝 frontend/src/pages/settings/SubscriptionGeneralTab.tsx (+7 -34)
➕ frontend/src/pages/settings/happPresets.ts (+118 -0)
📝 frontend/src/schemas/setting.ts (+23 -0)
➕ frontend/src/test/happ-presets.test.ts (+85 -0)
➕ frontend/src/test/happ-settings-tun-mode.test.tsx (+72 -0)
📝 internal/sub/controller.go (+16 -2)
📝 internal/sub/endpoint_test.go (+26 -0)
➕ internal/sub/happ.go (+141 -0)
➕ internal/sub/happ_test.go (+227 -0)
📝 internal/sub/remote_routing.go (+3 -0)
📝 internal/sub/service.go (+1 -2)
📝 internal/sub/sub.go (+26 -0)

...and 15 more files

📄 Description

Summary

Adds comprehensive integration and customization for the Happ VPN client according to official Happ developer specifications, including bug fixes for existing settings, routing presets with a visual rule generator, app management headers, and server subtitles.

Why

  1. Bug fixes in existing options:
    • When routing (subEnableRouting) or hiding server settings (subHideSettings) were toggled off, no headers were emitted. Happ's specification requires explicit Routing-Enable: 0 and Hide-Settings: 0 headers to clear cached state on the client.
    • The happ://routing/off deeplink was rejected by normalizeHappRouting as invalid JSON.
    • Server description URL fragments (#Title?serverDescription=...) had their ? and = characters percent-escaped by standard URL encoding, breaking Happ's subtitle regex.
  2. Feature parity with Happ developer specifications:
    • Enables full provider management (ProviderID, New-Url for zero-downtime migration, Fallback-Url).
    • Introduces smart in-app announcement banners (Sub-Info-Text, Sub-Info-Color, buttons) and expiration alerts (Sub-Expire, Notification-Subs-Expire).
    • Supports performance and security controls: No-Limit-Enabled, Subscription-Always-Hwid-Enable (HWID binding).
    • Exposes network stack options: TUN modes (system, gvisor), TUN core types (singbox, tun2proxy, default, xray), route exclusions, and Apple APNs bypass.
    • Provides curated routing presets (Iran Bypass, China Direct, AdBlock, Global) and a built-in visual deeplink generator in the UI.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

  • Go unit tests: Added internal/sub/happ_test.go verifying header injection, happ://routing/off preservation, preset deeplink builders, and subtitle fragment escaping.
  • Frontend unit tests: Added frontend/src/test/happ-presets.test.ts verifying all presets, Base64 UTF-8 encoding, and parser helpers (7/7 tests passed).
  • i18n parity: Ran i18n-dead-keys.test.ts ensuring all 13 locale files in internal/web/translation/ are fully synchronized with zero dead or orphan keys.
  • TypeScript & Linting: Validated with npm run typecheck (0 errors) and oxlint src tools (0 errors across 536 files).
  • Build verification: Verified production Vite build into internal/web/dist/.

Screenshots / recordings

(Optional: You can take a screenshot of Settings -> Subscription -> Happ tab and drag & drop it here)

Breaking changes

None. All new fields default to safe/empty values, and existing non-Happ clients are completely unaffected.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6434 **Author:** [@Pejman-Yousefi-Official](https://github.com/Pejman-Yousefi-Official) **Created:** 9/7/2026 **Status:** ✅ Merged **Merged:** 9/10/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `feat/happ-customization` --- ### 📝 Commits (3) - [`72b7189`](https://github.com/MHSanaei/3x-ui/commit/72b71894ee444f232fc83ebfa335a3a68ff825c9) feat(sub): add Happ client integration, routing presets, and app management - [`15ac222`](https://github.com/MHSanaei/3x-ui/commit/15ac222dbb934ecd9ae0a3e3a791b64474a0745f) Merge branch 'main' into feat/happ-customization - [`6544be8`](https://github.com/MHSanaei/3x-ui/commit/6544be863dde83930791058a39c56b30e3cc1288) fix(sub): keep Happ header overrides behind the auto-detect opt-in ### 📊 Changes **35 files changed** (+3460 additions, -51 deletions) <details> <summary>View changed files</summary> 📝 `docs/public/openapi.json` (+186 -0) 📝 `frontend/public/openapi.json` (+186 -0) 📝 `frontend/src/generated/examples.ts` (+46 -0) 📝 `frontend/src/generated/schemas.ts` (+186 -0) 📝 `frontend/src/generated/types.ts` (+46 -0) 📝 `frontend/src/generated/zod.ts` (+46 -0) 📝 `frontend/src/models/setting.ts` (+23 -0) ➕ `frontend/src/pages/settings/HappSettingsContent.tsx` (+637 -0) 📝 `frontend/src/pages/settings/SubscriptionGeneralTab.tsx` (+7 -34) ➕ `frontend/src/pages/settings/happPresets.ts` (+118 -0) 📝 `frontend/src/schemas/setting.ts` (+23 -0) ➕ `frontend/src/test/happ-presets.test.ts` (+85 -0) ➕ `frontend/src/test/happ-settings-tun-mode.test.tsx` (+72 -0) 📝 `internal/sub/controller.go` (+16 -2) 📝 `internal/sub/endpoint_test.go` (+26 -0) ➕ `internal/sub/happ.go` (+141 -0) ➕ `internal/sub/happ_test.go` (+227 -0) 📝 `internal/sub/remote_routing.go` (+3 -0) 📝 `internal/sub/service.go` (+1 -2) 📝 `internal/sub/sub.go` (+26 -0) _...and 15 more files_ </details> ### 📄 Description ## Summary Adds comprehensive integration and customization for the Happ VPN client according to official Happ developer specifications, including bug fixes for existing settings, routing presets with a visual rule generator, app management headers, and server subtitles. ## Why 1. **Bug fixes in existing options:** - When routing (`subEnableRouting`) or hiding server settings (`subHideSettings`) were toggled off, no headers were emitted. Happ's specification requires explicit `Routing-Enable: 0` and `Hide-Settings: 0` headers to clear cached state on the client. - The `happ://routing/off` deeplink was rejected by `normalizeHappRouting` as invalid JSON. - Server description URL fragments (`#Title?serverDescription=...`) had their `?` and `=` characters percent-escaped by standard URL encoding, breaking Happ's subtitle regex. 2. **Feature parity with Happ developer specifications:** - Enables full provider management (`ProviderID`, `New-Url` for zero-downtime migration, `Fallback-Url`). - Introduces smart in-app announcement banners (`Sub-Info-Text`, `Sub-Info-Color`, buttons) and expiration alerts (`Sub-Expire`, `Notification-Subs-Expire`). - Supports performance and security controls: `No-Limit-Enabled`, `Subscription-Always-Hwid-Enable` (HWID binding). - Exposes network stack options: TUN modes (`system`, `gvisor`), TUN core types (`singbox`, `tun2proxy`, `default`, `xray`), route exclusions, and Apple APNs bypass. - Provides curated routing presets (Iran Bypass, China Direct, AdBlock, Global) and a built-in visual deeplink generator in the UI. ## Type of change - [x] Bug fix - [x] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [x] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [x] Frontend (UI / panel pages) - [x] Backend (API endpoints, login, settings) - [ ] Xray config generation - [x] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? - **Go unit tests:** Added `internal/sub/happ_test.go` verifying header injection, `happ://routing/off` preservation, preset deeplink builders, and subtitle fragment escaping. - **Frontend unit tests:** Added `frontend/src/test/happ-presets.test.ts` verifying all presets, Base64 UTF-8 encoding, and parser helpers (7/7 tests passed). - **i18n parity:** Ran `i18n-dead-keys.test.ts` ensuring all 13 locale files in `internal/web/translation/` are fully synchronized with zero dead or orphan keys. - **TypeScript & Linting:** Validated with `npm run typecheck` (0 errors) and `oxlint src tools` (0 errors across 536 files). - **Build verification:** Verified production Vite build into `internal/web/dist/`. ## Screenshots / recordings *(Optional: You can take a screenshot of Settings -> Subscription -> Happ tab and drag & drop it here)* ## Breaking changes None. All new fields default to safe/empty values, and existing non-Happ clients are completely unaffected. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [x] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:07:32 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6268
No description provided.