mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-11 23:26:07 +00:00
feat(wireguard): per-peer comments for identifying devices (#5168)
WG peers were only identifiable by their keys. Add an optional panel-side comment per peer: editable in the inbound form (echoed next to "Peer N" in the section header), stored in the settings JSON alongside the panel-only privateKey (xray-core ignores unknown peer fields), and appended to the share link / .conf remark so the device is identifiable in client apps too.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user