[PR #6384] [CLOSED] feat: Add opt-in Happ crypt5 generation to the client QR modal #6243

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6384
Author: @NgaiYeanCoi
Created: 9/1/2026
Status: ❌ Closed

Base: main ← Head: feat/happ-links


📝 Commits (10+)

  • 2e45a97 feat(clients): add stateless Happ link generator
  • abb5dfb fix(clients): reject duplicate Happ provider fields
  • 1e86efe feat(clients): expose on-demand Happ link API
  • 11c116b fix(openapi): exclude service interfaces from generated types
  • 59772cd feat(clients): add stateless Happ QR presentation
  • 3b00218 fix(clients): cover overlapping Happ generations
  • 629f2ed fix(clients): harden Happ link handling
  • d1518bb fix(clients): gate Happ link generation behind operator opt-in
  • 2711485 fix(frontend): guard oversized Happ QR codes
  • c7a1fb5 Merge branch 'main' into feat/happ-links

📊 Changes

42 files changed (+2488 additions, -30 deletions)

View changed files

📝 docs/content/docs/en/reference/api/clients.mdx (+8 -1)
📝 docs/public/openapi.json (+69 -0)
📝 frontend/public/openapi.json (+69 -0)
📝 frontend/src/generated/examples.ts (+5 -0)
📝 frontend/src/generated/schemas.ts (+20 -0)
📝 frontend/src/generated/types.ts (+6 -1)
📝 frontend/src/generated/zod.ts (+7 -3)
📝 frontend/src/hooks/useClients.ts (+3 -0)
📝 frontend/src/models/setting.ts (+1 -0)
📝 frontend/src/pages/api-docs/endpoints.ts (+8 -0)
📝 frontend/src/pages/clients/ClientQrModal.tsx (+281 -9)
📝 frontend/src/pages/settings/SubscriptionGeneralTab.tsx (+27 -8)
📝 frontend/src/schemas/defaults.ts (+1 -0)
📝 frontend/src/schemas/setting.ts (+1 -0)
➕ frontend/src/test/client-qr-modal-qr-capacity.test.tsx (+65 -0)
➕ frontend/src/test/client-qr-modal.test.tsx (+576 -0)
📝 frontend/src/test/clients-query-gating.test.tsx (+12 -0)
📝 frontend/src/test/multi-tunnel-client-config.test.tsx (+10 -8)
📝 frontend/src/test/subscription-general-tab.test.tsx (+45 -0)
📝 internal/web/controller/client.go (+18 -0)

...and 22 more files

📄 Description

Summary

  • Adds an optional Happ view to the QR modal for an individual client.
  • Selecting Happ requests a fresh, validated happ://crypt5/ link from the authenticated backend and displays it through the existing QR, copy, and image actions.
  • It generates a fresh, validated happ://crypt5/ link through the authenticated backend without persisting or caching the result, while keeping the Standard subscription view available as the default and fallback.

Why

Administrators currently need to copy a client's complete subscription URL into an external Happ service manually. This change provides a client-scoped workflow in which the browser sends only the client's internal record ID, while the backend reconstructs the current subscription URL and applies bounded provider requests, strict response validation, and redacted diagnostics.

Privacy note: selecting Happ and generating the link sends the client's complete current subscription URL to the third-party service crypto.happ.su.

Fixes #6381
Refs #3902

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?

Frontend Tests

  • npm run lint
  • npm run typecheck
  • npm run build
  • npm run build-storybook
  • npm test -- --project components src/test/client-qr-modal.test.tsx
  • npm test -- --project unit src/test/i18n-dead-keys.test.ts

Backend Tests

  • go build ./...
  • go test ./internal/web/service -run 'Test(Happ|ParseHapp|SanitizeHapp)' -count=1
  • go test ./internal/web/controller -run TestGenerateHappLink -count=1
  • go test ./internal/web -run TestRouteRegistryContract -count=1
  • go test ./tools/openapigen -run TestWalkPackagesExportsAllowedStructsWithoutDIInterfaces -count=1
  • go test ./...
  • make verify
    but shown
[openapi] paths: 184, operations: 191, tags: 13
git diff --exit-code -- frontend/src/generated frontend/public/openapi.json
golangci-lint run
internal\logger\logger.go:85:58: SA4023: this comparison is always true (staticcheck)
                if syslogBackend, err := logging.NewSyslogBackend(""); err != nil {
                                                                       ^
1 issues:
* staticcheck: 1
mingw32-make: *** [Makefile:31: lint-go] Error 1

This PR does not modify internal/logger/logger.go, Makefile, or the golangci-lint configuration, so it does not introduce or alter this warning.

Manual verification

  1. Opened Clients and selected an individual client's QR modal.
  2. Confirmed that Standard is selected initially.
  3. Switched to Happ and confirmed that the generated link and QR use the returned happ://crypt5/ value.
  4. Confirmed that Regenerate performs a fresh request.
  5. Verified that provider failures show a generic Retry state without disabling the Standard subscription view.
  6. Verified that closing or switching clients does not reuse a previous Happ result.

Screenshots / recordings

Standard view

Standard subscription QR view

Happ crypt5 view

Generated Happ crypt5 QR view

Log output for a failed Happ crypt5 generation

image

Breaking changes

None

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/6384 **Author:** [@NgaiYeanCoi](https://github.com/NgaiYeanCoi) **Created:** 9/1/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/happ-links` --- ### 📝 Commits (10+) - [`2e45a97`](https://github.com/MHSanaei/3x-ui/commit/2e45a97f1ece45b761badc546182e38b98432b1f) feat(clients): add stateless Happ link generator - [`abb5dfb`](https://github.com/MHSanaei/3x-ui/commit/abb5dfbd72e2159d2111a961788f99030909d165) fix(clients): reject duplicate Happ provider fields - [`1e86efe`](https://github.com/MHSanaei/3x-ui/commit/1e86efea88e7fcfa1e8b13bc5cc3cecf28983730) feat(clients): expose on-demand Happ link API - [`11c116b`](https://github.com/MHSanaei/3x-ui/commit/11c116bd4625db944aa0049215a609d7d84478a3) fix(openapi): exclude service interfaces from generated types - [`59772cd`](https://github.com/MHSanaei/3x-ui/commit/59772cd0c31e3f0c82f1a33ee22be05d1ca72d9e) feat(clients): add stateless Happ QR presentation - [`3b00218`](https://github.com/MHSanaei/3x-ui/commit/3b0021801b825ba86a73c9fdc99da0527279ae55) fix(clients): cover overlapping Happ generations - [`629f2ed`](https://github.com/MHSanaei/3x-ui/commit/629f2edc84ccdce3436ab719c9a89a9c42806565) fix(clients): harden Happ link handling - [`d1518bb`](https://github.com/MHSanaei/3x-ui/commit/d1518bb010d77437e863c26c626959ded4241e48) fix(clients): gate Happ link generation behind operator opt-in - [`2711485`](https://github.com/MHSanaei/3x-ui/commit/2711485c8b6703dc92e46a5ca26286ef8cd54fb0) fix(frontend): guard oversized Happ QR codes - [`c7a1fb5`](https://github.com/MHSanaei/3x-ui/commit/c7a1fb56d221953a811083761e065cd460a07ccc) Merge branch 'main' into feat/happ-links ### 📊 Changes **42 files changed** (+2488 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/en/reference/api/clients.mdx` (+8 -1) 📝 `docs/public/openapi.json` (+69 -0) 📝 `frontend/public/openapi.json` (+69 -0) 📝 `frontend/src/generated/examples.ts` (+5 -0) 📝 `frontend/src/generated/schemas.ts` (+20 -0) 📝 `frontend/src/generated/types.ts` (+6 -1) 📝 `frontend/src/generated/zod.ts` (+7 -3) 📝 `frontend/src/hooks/useClients.ts` (+3 -0) 📝 `frontend/src/models/setting.ts` (+1 -0) 📝 `frontend/src/pages/api-docs/endpoints.ts` (+8 -0) 📝 `frontend/src/pages/clients/ClientQrModal.tsx` (+281 -9) 📝 `frontend/src/pages/settings/SubscriptionGeneralTab.tsx` (+27 -8) 📝 `frontend/src/schemas/defaults.ts` (+1 -0) 📝 `frontend/src/schemas/setting.ts` (+1 -0) ➕ `frontend/src/test/client-qr-modal-qr-capacity.test.tsx` (+65 -0) ➕ `frontend/src/test/client-qr-modal.test.tsx` (+576 -0) 📝 `frontend/src/test/clients-query-gating.test.tsx` (+12 -0) 📝 `frontend/src/test/multi-tunnel-client-config.test.tsx` (+10 -8) 📝 `frontend/src/test/subscription-general-tab.test.tsx` (+45 -0) 📝 `internal/web/controller/client.go` (+18 -0) _...and 22 more files_ </details> ### 📄 Description ## Summary - Adds an optional Happ view to the QR modal for an individual client. - Selecting Happ requests a fresh, validated `happ://crypt5/` link from the authenticated backend and displays it through the existing QR, copy, and image actions. - It generates a fresh, validated `happ://crypt5/` link through the authenticated backend without persisting or caching the result, while keeping the Standard subscription view available as the default and fallback. <!-- What does this PR do? One or two sentences. --> ## Why <!-- What problem does this solve, or what use case does it enable? Link related issues here: "Closes #123", "Refs #456". --> Administrators currently need to copy a client's complete subscription URL into an external Happ service manually. This change provides a client-scoped workflow in which the browser sends only the client's internal record ID, while the backend reconstructs the current subscription URL and applies bounded provider requests, strict response validation, and redacted diagnostics. Privacy note: selecting Happ and generating the link sends the client's complete current subscription URL to the third-party service `crypto.happ.su`. Fixes #6381 Refs #3902 ## Type of change - [ ] Bug fix - [X] New feature - [ ] Refactoring (no behavior change) - [X] Documentation - [ ] Tests only - [X] 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? <!-- Concrete steps the reviewer can repeat. For UI changes: which page, which actions, which browser. For backend: which endpoint, which payload, which response. Mention any new unit/integration tests added. --> ### Frontend Tests - npm run lint - npm run typecheck - npm run build - npm run build-storybook - npm test -- --project components src/test/client-qr-modal.test.tsx - npm test -- --project unit src/test/i18n-dead-keys.test.ts ### Backend Tests - go build ./... - go test ./internal/web/service -run 'Test(Happ|ParseHapp|SanitizeHapp)' -count=1 - go test ./internal/web/controller -run TestGenerateHappLink -count=1 - go test ./internal/web -run TestRouteRegistryContract -count=1 - go test ./tools/openapigen -run TestWalkPackagesExportsAllowedStructsWithoutDIInterfaces -count=1 - go test ./... - make verify but shown ```bash [openapi] paths: 184, operations: 191, tags: 13 git diff --exit-code -- frontend/src/generated frontend/public/openapi.json golangci-lint run internal\logger\logger.go:85:58: SA4023: this comparison is always true (staticcheck) if syslogBackend, err := logging.NewSyslogBackend(""); err != nil { ^ 1 issues: * staticcheck: 1 mingw32-make: *** [Makefile:31: lint-go] Error 1 ``` This PR does not modify internal/logger/logger.go, Makefile, or the golangci-lint configuration, so it does not introduce or alter this warning. ### Manual verification 1. Opened Clients and selected an individual client's QR modal. 2. Confirmed that Standard is selected initially. 3. Switched to Happ and confirmed that the generated link and QR use the returned happ://crypt5/ value. 4. Confirmed that Regenerate performs a fresh request. 5. Verified that provider failures show a generic Retry state without disabling the Standard subscription view. 6. Verified that closing or switching clients does not reuse a previous Happ result. ## Screenshots / recordings <!-- Required for UI changes. Drag images or GIFs here. Remove if N/A. --> ### Standard view <img width="511" height="680" alt="Standard subscription QR view" src="https://github.com/user-attachments/assets/91e86cc6-1ff9-4e6d-b0eb-b91431596875" /> ### Happ crypt5 view <img width="513" height="712" alt="Generated Happ crypt5 QR view" src="https://github.com/user-attachments/assets/45c7960d-a8d3-4d3b-9a24-d966c0d007b3" /> ### Log output for a failed Happ crypt5 generation <img width="756" height="169" alt="image" src="https://github.com/user-attachments/assets/4383c3a6-e6b2-4f99-b552-c90fa4770b03" /> ## Breaking changes <!-- Does this change require existing users to update their config, run a migration, or change their API calls? If yes, describe the migration path. Write "None" if there are no breaking changes. --> None ## 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:21 +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#6243
No description provided.