mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5161] [Feature]: Configure share address strategy for node-managed inbounds #3628
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#3628
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?
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.example.com203.0.113.10203.0.113.11When exporting links from the master panel, both inbounds use
node.example.comas 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:
sub/subService.go,SubService.resolveInboundAddress()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:
Alternatives you've considered
Changing the default priority to prefer
inbound.listenwould 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:
203.0.113.10203.0.113.11Both 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:
Node address/Inbound listen/Auto/CustomCustomis selectedA possible backend behavior:
Which parts of the panel would this affect?
Are you willing to help?
Before submitting
@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.goresolveInboundAddress()(line 781):Frontend —
frontend/src/lib/xray/inbound-link.tsresolveAddr()(line 787):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
Inboundindatabase/model/model.go:The values could be
"node"(default — preserves current behaviour),"listen","auto","custom".A GORM auto-migration entry in
database/db.go(look for the existingAutoMigratecall) would add the columns automatically on startup.2. Backend address resolver (
sub/subService.go)Replace the hard-coded priority in
resolveInboundAddress()with a switch oninbound.ShareAddrStrategy:"node"— existing node → listen → request-host chain"listen"— routable listen, then fall back to node address"custom"—inbound.ShareAddrwhen non-empty, then node address as fallback"auto"— prefer routable listen, then node address, then request hostThe same resolver is used by
GetSubs,GetJson(viasub/subJsonService.go), andGetClash(viasub/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 acceptshostOverride(the node address) andfallbackHostname; you'd readinbound.shareAddrStrategyandinbound.shareAddrto decide which wins.4. Frontend inbound form
Add the strategy selector and the conditional custom-address input to the inbound creation/edit form. The
shareAddrStrategyfield can default to"node"so existing inbounds behave exactly as today.5. Node sync propagation
The new fields live on the
Inboundrow 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 inweb/service/node.go— worth checking that a sync does not stomp the locally configuredshareAddrStrategy.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.
@MHSanaei commented on GitHub (Jun 12, 2026):
Implemented via the inbound share address strategy (
2a7342ba) plusc47a905a, 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.