[PR #7098] fix(sub): let balancers select inbounds that are hidden from the subscription #6650

Open
opened 2026-11-07 21:42:15 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/7098
Author: @mjbe71
Created: 11/7/2026
Status: 🔄 Open

Base: main ← Head: fix/sub-balancer-hidden-inbounds


📝 Commits (1)

  • f18da47 fix(sub): let balancers select inbounds that are hidden from the subscription

📊 Changes

2 files changed (+171 additions, -15 deletions)

View changed files

📝 internal/sub/json_service.go (+62 -15)
➕ internal/sub/sub_balancer_hidden_test.go (+109 -0)

📄 Description

Problem

An inbound with ExcludeFromSub was skipped before its configs were built, and appendBalancerEntries only reads the inbound entries that reach the output. A hidden inbound could therefore never become a balancer member, although the balancer form lists it.

Design

  • Hidden inbounds that at least one enabled balancer selects are still rendered, but into a separate list that never reaches the output. Hidden inbounds that no balancer selects are skipped as before.
  • Balancers draw members from both lists. The hidden inbound still emits no document of its own, and its clients are still counted in the usage header.
  • Rendering a hidden member neither spends the response budget nor the first-link remark tokens, so what the client sees is unchanged.
  • Hidden members follow the visible ones in member order, so the balancer's first member (the leastPing/leastLoad fallbackTag) stays a visible inbound when there is one.
  • Clash has no balancers, so it needs no change.

Behaviour change

A balancer that selects a hidden inbound now contains its outbound. This only happens when an admin explicitly selects that inbound in a balancer; its outbound (address, credentials) is then visible inside that balancer document.

This also applies to existing data: an inbound that is already hidden and already selected in an enabled balancer starts appearing inside that balancer after the upgrade, without any action from the admin. Previously such a selection was silently ignored.

The balancer document is only served to subscribers who are already clients of that inbound, so this exposes nothing to anyone who did not already have its credentials.

Tests

  • TestSubJson_BalancerMemberFromHiddenInbound (legacy and hosts-first): the hidden inbound appears only inside the balancer doc.
  • TestSubJson_BalancerOfOnlyHiddenInbound: a balancer with only hidden members still renders.
  • TestSubJson_HiddenBalancerMemberKeepsFirstLinkRemark: rendering a hidden member does not swallow the first-link remark tokens.

Written test-first; the first two fail on main for the reported reason, and the third fails if the remark tokens are not restored after rendering a hidden member.


🔄 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/7098 **Author:** [@mjbe71](https://github.com/mjbe71) **Created:** 11/7/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/sub-balancer-hidden-inbounds` --- ### 📝 Commits (1) - [`f18da47`](https://github.com/MHSanaei/3x-ui/commit/f18da477f6504c01312fcd144d95464e83490e1b) fix(sub): let balancers select inbounds that are hidden from the subscription ### 📊 Changes **2 files changed** (+171 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `internal/sub/json_service.go` (+62 -15) ➕ `internal/sub/sub_balancer_hidden_test.go` (+109 -0) </details> ### 📄 Description ## Problem An inbound with ExcludeFromSub was skipped before its configs were built, and appendBalancerEntries only reads the inbound entries that reach the output. A hidden inbound could therefore never become a balancer member, although the balancer form lists it. ## Design - Hidden inbounds that at least one enabled balancer selects are still rendered, but into a separate list that never reaches the output. Hidden inbounds that no balancer selects are skipped as before. - Balancers draw members from both lists. The hidden inbound still emits no document of its own, and its clients are still counted in the usage header. - Rendering a hidden member neither spends the response budget nor the first-link remark tokens, so what the client sees is unchanged. - Hidden members follow the visible ones in member order, so the balancer's first member (the leastPing/leastLoad fallbackTag) stays a visible inbound when there is one. - Clash has no balancers, so it needs no change. ## Behaviour change A balancer that selects a hidden inbound now contains its outbound. This only happens when an admin explicitly selects that inbound in a balancer; its outbound (address, credentials) is then visible inside that balancer document. This also applies to existing data: an inbound that is already hidden and already selected in an enabled balancer starts appearing inside that balancer after the upgrade, without any action from the admin. Previously such a selection was silently ignored. The balancer document is only served to subscribers who are already clients of that inbound, so this exposes nothing to anyone who did not already have its credentials. ## Tests - `TestSubJson_BalancerMemberFromHiddenInbound` (legacy and hosts-first): the hidden inbound appears only inside the balancer doc. - `TestSubJson_BalancerOfOnlyHiddenInbound`: a balancer with only hidden members still renders. - `TestSubJson_HiddenBalancerMemberKeepsFirstLinkRemark`: rendering a hidden member does not swallow the first-link remark tokens. Written test-first; the first two fail on main for the reported reason, and the third fails if the remark tokens are not restored after rendering a hidden member. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#6650
No description provided.