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:
mrchatam
2026-09-12 12:38:21 +03:30
committed by GitHub
parent 5cce2464f1
commit 22763fe8f6
+16 -4
View File
@@ -522,6 +522,10 @@ export default function ClientFormModal({
methods.setValue('wgPublicKey', kp.publicKey); methods.setValue('wgPublicKey', kp.publicKey);
} }
function regenerateWireguardPresharedKey() {
methods.setValue('wgPreSharedKey', Wireguard.keyToBase64(Wireguard.generatePresharedKey()));
}
function regenerateMtprotoSecret() { function regenerateMtprotoSecret() {
methods.setValue('secret', generateMtprotoSecret(mtprotoDomain)); methods.setValue('secret', generateMtprotoSecret(mtprotoDomain));
} }
@@ -1251,16 +1255,24 @@ export default function ClientFormModal({
> >
<Input disabled /> <Input disabled />
</FormField> </FormField>
<FormField <Form.Item
name="wgPreSharedKey"
label={t( label={t(
showAmneziawg showAmneziawg
? 'pages.clients.amneziaWgPreSharedKey' ? 'pages.clients.amneziaWgPreSharedKey'
: 'pages.clients.wireguardPreSharedKey', : 'pages.clients.wireguardPreSharedKey',
)} )}
> >
<Input /> <Space.Compact style={{ display: 'flex' }}>
</FormField> <FormField name="wgPreSharedKey" noStyle>
<Input style={{ flex: 1 }} />
</FormField>
<Button
aria-label={t('regenerate')}
icon={<ReloadOutlined />}
onClick={regenerateWireguardPresharedKey}
/>
</Space.Compact>
</Form.Item>
{showWireguard && showAmneziawg ? ( {showWireguard && showAmneziawg ? (
<> <>
<FormField <FormField