[PR #6810] [MERGED] fix(sub): isolate Incy subscription routing from Happ headers #6461

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6810
Author: @mvanhorn
Created: 10/13/2026
Status: ✅ Merged
Merged: 10/13/2026
Merged by: @MHSanaei

Base: main ← Head: fix/6062-incy-client-routing-isolation


📝 Commits (2)

  • 1f6155c sub: isolate Incy subscription routing from Happ headers
  • c9d3b67 fix(sub): keep the shared JSON routing profile for INCY clients

📊 Changes

2 files changed (+67 additions, -2 deletions)

View changed files

📝 internal/sub/controller.go (+12 -2)
📝 internal/sub/controller_test.go (+55 -0)

📄 Description

Summary

The resolved Incy line is written to the body only when IsIncyClient matches the subscription User-Agent, Incy routing is enabled, and the resolved text is non-blank. ApplyCommonHeaders computes that same Incy check once and, for a matching client, skips the Happ routing-header block, leaving Routing-Enable, the Happ Routing value, and the JSON routing header unset. ApplyIncyHeaders is called with that incyClient flag. The new test requests the subscription as INCY/1.0.0/ios and as Happ/1.2.0 and expects the Incy response to end with the incy:// line and to have empty Routing headers, and the Happ response to keep the happ:// Routing header with Routing-Enable true and no incy:// line in the body.

Closes #6062

Why

With both routing features enabled, every subscription response carries Happ's Routing and Routing-Enable headers, and the Incy rules are appended to that same body for every caller. An Incy client therefore loads the Happ profile from the header. A Happ client receives the incy:// line in the body alongside its own Routing header. ApplyCommonHeaders resolved the Happ routing source on every response and set Routing-Enable and Routing from it, and when the Happ rule string was empty it substituted the JSON routing header. The subs handler appended subIncyRoutingRules whenever Incy routing was enabled and the stored rules were non-empty. Neither write consulted the request User-Agent, so the Happ headers and the Incy body line were emitted together.

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?

gofmt -l printed no filenames for the subscription controller, its test, and the remote routing test.
go vet ./internal/sub/... printed no diagnostics.
go test ./internal/sub/... passed.
The tests in internal/sub/controller_test.go fail without the fix (checked by reverting the source changes).

Screenshots / recordings

No user-visible surface changes in this PR, so there is nothing to show.

Breaking changes

Covered in the summary above.

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.
    Not claimed: go build ./... is a different command from the local runs that passed, gofmt, go vet and go test.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
    Not claimed: npm run lint is a different command from the local runs that passed, gofmt, go vet and go test.
  • 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.

AI disclosure

AI was used for assistance.

  • Tools: Grok.

🔄 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/6810 **Author:** [@mvanhorn](https://github.com/mvanhorn) **Created:** 10/13/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/6062-incy-client-routing-isolation` --- ### 📝 Commits (2) - [`1f6155c`](https://github.com/MHSanaei/3x-ui/commit/1f6155cc447e5856b537c3dd67c9faabc1381a34) sub: isolate Incy subscription routing from Happ headers - [`c9d3b67`](https://github.com/MHSanaei/3x-ui/commit/c9d3b67c541b5779ce57313ce97cee2186bd9a22) fix(sub): keep the shared JSON routing profile for INCY clients ### 📊 Changes **2 files changed** (+67 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `internal/sub/controller.go` (+12 -2) 📝 `internal/sub/controller_test.go` (+55 -0) </details> ### 📄 Description ## Summary The resolved Incy line is written to the body only when IsIncyClient matches the subscription User-Agent, Incy routing is enabled, and the resolved text is non-blank. ApplyCommonHeaders computes that same Incy check once and, for a matching client, skips the Happ routing-header block, leaving Routing-Enable, the Happ Routing value, and the JSON routing header unset. ApplyIncyHeaders is called with that incyClient flag. The new test requests the subscription as INCY/1.0.0/ios and as Happ/1.2.0 and expects the Incy response to end with the incy:// line and to have empty Routing headers, and the Happ response to keep the happ:// Routing header with Routing-Enable true and no incy:// line in the body. Closes #6062 ## Why With both routing features enabled, every subscription response carries Happ's Routing and Routing-Enable headers, and the Incy rules are appended to that same body for every caller. An Incy client therefore loads the Happ profile from the header. A Happ client receives the incy:// line in the body alongside its own Routing header. ApplyCommonHeaders resolved the Happ routing source on every response and set Routing-Enable and Routing from it, and when the Happ rule string was empty it substituted the JSON routing header. The subs handler appended subIncyRoutingRules whenever Incy routing was enabled and the stored rules were non-empty. Neither write consulted the request User-Agent, so the Happ headers and the Incy body line were emitted together. ## Type of change - [x] 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? gofmt -l printed no filenames for the subscription controller, its test, and the remote routing test. go vet ./internal/sub/... printed no diagnostics. go test ./internal/sub/... passed. The tests in `internal/sub/controller_test.go` fail without the fix (checked by reverting the source changes). ## Screenshots / recordings No user-visible surface changes in this PR, so there is nothing to show. ## Breaking changes Covered in the summary above. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [ ] `go build ./...` and the test suite pass locally. Not claimed: `go build ./...` is a different command from the local runs that passed, `gofmt`, `go vet` and `go test`. - [ ] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. Not claimed: `npm run lint` is a different command from the local runs that passed, `gofmt`, `go vet` and `go test`. - [ ] 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. **AI disclosure** AI was used for assistance. - Tools: Grok. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:08:57 +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#6461
No description provided.