mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6545] [MERGED] feat(happ): add routing editor, optional ad blocking, and LAN bypass preset #6342
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#6342
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6545
Author: @NgaiYeanCoi
Created: 9/15/2026
Status: ✅ Merged
Merged: 9/26/2026
Merged by: @MHSanaei
Base:
main← Head:feat/happ-presets-adblock📝 Commits (8)
8f7f8e2feat(happ): make ad blocking optional in routing presets72282effeat: add visual routing editor with JSON support and localization updates5e249ceMerge branch 'main' into feat/happ-presets-adblockf0ce53afeat: update routing editor to preserve null lists in profiles and enhance validation messages12bbc96Merge branch 'feat/happ-presets-adblock' of github.com:NgaiYeanCoi/3x-ui into feat/happ-presets-adblock940cee7Merge branch 'main' into feat/happ-presets-adblocka223e98Merge branch 'main' into feat/happ-presets-adblocka6a28f9Merge branch 'main' into feat/happ-presets-adblock📊 Changes
22 files changed (+1356 additions, -202 deletions)
View changed files
➕
frontend/src/pages/settings/HappRoutingEditorModal.tsx(+204 -0)📝
frontend/src/pages/settings/HappSettingsContent.tsx(+28 -104)📝
frontend/src/pages/settings/happPresets.ts(+57 -27)➕
frontend/src/pages/settings/happRoutingEditor.ts(+90 -0)➕
frontend/src/schemas/happRouting.ts(+16 -0)📝
frontend/src/test/happ-presets.test.ts(+77 -19)➕
frontend/src/test/happ-routing-editor-helpers.test.ts(+156 -0)➕
frontend/src/test/happ-routing-editor.test.tsx(+322 -0)➕
frontend/src/test/happ-settings-presets.test.tsx(+211 -0)📝
internal/web/translation/ar-EG.json(+15 -4)📝
internal/web/translation/en-US.json(+15 -4)📝
internal/web/translation/es-ES.json(+15 -4)📝
internal/web/translation/fa-IR.json(+15 -4)📝
internal/web/translation/id-ID.json(+15 -4)📝
internal/web/translation/ja-JP.json(+15 -4)📝
internal/web/translation/pt-BR.json(+15 -4)📝
internal/web/translation/ru-RU.json(+15 -4)📝
internal/web/translation/tr-TR.json(+15 -4)📝
internal/web/translation/uk-UA.json(+15 -4)📝
internal/web/translation/vi-VN.json(+15 -4)...and 2 more files
📄 Description
Summary
Adds basic and advanced JSON editing for existing Happ routing profiles, optional ad blocking, and a separate Global Bypass Local Network preset.
add/onaddmode when editing.Why
The previous rule generator started from empty lists. Editing an existing profile therefore required manually decoding its link and carrying over settings such as DNS configuration, routing strategy, and custom fields.
Ad blocking was also bundled into the Iran and China presets, while a separate AdBlock preset represented another routing configuration. This made it difficult to choose a routing policy and independently decide whether to include ad blocking.
During the preset review, I used the v2rayNG routing presets as references for private-network and regional bypass rules . The resulting profiles use Happ's routing format and retain a separate choice for users who want global proxying with local-network access.
1. Routing presets and optional ad blocking
IPIfNonMatchIPIfNonMatchAsIsgeosite:privateandgeoip:privateAsIsAll four profiles use
GlobalProxy: "true"as the proxy fallback. Explicit direct rules provide the bypass behavior.The LAN preset uses a separate
lan-bypassidentifier in the panel and the profile nameGlobal Bypass Local Network, avoiding a name collision with the existingGlobal Proxyprofile.Include AdBlock defaults to off. Enabling it adds:
The switch is a generator option. Its effect is stored in the generated profile when the page is saved.
The standalone AdBlock preset is removed. Off continues to generate
happ://routing/off, with the AdBlock control disabled.2. Regional preset adjustments
The Iran preset uses
domain:irtogether withgeosite:category-irand private-network rules. This replaces the previous.irregular expression.The China profile is special optimize generated as
Bypass-CNand includes:IPIfNonMatch, disabled FakeDNS, and enabled chunk files.Profiles for other regions require dedicated optimization by other contributors.
Both regional presets explicitly use
RouteOrder: "block-proxy-direct".3. Preserving fields during editing
The Basic rules tab exposes the six domain and IP lists for direct, proxy, and block routing.
Only edited lists are replaced. Untouched lists, absent fields, DNS settings, and unknown extension fields survive regeneration. Preservation applies to profile values; JSON formatting and Base64 representation may normalize.
The Advanced editor exposes the complete JSON object. Switching between tabs synchronizes valid changes in both directions.
Invalid JSON prevents generation and switching back to Basic rules until it is corrected.
4. Validation and compatibility boundaries
Validation checks that the profile is a JSON object and that each supported routing list, when present, is an array of strings.
Other Happ fields and extension values are preserved without full semantic validation. The editor does not verify individual rule syntax, geodata availability, DNS reachability, or the resulting traffic behavior.
Private-network matching depends on the geodata available to the Happ client. Automated frontend tests cover generated payloads and editor behavior.
Type of change
Areas affected
How was this tested?
Screenshots / recordings
Breaking changes
None
Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.