mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-03 17:07:15 +00:00
47964afbc5
When a client belongs to multiple AmneziaWG or WireGuard inbounds (e.g. across remote nodes), findAmneziaWGInbounds and findWireguardInbounds only returned the first matching inbound. Consequently, ClientInfoModal and ClientQrModal rendered only one config block, making other inbounds' configs unreachable. - Add findAmneziaWGInbounds and findWireguardInbounds returning all matching inbounds - Add formatTunnelConfigMeta helper to unify label, fileName, and qrRemark resolution - Support addressOverride in buildWireguardClientConfig from tunnelAllowedIPs - Render all tunnel configs in ClientInfoModal and ClientQrModal with node remarks - Distinguish download filenames with inbound remark suffix to avoid collisions - Add component integration tests covering multi-inbound modal rendering
33 lines
1.2 KiB
TypeScript
33 lines
1.2 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,
|
|
): {
|
|
label?: string;
|
|
fileName: string;
|
|
qrRemark: string;
|
|
} {
|
|
const inboundName =
|
|
formatInboundLabel(inbound.tag, inbound.remark) ||
|
|
(inbound.id != null ? `inbound-${inbound.id}` : '');
|
|
const label = totalCount > 1 ? inboundName : undefined;
|
|
const suffix = inbound.remark || inbound.tag || (inbound.id != null ? `${inbound.id}` : '');
|
|
const safeSuffix = suffix ? `-${suffix.replace(/[^\w.-]+/g, '_')}` : '';
|
|
const emailPrefix = email || 'client';
|
|
const fileName = `${emailPrefix}${totalCount > 1 ? safeSuffix : ''}.conf`;
|
|
const qrRemark =
|
|
totalCount > 1 && inboundName ? [inboundName, email].filter(Boolean).join(' - ') : email || '';
|
|
|
|
return { label, fileName, qrRemark };
|
|
}
|