mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-20 12:55:00 +03:00
fix(hosts): advertise Hosts in every WireGuard, AmneziaWG and TUIC config
Invariant: an inbound's enabled Hosts are the endpoints every client config for it advertises, whichever surface renders that config. WireGuard and AmneziaWG broke it. Their raw generators ignored the externalProxy entries Hosts are injected as and always emitted resolveInboundAddress, so the raw subscription, the sub page .conf, the clients links API and "export all links" gave out the panel address while the JSON and Clash formats of the same inbound used the Host. advertisedEndpoints now states the fan-out once for mtproto, wireguard and amneziawg. The browser-built configs had the same gap. The Clients page WireGuard and AmneziaWG config blocks and QR panels, and its TUIC Clash config, used the panel hostname next to server links that already used Hosts; the Inbounds page peer configs, QR and export ignored them too. withMtprotoHostEndpoints becomes withHostEndpoints over a shared hostEndpointsFor mirror of the backend, the tunnel fan-outs render one config per Host, and the clients page waits for the hosts list the way the inbounds page does, so an empty list means "no hosts" rather than "not loaded yet".
This commit is contained in:
@@ -56,6 +56,24 @@ func (s *SubService) inboundDefaultEndpoint(inbound *model.Inbound) ShareEndpoin
|
||||
}
|
||||
}
|
||||
|
||||
// advertisedEndpoints is every endpoint a stream-less link (mtproto, wireguard,
|
||||
// amneziawg) must fan out over: the externalProxy/Host entries, else the default.
|
||||
func (s *SubService) advertisedEndpoints(inbound *model.Inbound) []ShareEndpoint {
|
||||
stream := unmarshalStreamSettings(inbound.StreamSettings)
|
||||
if externalProxies, ok := stream["externalProxy"].([]any); ok {
|
||||
endpoints := make([]ShareEndpoint, 0, len(externalProxies))
|
||||
for _, raw := range externalProxies {
|
||||
if ep, ok := raw.(map[string]any); ok {
|
||||
endpoints = append(endpoints, externalProxyToEndpoint(ep))
|
||||
}
|
||||
}
|
||||
if len(endpoints) > 0 {
|
||||
return endpoints
|
||||
}
|
||||
}
|
||||
return []ShareEndpoint{s.inboundDefaultEndpoint(inbound)}
|
||||
}
|
||||
|
||||
// applyEndpointTLSParams applies an endpoint's TLS overrides onto a URL-param
|
||||
// map. External-proxy endpoints delegate to the unchanged helper; host/default
|
||||
// endpoints carry no override yet (Phase 4).
|
||||
|
||||
Reference in New Issue
Block a user