mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-14 08:36:07 +00:00
fix(web): sync the VLESS generate-key dropdown with the encryption field
The auth-kind dropdown in the VLESS "Generate Key" block was hardcoded to x25519 on mount, while the "Already selected" text next to it was derived independently from settings.encryption. Editing an inbound whose encryption uses another kind (e.g. ML-KEM-768) showed a mismatched dropdown, and clicking Generate without noticing would produce a keypair of the wrong kind for the inbound. Extract the encryption-string parsing into a shared pure helper (lib/xray/vless-encryption), use it both for the selected-auth label and to initialize/sync the dropdown, so the two can no longer diverge. When the encryption is none or unparseable the dropdown keeps its x25519 default. Closes #5744
This commit is contained in:
@@ -41,6 +41,7 @@ import { Protocols } from '@/schemas/primitives';
|
||||
import { SockoptStreamSettingsSchema } from '@/schemas/protocols/stream/sockopt';
|
||||
import { HysteriaStreamSettingsSchema } from '@/schemas/protocols/stream/hysteria';
|
||||
import { createHysteriaTlsSettingsWithDefaultCert } from '@/lib/xray/inbound-tls-defaults';
|
||||
import { VLESS_AUTH_LABEL_KEYS, vlessEncryptionAuthKind } from '@/lib/xray/vless-encryption';
|
||||
import { SniffingSchema } from '@/schemas/primitives/sniffing';
|
||||
import { TcpStreamSettingsSchema } from '@/schemas/protocols/stream/tcp';
|
||||
import { KcpStreamSettingsSchema } from '@/schemas/protocols/stream/kcp';
|
||||
@@ -317,27 +318,14 @@ export default function InboundFormModal({
|
||||
form.setFieldValue(['settings', 'encryption'], 'none');
|
||||
};
|
||||
|
||||
const vlessAuthKind = vlessEncryptionAuthKind(
|
||||
typeof vlessEncryption === 'string' ? vlessEncryption : '',
|
||||
);
|
||||
const selectedVlessAuth = (() => {
|
||||
const enc = typeof vlessEncryption === 'string' ? vlessEncryption : '';
|
||||
if (!enc || enc === 'none') return 'None';
|
||||
const parts = enc.split('.').filter(Boolean);
|
||||
const authKey = parts[parts.length - 1] || '';
|
||||
if (!authKey) return t('pages.inbounds.vlessAuthCustom');
|
||||
const mode = parts[1] || 'native';
|
||||
const keyType = authKey.length > 300 ? 'mlkem768' : 'x25519';
|
||||
if (mode === 'xorpub') {
|
||||
return keyType === 'mlkem768'
|
||||
? t('pages.inbounds.vlessAuthMlkem768Xorpub')
|
||||
: t('pages.inbounds.vlessAuthX25519Xorpub');
|
||||
}
|
||||
if (mode === 'random') {
|
||||
return keyType === 'mlkem768'
|
||||
? t('pages.inbounds.vlessAuthMlkem768Random')
|
||||
: t('pages.inbounds.vlessAuthX25519Random');
|
||||
}
|
||||
return keyType === 'mlkem768'
|
||||
? t('pages.inbounds.vlessAuthMlkem768')
|
||||
: t('pages.inbounds.vlessAuthX25519');
|
||||
if (!vlessAuthKind) return t('pages.inbounds.vlessAuthCustom');
|
||||
return t(VLESS_AUTH_LABEL_KEYS[vlessAuthKind]);
|
||||
})();
|
||||
|
||||
useEffect(() => {
|
||||
@@ -703,7 +691,7 @@ export default function InboundFormModal({
|
||||
|
||||
{protocol === Protocols.SHADOWSOCKS && <ShadowsocksFields form={form} isSSWith2022={isSSWith2022} />}
|
||||
|
||||
{protocol === Protocols.VLESS && <VlessFields saving={saving} selectedVlessAuth={selectedVlessAuth} network={network} security={security} getNewVlessEnc={getNewVlessEnc} clearVlessEnc={clearVlessEnc} />}
|
||||
{protocol === Protocols.VLESS && <VlessFields saving={saving} selectedVlessAuth={selectedVlessAuth} vlessAuthKind={vlessAuthKind} network={network} security={security} getNewVlessEnc={getNewVlessEnc} clearVlessEnc={clearVlessEnc} />}
|
||||
|
||||
{isFallbackHost && fallbacksCard}
|
||||
{(protocol === Protocols.VLESS || protocol === Protocols.TROJAN)
|
||||
|
||||
Reference in New Issue
Block a user