diff --git a/frontend/src/lib/xray/inbound-link.ts b/frontend/src/lib/xray/inbound-link.ts index 4ca6e5e36..c3da5fb4a 100644 --- a/frontend/src/lib/xray/inbound-link.ts +++ b/frontend/src/lib/xray/inbound-link.ts @@ -1079,11 +1079,11 @@ export function genWireguardLinks(input: GenWireguardFanoutInput): string { const addr = resolveAddr(inbound, hostOverride, fallbackHostname); const sep = remarkModel.charAt(0); return inbound.settings.peers - .map((_p, i) => genWireguardLink({ + .map((p, i) => genWireguardLink({ settings: inbound.settings as WireguardInboundSettings, address: addr, port: inbound.port, - remark: `${remark}${sep}${i + 1}`, + remark: `${remark}${sep}${i + 1}${wgPeerCommentSuffix(p)}`, peerIndex: i, })) .join('\r\n'); @@ -1095,16 +1095,23 @@ export function genWireguardConfigs(input: GenWireguardFanoutInput): string { const addr = resolveAddr(inbound, hostOverride, fallbackHostname); const sep = remarkModel.charAt(0); return inbound.settings.peers - .map((_p, i) => genWireguardConfig({ + .map((p, i) => genWireguardConfig({ settings: inbound.settings as WireguardInboundSettings, address: addr, port: inbound.port, - remark: `${remark}${sep}${i + 1}`, + remark: `${remark}${sep}${i + 1}${wgPeerCommentSuffix(p)}`, peerIndex: i, })) .join('\r\n'); } +// Peer comments (#5168) are panel-side annotations; when present they ride +// along in the share remark so the device is identifiable in client apps. +function wgPeerCommentSuffix(peer: unknown): string { + const comment = (peer as { comment?: unknown })?.comment; + return typeof comment === 'string' && comment.trim() !== '' ? ` (${comment.trim()})` : ''; +} + export function isPostQuantumLink(link: string): boolean { if (/[?&]pqv=/.test(link)) return true; if (link.includes('mlkem768') || link.includes('mldsa65')) return true; diff --git a/frontend/src/pages/inbounds/form/protocols/wireguard.tsx b/frontend/src/pages/inbounds/form/protocols/wireguard.tsx index 665ccdc48..cdf4aa597 100644 --- a/frontend/src/pages/inbounds/form/protocols/wireguard.tsx +++ b/frontend/src/pages/inbounds/form/protocols/wireguard.tsx @@ -102,6 +102,12 @@ export default function WireguardFields({ wgPubKey, regenInboundWg, regenWgPeerK {t('pages.inbounds.info.peerNumber', { n: idx + 1 })} + + {() => { + const comment = form.getFieldValue(['settings', 'peers', field.name, 'comment']) as string | undefined; + return comment ? — {comment} : null; + }} + {fields.length > 1 && (