[GH-ISSUE #5161] [Feature]: Configure share address strategy for node-managed inbounds #3628

Closed
opened 2026-10-31 20:33:49 +07:00 by bsakaguchi · 2 comments
Owner

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

Yes. In multi-node deployments, share links and subscription links for node-managed inbounds currently prefer the node panel address over the inbound's own listen address.

This is a problem when one sub-node exposes multiple inbounds through different public IPs.

Example:

  • Node panel address: node.example.com
  • Inbound A listen address: 203.0.113.10
  • Inbound B listen address: 203.0.113.11

When exporting links from the master panel, both inbounds use node.example.com as the link address. There is no explicit way to choose the inbound listen address or a custom address per inbound.

Current code paths appear to make the node address win before the inbound listen address is considered:

  • Backend subscriptions: sub/subService.go, SubService.resolveInboundAddress()
  • Frontend share links and QR codes: frontend/src/lib/xray/inbound-link.ts, resolveAddr()

There are related reports and requests around generated link addresses, but this request is specifically about making the address selection explicit for node-managed inbounds and multi-IP nodes: #4029, #4798, #4944, #4949, #5043.

Describe the solution you'd like

Add an explicit share address strategy for generated share links, QR codes, raw subscriptions, Clash subscriptions, and JSON subscriptions.

Suggested per-inbound options:

  • node: use the node panel address. This preserves the current behavior.
  • listen: use the inbound listen address when it is externally reachable.
  • auto: prefer a routable inbound listen address, otherwise fall back to the node address.
  • custom: use a manually configured share address for this inbound.

The setting should be available per inbound, because a single node can host multiple inbounds that must advertise different public IPs or domains.

The default should preserve existing behavior to avoid breaking current users.

Expected coverage:

  • Panel exported share links
  • Client information modal links
  • QR code links
  • Raw subscription links
  • JSON subscription output
  • Clash subscription output

Alternatives you've considered

Changing the default priority to prefer inbound.listen would fix multi-IP node setups, but it could break users who rely on the current node-address behavior.

External proxy can solve some cases, but it is heavier than needed when the only requirement is selecting the address used in generated links.

A global setting would not be enough, because different inbounds on the same node can need different advertised addresses.

Concrete use case

A master panel manages one sub-node. The sub-node has two public IPs and two inbounds:

  • VLESS inbound A bound to 203.0.113.10
  • VLESS inbound B bound to 203.0.113.11

Both inbounds belong to the same node, but clients must connect to different IPs. The current node-level address cannot represent both endpoints.

Mockups, screenshots, or examples

A possible UI shape in the inbound form:

  • Share address strategy: Node address / Inbound listen / Auto / Custom
  • Custom share address: shown only when Custom is selected

A possible backend behavior:

node   -> node.address, then request/public host fallback
listen -> routable inbound.listen, then node.address fallback
custom -> inbound custom share address, then node.address fallback
auto   -> routable inbound.listen, then node.address, then request/public host fallback

Which parts of the panel would this affect?

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Subscription (share links / Clash / JSON)
  • Database / migrations
  • Multi-node (sub-nodes)

Are you willing to help?

  • I'd like to implement this feature myself and open a PR.
  • I can help test once a PR is open.

Before submitting

  • I searched existing issues and this feature has not been requested.
  • This feature request is written in English.
Originally created by @yuanzhidao on GitHub (Jun 10, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5161 ### Is your feature request related to a problem? Yes. In multi-node deployments, share links and subscription links for node-managed inbounds currently prefer the node panel address over the inbound's own listen address. This is a problem when one sub-node exposes multiple inbounds through different public IPs. Example: - Node panel address: `node.example.com` - Inbound A listen address: `203.0.113.10` - Inbound B listen address: `203.0.113.11` When exporting links from the master panel, both inbounds use `node.example.com` as the link address. There is no explicit way to choose the inbound listen address or a custom address per inbound. Current code paths appear to make the node address win before the inbound listen address is considered: - Backend subscriptions: `sub/subService.go`, `SubService.resolveInboundAddress()` - Frontend share links and QR codes: `frontend/src/lib/xray/inbound-link.ts`, `resolveAddr()` There are related reports and requests around generated link addresses, but this request is specifically about making the address selection explicit for node-managed inbounds and multi-IP nodes: #4029, #4798, #4944, #4949, #5043. ### Describe the solution you'd like Add an explicit share address strategy for generated share links, QR codes, raw subscriptions, Clash subscriptions, and JSON subscriptions. Suggested per-inbound options: - `node`: use the node panel address. This preserves the current behavior. - `listen`: use the inbound listen address when it is externally reachable. - `auto`: prefer a routable inbound listen address, otherwise fall back to the node address. - `custom`: use a manually configured share address for this inbound. The setting should be available per inbound, because a single node can host multiple inbounds that must advertise different public IPs or domains. The default should preserve existing behavior to avoid breaking current users. Expected coverage: - Panel exported share links - Client information modal links - QR code links - Raw subscription links - JSON subscription output - Clash subscription output ### Alternatives you've considered Changing the default priority to prefer `inbound.listen` would fix multi-IP node setups, but it could break users who rely on the current node-address behavior. External proxy can solve some cases, but it is heavier than needed when the only requirement is selecting the address used in generated links. A global setting would not be enough, because different inbounds on the same node can need different advertised addresses. ### Concrete use case A master panel manages one sub-node. The sub-node has two public IPs and two inbounds: - VLESS inbound A bound to `203.0.113.10` - VLESS inbound B bound to `203.0.113.11` Both inbounds belong to the same node, but clients must connect to different IPs. The current node-level address cannot represent both endpoints. ### Mockups, screenshots, or examples A possible UI shape in the inbound form: - Share address strategy: `Node address` / `Inbound listen` / `Auto` / `Custom` - Custom share address: shown only when `Custom` is selected A possible backend behavior: ```text node -> node.address, then request/public host fallback listen -> routable inbound.listen, then node.address fallback custom -> inbound custom share address, then node.address fallback auto -> routable inbound.listen, then node.address, then request/public host fallback ``` ### Which parts of the panel would this affect? - Frontend (UI / panel pages) - Backend (API endpoints, login, settings) - Subscription (share links / Clash / JSON) - Database / migrations - Multi-node (sub-nodes) ### Are you willing to help? - [x] I'd like to implement this feature myself and open a PR. - [x] I can help test once a PR is open. ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this feature has not been requested. - [x] This feature request is written in English.
bsakaguchi 2026-10-31 20:33:49 +07:00
Author
Owner

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

Thanks for the detailed write-up and for tracing the code paths — everything you describe matches what the code actually does.

Current behaviour (verified in v3.3.0)

Backend — sub/subService.go resolveInboundAddress() (line 781):

1. inbound.NodeID \!= nil  → node.Address
2. inbound.Listen is a routable non-unix-socket address → that listen
3. otherwise → subscriber's request host (s.address)

Frontend — frontend/src/lib/xray/inbound-link.ts resolveAddr() (line 787):

1. hostOverride non-empty (caller passes node address for node-managed inbounds) → that override
2. inbound.listen non-empty, not 0.0.0.0, not unix socket → that listen
3. otherwise → window.location.hostname

The node address unconditionally wins at step 1 in both paths. There is no existing per-inbound strategy field.

What a PR would need to touch

1. Database model and migration

Add two fields to Inbound in database/model/model.go:

ShareAddrStrategy string `json:"shareAddrStrategy" form:"shareAddrStrategy" gorm:"default:node"`
ShareAddr         string `json:"shareAddr"         form:"shareAddr"`

The values could be "node" (default — preserves current behaviour), "listen", "auto", "custom".

A GORM auto-migration entry in database/db.go (look for the existing AutoMigrate call) would add the columns automatically on startup.

2. Backend address resolver (sub/subService.go)

Replace the hard-coded priority in resolveInboundAddress() with a switch on inbound.ShareAddrStrategy:

  • "node" — existing node → listen → request-host chain
  • "listen" — routable listen, then fall back to node address
  • "custom" — inbound.ShareAddr when non-empty, then node address as fallback
  • "auto" — prefer routable listen, then node address, then request host

The same resolver is used by GetSubs, GetJson (via sub/subJsonService.go), and GetClash (via sub/subClashService.go), so fixing it in one place covers all three subscription formats.

Update resolveAddr() to respect the new strategy field from the inbound schema. The function signature already accepts hostOverride (the node address) and fallbackHostname; you'd read inbound.shareAddrStrategy and inbound.shareAddr to decide which wins.

4. Frontend inbound form

Add the strategy selector and the conditional custom-address input to the inbound creation/edit form. The shareAddrStrategy field can default to "node" so existing inbounds behave exactly as today.

5. Node sync propagation

The new fields live on the Inbound row in the master panel's DB. Because node-synced inbounds are created/updated from the JSON the sub-node returns, the fields need to round-trip: either the master preserves them during the update (i.e. does not overwrite with the node's value), or the UI explicitly writes them back. The existing node sync logic is in web/service/node.go — worth checking that a sync does not stomp the locally configured shareAddrStrategy.

#4891 covers a similar request from a CDN/SNI angle. The two features are complementary — if you implement the strategy approach from this issue, #4891's use case would be covered by "custom".

Good luck with the PR — the scope is well-defined and the code paths you cited are the right ones.

<!-- gh-comment-id:4669193357 --> @github-actions[bot] commented on GitHub (Jun 10, 2026): Thanks for the detailed write-up and for tracing the code paths — everything you describe matches what the code actually does. ## Current behaviour (verified in v3.3.0) **Backend** — `sub/subService.go` `resolveInboundAddress()` (line 781): ``` 1. inbound.NodeID \!= nil → node.Address 2. inbound.Listen is a routable non-unix-socket address → that listen 3. otherwise → subscriber's request host (s.address) ``` **Frontend** — `frontend/src/lib/xray/inbound-link.ts` `resolveAddr()` (line 787): ``` 1. hostOverride non-empty (caller passes node address for node-managed inbounds) → that override 2. inbound.listen non-empty, not 0.0.0.0, not unix socket → that listen 3. otherwise → window.location.hostname ``` The node address unconditionally wins at step 1 in both paths. There is no existing per-inbound strategy field. ## What a PR would need to touch ### 1. Database model and migration Add two fields to `Inbound` in `database/model/model.go`: ```go ShareAddrStrategy string `json:"shareAddrStrategy" form:"shareAddrStrategy" gorm:"default:node"` ShareAddr string `json:"shareAddr" form:"shareAddr"` ``` The values could be `"node"` (default — preserves current behaviour), `"listen"`, `"auto"`, `"custom"`. A GORM auto-migration entry in `database/db.go` (look for the existing `AutoMigrate` call) would add the columns automatically on startup. ### 2. Backend address resolver (`sub/subService.go`) Replace the hard-coded priority in `resolveInboundAddress()` with a switch on `inbound.ShareAddrStrategy`: - `"node"` — existing node → listen → request-host chain - `"listen"` — routable listen, then fall back to node address - `"custom"` — `inbound.ShareAddr` when non-empty, then node address as fallback - `"auto"` — prefer routable listen, then node address, then request host The same resolver is used by `GetSubs`, `GetJson` (via `sub/subJsonService.go`), and `GetClash` (via `sub/subClashService.go`), so fixing it in one place covers all three subscription formats. ### 3. Frontend link builder (`frontend/src/lib/xray/inbound-link.ts`) Update `resolveAddr()` to respect the new strategy field from the inbound schema. The function signature already accepts `hostOverride` (the node address) and `fallbackHostname`; you'd read `inbound.shareAddrStrategy` and `inbound.shareAddr` to decide which wins. ### 4. Frontend inbound form Add the strategy selector and the conditional custom-address input to the inbound creation/edit form. The `shareAddrStrategy` field can default to `"node"` so existing inbounds behave exactly as today. ### 5. Node sync propagation The new fields live on the `Inbound` row in the master panel's DB. Because node-synced inbounds are created/updated from the JSON the sub-node returns, the fields need to round-trip: either the master preserves them during the update (i.e. does not overwrite with the node's value), or the UI explicitly writes them back. The existing node sync logic is in `web/service/node.go` — worth checking that a sync does not stomp the locally configured `shareAddrStrategy`. ## Related #4891 covers a similar request from a CDN/SNI angle. The two features are complementary — if you implement the strategy approach from this issue, #4891's use case would be covered by `"custom"`. Good luck with the PR — the scope is well-defined and the code paths you cited are the right ones.
Author
Owner

@MHSanaei commented on GitHub (Jun 12, 2026):

Implemented via the inbound share address strategy (2a7342ba) plus c47a905a, which offers the node share-address strategy only when a node exists. You can now configure, per inbound, whether exported links/subscriptions use the node address, the listen address, or a custom address. Will be in the next release.

<!-- gh-comment-id:4686423811 --> @MHSanaei commented on GitHub (Jun 12, 2026): Implemented via the inbound share address strategy (2a7342ba) plus c47a905a, which offers the node share-address strategy only when a node exists. You can now configure, per inbound, whether exported links/subscriptions use the node address, the listen address, or a custom address. Will be in the next release.
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#3628
No description provided.