[GH-ISSUE #5585] Happ: scoped "Hide server settings" with email-based allowlist/blocklist #3901

Open
opened 2026-10-31 20:35:46 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @acidmsg on GitHub (Jun 26, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5585

Problem:
subHideSettings is a global boolean flag. Hide-Settings: 1 header is either applied to all subscription responses, or none. Selective application (some clients see full server config, others get a locked-down profile) is impossible.

Proposed solution:
Replace the binary toggle with a filter supporting two modes: blocklist (hide for selected) and allowlist (hide for everyone EXCEPT selected). Input field uses the same chip/tag UX already present across the panel (comma-separated values, each rendered as a removable chip — like Telegram chat IDs, trusted IPs, etc.).

Behavior at subscription request time:

subHideEnabled == false → header not set
subHideEnabled == true && filter empty → Hide-Settings: 1 for everyone (current behavior)
subHideEnabled == true && mode == blocklist → Hide-Settings: 1 for emails in filter
subHideEnabled == true && mode == allowlist → Hide-Settings: 1 for everyone EXCEPT emails in filter

Group resolution:
When a group is selected in the filter, it is resolved to its current members at request time (getSubs()). Members added to the group later are automatically covered on their next subscription request — no panel settings change needed.

Migration:
The old subHideSettings (bool) is superseded. On startup after upgrade:

  • subHideSettings == true → subHideEnabled = true, subHideFilter = "" (empty filter → hide for all)
  • subHideSettings == false → subHideEnabled = false

No backward compatibility needed — HTTP headers are served identically.

Where to change:

  • settings: rename subHideSettings → subHideEnabled (bool), add subHideFilter (string, new: JSON {mode, entries})
  • Migration on startup: convert old subHideSettings to new format
  • controller.go:subs(): after getSubs(), check client emails against filter before calling ApplyCommonHeaders
  • UI: Subscription → Happ tab — radio (blocklist/allowlist) + chip input field with autocomplete from DB
  • Locales: en, ru, and others

Why email-based:
getSubs() already returns emails []string. Email-based matching requires zero changes to the method signature. Using client/group IDs would require extending the return value of getSubs().

Originally created by @acidmsg on GitHub (Jun 26, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5585 **Problem:** `subHideSettings` is a global boolean flag. `Hide-Settings: 1` header is either applied to all subscription responses, or none. Selective application (some clients see full server config, others get a locked-down profile) is impossible. **Proposed solution:** Replace the binary toggle with a filter supporting two modes: **blocklist** (hide for selected) and **allowlist** (hide for everyone EXCEPT selected). Input field uses the same chip/tag UX already present across the panel (comma-separated values, each rendered as a removable chip — like Telegram chat IDs, trusted IPs, etc.). **Behavior at subscription request time:** ``` subHideEnabled == false → header not set subHideEnabled == true && filter empty → Hide-Settings: 1 for everyone (current behavior) subHideEnabled == true && mode == blocklist → Hide-Settings: 1 for emails in filter subHideEnabled == true && mode == allowlist → Hide-Settings: 1 for everyone EXCEPT emails in filter ``` **Group resolution:** When a group is selected in the filter, it is resolved to its current members at request time (`getSubs()`). Members added to the group later are automatically covered on their next subscription request — no panel settings change needed. **Migration:** The old `subHideSettings` (bool) is superseded. On startup after upgrade: - `subHideSettings == true` → `subHideEnabled = true`, `subHideFilter = ""` (empty filter → hide for all) - `subHideSettings == false` → `subHideEnabled = false` No backward compatibility needed — HTTP headers are served identically. **Where to change:** - **`settings`:** rename `subHideSettings` → `subHideEnabled` (bool), add `subHideFilter` (string, new: JSON `{mode, entries}`) - **Migration on startup:** convert old `subHideSettings` to new format - **`controller.go:subs()`:** after `getSubs()`, check client `emails` against filter before calling `ApplyCommonHeaders` - **UI:** Subscription → Happ tab — radio (blocklist/allowlist) + chip input field with autocomplete from DB - **Locales:** `en`, `ru`, and others **Why email-based:** `getSubs()` already returns `emails []string`. Email-based matching requires zero changes to the method signature. Using client/group IDs would require extending the return value of `getSubs()`.
Author
Owner

@github-actions[bot] commented on GitHub (Jun 26, 2026):

The technical analysis is accurate. Confirmed against the current source:

subHideSettings is a global bool stored in the settings table with a default of false (internal/web/service/setting.go:81). GetSubHideSettings() (line 712) returns it as a single value. It is passed into SUBController at initialization time alongside every other sub setting (internal/sub/sub.go:245), stored in the struct as subHideSettings bool (internal/sub/controller.go:51), and forwarded unchanged to every ApplyCommonHeaders() call (internal/sub/controller.go:194, 378, 395). ApplyCommonHeaders sets Hide-Settings: 1 unconditionally when the field is true (internal/sub/controller.go:439-440). There is currently no per-client or per-email gate.

getSubs() does return emails []string as its second return value (internal/sub/service.go:180). The emails are populated per-matched client (lines 219, 230) and are available in the subs() handler immediately after the call (line 159), before ApplyCommonHeaders is invoked (line 194). The filtering logic proposed could be inserted at that point with no change to getSubs()'s signature.

Client groups exist in the data model — ClientRecord.Group (internal/database/model/model.go:626) and the client_groups table (ClientGroup, line 635-642). Group-to-email resolution would require a DB query at subscription request time; this is feasible but adds latency per request when a group entry is present in the filter.

One architectural note not addressed in the proposal: SUBController is constructed once at sub-server startup, receiving all settings as constructor arguments. New fields (subHideEnabled, subHideFilter) would follow the same pattern — they would be read from the DB at sub-server initialization and would not reflect settings changes until the sub server is reloaded (which already happens for other setting changes via the existing reload mechanism). This is not a blocker, just something the implementation must account for when wiring up the new fields.

Migration note: the proposal's migration — subHideSettings == true → subHideEnabled = true, subHideFilter = "" (hide for all, preserving current behavior) — is correct and backward-compatible from an HTTP standpoint. The old key can be retired after the migration step runs on startup.

A PR that implements this would need changes in at minimum:

  • internal/web/service/setting.go — new defaults and accessors for subHideEnabled and subHideFilter
  • internal/database/ — startup migration from subHideSettings
  • internal/sub/controller.go — new struct fields, new constructor params, per-email check before ApplyCommonHeaders
  • internal/sub/sub.go — pass the new fields at construction
  • internal/web/translation/ — new i18n keys for all 13 locale files
  • frontend/src/ — UI for the new radio + chip input on the Happ tab
  • tools/openapigen/ or the generated spec — schema update for the two new settings fields

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4808597782 --> @github-actions[bot] commented on GitHub (Jun 26, 2026): The technical analysis is accurate. Confirmed against the current source: **`subHideSettings` is a global bool** stored in the settings table with a default of `false` (`internal/web/service/setting.go:81`). `GetSubHideSettings()` (line 712) returns it as a single value. It is passed into `SUBController` at initialization time alongside every other sub setting (`internal/sub/sub.go:245`), stored in the struct as `subHideSettings bool` (`internal/sub/controller.go:51`), and forwarded unchanged to every `ApplyCommonHeaders()` call (`internal/sub/controller.go:194, 378, 395`). `ApplyCommonHeaders` sets `Hide-Settings: 1` unconditionally when the field is `true` (`internal/sub/controller.go:439-440`). There is currently no per-client or per-email gate. **`getSubs()` does return `emails []string`** as its second return value (`internal/sub/service.go:180`). The emails are populated per-matched client (lines 219, 230) and are available in the `subs()` handler immediately after the call (line 159), before `ApplyCommonHeaders` is invoked (line 194). The filtering logic proposed could be inserted at that point with no change to `getSubs()`'s signature. **Client groups exist in the data model** — `ClientRecord.Group` (`internal/database/model/model.go:626`) and the `client_groups` table (`ClientGroup`, line 635-642). Group-to-email resolution would require a DB query at subscription request time; this is feasible but adds latency per request when a group entry is present in the filter. **One architectural note not addressed in the proposal:** `SUBController` is constructed once at sub-server startup, receiving all settings as constructor arguments. New fields (`subHideEnabled`, `subHideFilter`) would follow the same pattern — they would be read from the DB at sub-server initialization and would not reflect settings changes until the sub server is reloaded (which already happens for other setting changes via the existing reload mechanism). This is not a blocker, just something the implementation must account for when wiring up the new fields. **Migration note:** the proposal's migration — `subHideSettings == true` → `subHideEnabled = true, subHideFilter = ""` (hide for all, preserving current behavior) — is correct and backward-compatible from an HTTP standpoint. The old key can be retired after the migration step runs on startup. A PR that implements this would need changes in at minimum: - `internal/web/service/setting.go` — new defaults and accessors for `subHideEnabled` and `subHideFilter` - `internal/database/` — startup migration from `subHideSettings` - `internal/sub/controller.go` — new struct fields, new constructor params, per-email check before `ApplyCommonHeaders` - `internal/sub/sub.go` — pass the new fields at construction - `internal/web/translation/` — new i18n keys for all 13 locale files - `frontend/src/` — UI for the new radio + chip input on the Happ tab - `tools/openapigen/` or the generated spec — schema update for the two new settings fields *This reply was generated automatically; a maintainer may follow up.*
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#3901
No description provided.