fix(sub): advertise routable inbound Listen in subscription links

resolveInboundAddress stopped using the inbound's bind Listen in 3.2.5/3.2.6, so a per-inbound Address/IP no longer appeared in generated subscription/share links - they always used the host the subscriber reached the panel on. The frontend QR path still honored Listen, so the panel and the subscription disagreed (issue #4798).

Restore advertising Listen when it is a routable host (real IP or hostname), reusing isRoutableHost and excluding unix-domain sockets. Loopback/wildcard binds still fall back to the subscriber host, keeping the earlier loopback-leak fix intact. Precedence is now node address > routable Listen > subscriber host; External Proxy still overrides everything.

Closes #4798
This commit is contained in:
MHSanaei
2026-06-02 22:01:43 +02:00
parent f901cd42a5
commit a40d85ce53
2 changed files with 29 additions and 11 deletions
+11 -4
View File
@@ -713,16 +713,23 @@ func (s *SubService) loadNodes() {
s.nodesByID = m
}
// resolveInboundAddress returns the node's address for node-managed inbounds,
// otherwise the subscriber's host (s.address). The inbound's bind Listen is
// deliberately ignored: it's a server-side address, not a client-reachable
// host, so operators advertise a specific endpoint via External Proxy instead.
// resolveInboundAddress picks the host an external client should connect to:
// 1. node-managed inbound -> the node's address
// 2. an explicit, client-reachable bind Listen -> that Listen
// 3. otherwise the subscriber's request host (s.address)
// A loopback/wildcard bind or a unix-domain-socket listen is a server-side
// detail and is never advertised; External Proxy remains the way to advertise
// an arbitrary endpoint. Mirrors the frontend's resolveAddr so the panel QR and
// the subscription agree.
func (s *SubService) resolveInboundAddress(inbound *model.Inbound) string {
if inbound.NodeID != nil && s.nodesByID != nil {
if n, ok := s.nodesByID[*inbound.NodeID]; ok && n.Address != "" {
return n.Address
}
}
if listen := inbound.Listen; listen != "" && listen[0] != '@' && listen[0] != '/' && isRoutableHost(listen) {
return listen
}
return s.address
}