mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-14 02:12:11 +03:00
feat(clients): add Generate button for WireGuard/AmneziaWG PresharedKey (#6455)
* feat(clients): add Generate button for WireGuard/AmneziaWG PresharedKey Matches existing key regenerate controls on the client form. Value is 32 random bytes base64 via Wireguard.generatePresharedKey (same as wg genpsk). Field stays optional. Fixes #6343 * fix(clients): keep FormField for WireGuard PresharedKey generate Restore RHF FormField (noStyle inside Space.Compact) so the regenerate control matches inbound reality patterns and satisfies oxfmt. --------- Co-authored-by: mrchatam <287639636+mrchatam@users.noreply.github.com>
This commit is contained in:
@@ -522,6 +522,10 @@ export default function ClientFormModal({
|
||||
methods.setValue('wgPublicKey', kp.publicKey);
|
||||
}
|
||||
|
||||
function regenerateWireguardPresharedKey() {
|
||||
methods.setValue('wgPreSharedKey', Wireguard.keyToBase64(Wireguard.generatePresharedKey()));
|
||||
}
|
||||
|
||||
function regenerateMtprotoSecret() {
|
||||
methods.setValue('secret', generateMtprotoSecret(mtprotoDomain));
|
||||
}
|
||||
@@ -1251,16 +1255,24 @@ export default function ClientFormModal({
|
||||
>
|
||||
<Input disabled />
|
||||
</FormField>
|
||||
<FormField
|
||||
name="wgPreSharedKey"
|
||||
<Form.Item
|
||||
label={t(
|
||||
showAmneziawg
|
||||
? 'pages.clients.amneziaWgPreSharedKey'
|
||||
: 'pages.clients.wireguardPreSharedKey',
|
||||
)}
|
||||
>
|
||||
<Input />
|
||||
</FormField>
|
||||
<Space.Compact style={{ display: 'flex' }}>
|
||||
<FormField name="wgPreSharedKey" noStyle>
|
||||
<Input style={{ flex: 1 }} />
|
||||
</FormField>
|
||||
<Button
|
||||
aria-label={t('regenerate')}
|
||||
icon={<ReloadOutlined />}
|
||||
onClick={regenerateWireguardPresharedKey}
|
||||
/>
|
||||
</Space.Compact>
|
||||
</Form.Item>
|
||||
{showWireguard && showAmneziawg ? (
|
||||
<>
|
||||
<FormField
|
||||
|
||||
Reference in New Issue
Block a user