From 3ba43bd86db556e58575411273284c0eecdba86d Mon Sep 17 00:00:00 2001 From: FunLay123 <137938315+FunLay123@users.noreply.github.com> Date: Wed, 24 Jun 2026 21:22:42 +0200 Subject: [PATCH] feat(web): vless encryption new modes (#5517) * feat(web): add vless encryption new modes * feat(web): add translations for vless encryption modes * feat(translation): bring "vlessAuthX25519" and "vlessAuthMlkem768" to general form --- .../pages/inbounds/form/InboundFormModal.tsx | 22 +++++++++-- .../pages/inbounds/form/protocols/vless.tsx | 39 +++++++++++++++---- internal/web/service/server.go | 25 +++++++++++- internal/web/service/server_vlessenc_test.go | 28 +++++++++++++ internal/web/translation/ar-EG.json | 12 ++++-- internal/web/translation/en-US.json | 12 ++++-- internal/web/translation/es-ES.json | 12 ++++-- internal/web/translation/fa-IR.json | 12 ++++-- internal/web/translation/id-ID.json | 12 ++++-- internal/web/translation/ja-JP.json | 12 ++++-- internal/web/translation/pt-BR.json | 12 ++++-- internal/web/translation/ru-RU.json | 12 ++++-- internal/web/translation/tr-TR.json | 12 ++++-- internal/web/translation/uk-UA.json | 12 ++++-- internal/web/translation/vi-VN.json | 12 ++++-- internal/web/translation/zh-CN.json | 12 ++++-- internal/web/translation/zh-TW.json | 12 ++++-- 17 files changed, 219 insertions(+), 51 deletions(-) diff --git a/frontend/src/pages/inbounds/form/InboundFormModal.tsx b/frontend/src/pages/inbounds/form/InboundFormModal.tsx index b46542b0a..3bb207feb 100644 --- a/frontend/src/pages/inbounds/form/InboundFormModal.tsx +++ b/frontend/src/pages/inbounds/form/InboundFormModal.tsx @@ -285,8 +285,12 @@ export default function InboundFormModal({ ) => { if (block?.id === authId) return true; const label = (block?.label || '').toLowerCase().replace(/[-_\s]/g, ''); - if (authId === 'mlkem768') return label.includes('mlkem768'); - if (authId === 'x25519') return label.includes('x25519'); + if (authId === 'mlkem768') return label.includes('mlkem768') && !label.includes('xorpub') && !label.includes('random'); + if (authId === 'x25519') return label.includes('x25519') && !label.includes('xorpub') && !label.includes('random'); + if (authId === 'mlkem768_xorpub') return label.includes('mlkem768') && label.includes('xorpub'); + if (authId === 'mlkem768_random') return label.includes('mlkem768') && label.includes('random'); + if (authId === 'x25519_xorpub') return label.includes('x25519') && label.includes('xorpub'); + if (authId === 'x25519_random') return label.includes('x25519') && label.includes('random'); return false; }; @@ -319,7 +323,19 @@ export default function InboundFormModal({ const parts = enc.split('.').filter(Boolean); const authKey = parts[parts.length - 1] || ''; if (!authKey) return t('pages.inbounds.vlessAuthCustom'); - return authKey.length > 300 + 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'); })(); diff --git a/frontend/src/pages/inbounds/form/protocols/vless.tsx b/frontend/src/pages/inbounds/form/protocols/vless.tsx index d924c8808..310bc8ffe 100644 --- a/frontend/src/pages/inbounds/form/protocols/vless.tsx +++ b/frontend/src/pages/inbounds/form/protocols/vless.tsx @@ -1,12 +1,21 @@ +import { useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { Button, Form, Input, InputNumber, Space, Typography } from 'antd'; +import { Button, Form, Input, InputNumber, Select, Space, Typography } from 'antd'; + +type VlessAuthKind = + | 'x25519' + | 'x25519_xorpub' + | 'x25519_random' + | 'mlkem768' + | 'mlkem768_xorpub' + | 'mlkem768_random'; interface VlessFieldsProps { saving: boolean; selectedVlessAuth: string; network: string; security: string; - getNewVlessEnc: (kind: 'x25519' | 'mlkem768') => void; + getNewVlessEnc: (kind: VlessAuthKind) => void; clearVlessEnc: () => void; } @@ -19,6 +28,17 @@ export default function VlessFields({ clearVlessEnc, }: VlessFieldsProps) { const { t } = useTranslation(); + const [authKind, setAuthKind] = useState('x25519'); + + const authOptions = [ + { value: 'x25519', label: t('pages.inbounds.vlessAuthX25519') }, + { value: 'x25519_xorpub', label: t('pages.inbounds.vlessAuthX25519Xorpub') }, + { value: 'x25519_random', label: t('pages.inbounds.vlessAuthX25519Random') }, + { value: 'mlkem768', label: t('pages.inbounds.vlessAuthMlkem768') }, + { value: 'mlkem768_xorpub', label: t('pages.inbounds.vlessAuthMlkem768Xorpub') }, + { value: 'mlkem768_random', label: t('pages.inbounds.vlessAuthMlkem768Random') }, + ]; + return ( <> @@ -27,13 +47,16 @@ export default function VlessFields({ - + - -