mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-01 19:52:09 +03:00
aee45ca3fe
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".
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
/**
|
|
* Display label for an inbound: the remark when one is set, otherwise the
|
|
* inbound tag. Falls back to an empty string when neither is present.
|
|
*/
|
|
export function formatInboundLabel(tag?: string, remark?: string): string {
|
|
const remarkText = (remark || '').trim();
|
|
if (remarkText) return remarkText;
|
|
return (tag || '').trim();
|
|
}
|
|
|
|
export function formatTunnelConfigMeta(
|
|
inbound: { id?: number; tag?: string; remark?: string },
|
|
email?: string,
|
|
totalCount = 1,
|
|
endpoint = '',
|
|
): {
|
|
label?: string;
|
|
fileName: string;
|
|
qrRemark: string;
|
|
} {
|
|
const inboundName =
|
|
formatInboundLabel(inbound.tag, inbound.remark) ||
|
|
(inbound.id != null ? `inbound-${inbound.id}` : '');
|
|
const name = [inboundName, endpoint].filter(Boolean).join(' - ');
|
|
const label = totalCount > 1 ? name : undefined;
|
|
const suffix = [
|
|
inbound.remark || inbound.tag || (inbound.id != null ? `${inbound.id}` : ''),
|
|
endpoint,
|
|
]
|
|
.filter(Boolean)
|
|
.join('-');
|
|
const safeSuffix = suffix ? `-${suffix.replace(/[^\w.-]+/g, '_')}` : '';
|
|
const emailPrefix = email || 'client';
|
|
const fileName = `${emailPrefix}${totalCount > 1 ? safeSuffix : ''}.conf`;
|
|
const qrRemark = totalCount > 1 && name ? [name, email].filter(Boolean).join(' - ') : email || '';
|
|
|
|
return { label, fileName, qrRemark };
|
|
}
|