🐛 fix: Fixing issues with generating standard and quantum-resistant encryption keys

This commit is contained in:
web 2025-11-04 20:40:53 -08:00
parent 2182400adc
commit 5eac6a9f4a
32 changed files with 142 additions and 32 deletions

View File

@ -1,17 +1,16 @@
<a name="readme-top"></a>
# Changelog
# [1.6.0](https://github.com/perfect-panel/ppanel-web/compare/v1.5.4...v1.6.0) (2025-10-28)
### ✨ Features
* Add server installation dialog and commands ([4429c9d](https://github.com/perfect-panel/ppanel-web/commit/4429c9d))
- Add server installation dialog and commands ([4429c9d](https://github.com/perfect-panel/ppanel-web/commit/4429c9d))
### 🐛 Bug Fixes
* Add typeRoots configuration to ensure type definitions are resolved correctly ([ad60ea9](https://github.com/perfect-panel/ppanel-web/commit/ad60ea9))
- Add typeRoots configuration to ensure type definitions are resolved correctly ([ad60ea9](https://github.com/perfect-panel/ppanel-web/commit/ad60ea9))
<a name="readme-top"></a>

View File

@ -444,7 +444,16 @@ export const PROTOCOL_FIELDS: Record<string, FieldConfig[]> = {
placeholder: (t) => t('encryption_private_key_placeholder'),
group: 'encryption',
generate: {
function: generateMLKEM768KeyPair,
functions: [
{
label: (t) => t('generate_standard_encryption_key'),
function: generateRealityKeyPair,
},
{
label: (t) => t('generate_quantum_resistant_key'),
function: generateMLKEM768KeyPair,
},
],
updateFields: {
encryption_private_key: 'privateKey',
encryption_password: 'publicKey',

View File

@ -12,7 +12,11 @@ export type FieldConfig = {
step?: number;
suffix?: string;
generate?: {
function: () => Promise<string | Record<string, string>> | string | Record<string, string>;
function?: () => Promise<string | Record<string, string>> | string | Record<string, string>;
functions?: {
label: string | ((t: (key: string) => string, protocol: any) => string);
function: () => Promise<string | Record<string, string>> | string | Record<string, string>;
}[];
updateFields?: Record<string, string>;
};
condition?: (protocol: any, values: any) => boolean;

View File

@ -1,11 +1,11 @@
import * as x25519 from '@noble/ed25519';
import { x25519 } from '@noble/curves/ed25519.js';
import { toB64Url } from './util';
/**
* Generate a Reality key pair
* @returns An object containing the private and public keys in base64url format
*/
export async function generateRealityKeyPair() {
const { secretKey, publicKey } = await x25519.keygenAsync();
export function generateRealityKeyPair() {
const { secretKey, publicKey } = x25519.keygen();
return { privateKey: toB64Url(secretKey), publicKey: toB64Url(publicKey) };
}

View File

@ -61,7 +61,6 @@ export default function ServersPage() {
const { fetchServers } = useServer();
const [loading, setLoading] = useState(false);
const [migrating, setMigrating] = useState(false);
const ref = useRef<ProTableActions>(null);
return (

View File

@ -10,6 +10,12 @@ import {
} from '@workspace/ui/components/accordion';
import { Badge } from '@workspace/ui/components/badge';
import { Button } from '@workspace/ui/components/button';
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from '@workspace/ui/components/dropdown-menu';
import {
Form,
FormControl,
@ -99,29 +105,68 @@ function DynamicField({
onValueChange={(v) => fieldProps.onChange(v)}
suffix={
field.generate ? (
<Button
type='button'
variant='ghost'
onClick={async () => {
const result = await field.generate!.function();
if (typeof result === 'string') {
fieldProps.onChange(result);
} else if (field.generate!.updateFields) {
Object.entries(field.generate!.updateFields).forEach(
([fieldName, resultKey]) => {
const fullFieldName = `protocols.${protocolIndex}.${fieldName}`;
form.setValue(fullFieldName, (result as any)[resultKey]);
},
);
} else {
if (result.privateKey) {
fieldProps.onChange(result.privateKey);
field.generate.functions && field.generate.functions.length > 0 ? (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button type='button' variant='ghost' size='sm'>
<Icon icon='mdi:key' className='h-4 w-4' />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align='end'>
{field.generate.functions.map((genFunc, idx) => (
<DropdownMenuItem
key={idx}
onClick={async () => {
const result = await genFunc.function();
if (typeof result === 'string') {
fieldProps.onChange(result);
} else if (field.generate!.updateFields) {
Object.entries(field.generate!.updateFields).forEach(
([fieldName, resultKey]) => {
const fullFieldName = `protocols.${protocolIndex}.${fieldName}`;
form.setValue(fullFieldName, (result as any)[resultKey]);
},
);
} else {
if (result.privateKey) {
fieldProps.onChange(result.privateKey);
}
}
}}
>
{typeof genFunc.label === 'function'
? genFunc.label(t, protocolData)
: genFunc.label}
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
) : field.generate.function ? (
<Button
type='button'
variant='ghost'
size='sm'
onClick={async () => {
const result = await field.generate!.function!();
if (typeof result === 'string') {
fieldProps.onChange(result);
} else if (field.generate!.updateFields) {
Object.entries(field.generate!.updateFields).forEach(
([fieldName, resultKey]) => {
const fullFieldName = `protocols.${protocolIndex}.${fieldName}`;
form.setValue(fullFieldName, (result as any)[resultKey]);
},
);
} else {
if (result.privateKey) {
fieldProps.onChange(result.privateKey);
}
}
}
}}
>
<Icon icon='mdi:key' className='h-4 w-4' />
</Button>
}}
>
<Icon icon='mdi:key' className='h-4 w-4' />
</Button>
) : null
) : (
field.suffix
)

View File

@ -50,6 +50,8 @@
"expired": "Vypršelo",
"extra": "Další konfigurace",
"flow": "Tok",
"generate_quantum_resistant_key": "Generovat kvantově odolný klíč",
"generate_standard_encryption_key": "Generovat standardní šifrovací klíč",
"hop_interval": "Interval skoku",
"hop_ports": "Porty skoku",
"hop_ports_placeholder": "např. 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "Abgelaufen",
"extra": "Zusätzliche Konfiguration",
"flow": "Fluss",
"generate_quantum_resistant_key": "Quantenresistenten Schlüssel generieren",
"generate_standard_encryption_key": "Standard-Verschlüsselungsschlüssel generieren",
"hop_interval": "Hop-Intervall",
"hop_ports": "Hop-Ports",
"hop_ports_placeholder": "z.B. 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "Expired",
"extra": "Extra Configuration",
"flow": "Flow",
"generate_quantum_resistant_key": "Generate Quantum-Resistant Key",
"generate_standard_encryption_key": "Generate Standard Encryption Key",
"hop_interval": "Hop interval",
"hop_ports": "Hop ports",
"hop_ports_placeholder": "e.g. 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "Expirado",
"extra": "Configuración Extra",
"flow": "Flujo",
"generate_quantum_resistant_key": "Generar clave resistente a cuánticos",
"generate_standard_encryption_key": "Generar clave de cifrado estándar",
"hop_interval": "Intervalo de salto",
"hop_ports": "Puertos de salto",
"hop_ports_placeholder": "p. ej. 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "Expirado",
"extra": "Configuración Extra",
"flow": "Flujo",
"generate_quantum_resistant_key": "Generar clave resistente a cuánticos",
"generate_standard_encryption_key": "Generar clave de cifrado estándar",
"hop_interval": "Intervalo de salto",
"hop_ports": "Puertos de salto",
"hop_ports_placeholder": "p. ej. 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "منقضی شده",
"extra": "پیکربندی اضافی",
"flow": "جریان",
"generate_quantum_resistant_key": "تولید کلید مقاوم در برابر کوانتوم",
"generate_standard_encryption_key": "تولید کلید رمزگذاری استاندارد",
"hop_interval": "فاصله پرش",
"hop_ports": "پورت‌های پرش",
"hop_ports_placeholder": "مثلاً 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "Vanhentunut",
"extra": "Lisäasetukset",
"flow": "Virta",
"generate_quantum_resistant_key": "Luo kvanttikestävä avain",
"generate_standard_encryption_key": "Luo standardi salausavain",
"hop_interval": "Hyppyvälit",
"hop_ports": "Hyppysatamat",
"hop_ports_placeholder": "esim. 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "Expiré",
"extra": "Configuration supplémentaire",
"flow": "Flux",
"generate_quantum_resistant_key": "Générer une clé résistante aux quantiques",
"generate_standard_encryption_key": "Générer une clé de chiffrement standard",
"hop_interval": "Intervalle de saut",
"hop_ports": "Ports de saut",
"hop_ports_placeholder": "ex. 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "समय समाप्त",
"extra": "अतिरिक्त कॉन्फ़िगरेशन",
"flow": "प्रवाह",
"generate_quantum_resistant_key": "क्वांटम-प्रतिरोधी कुंजी उत्पन्न करें",
"generate_standard_encryption_key": "मानक एन्क्रिप्शन कुंजी उत्पन्न करें",
"hop_interval": "हॉप अंतराल",
"hop_ports": "हॉप पोर्ट",
"hop_ports_placeholder": "जैसे 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "Lejárt",
"extra": "További konfiguráció",
"flow": "Forgalom",
"generate_quantum_resistant_key": "Kvantumálló kulcs generálása",
"generate_standard_encryption_key": "Szabványos titkosítási kulcs generálása",
"hop_interval": "Ugrás időköz",
"hop_ports": "Ugrás portok",
"hop_ports_placeholder": "pl. 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "期限切れ",
"extra": "追加設定",
"flow": "フロー",
"generate_quantum_resistant_key": "量子耐性キーを生成",
"generate_standard_encryption_key": "標準暗号化キーを生成",
"hop_interval": "ホップ間隔",
"hop_ports": "ホップポート",
"hop_ports_placeholder": "例: 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "만료됨",
"extra": "추가 구성",
"flow": "흐름",
"generate_quantum_resistant_key": "양자 저항 키 생성",
"generate_standard_encryption_key": "표준 암호화 키 생성",
"hop_interval": "홉 간격",
"hop_ports": "홉 포트",
"hop_ports_placeholder": "예: 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "Utløpt",
"extra": "Ekstra konfigurasjon",
"flow": "Flyt",
"generate_quantum_resistant_key": "Generer kvantumresistent nøkkel",
"generate_standard_encryption_key": "Generer standard krypteringsnøkkel",
"hop_interval": "Hoppintervall",
"hop_ports": "Hoppporter",
"hop_ports_placeholder": "f.eks. 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "Wygasł",
"extra": "Dodatkowa konfiguracja",
"flow": "Przepływ",
"generate_quantum_resistant_key": "Generuj klucz odporny na kwanty",
"generate_standard_encryption_key": "Generuj standardowy klucz szyfrowania",
"hop_interval": "Interwał skoku",
"hop_ports": "Porty skoku",
"hop_ports_placeholder": "np. 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "Expirado",
"extra": "Configuração Extra",
"flow": "Fluxo",
"generate_quantum_resistant_key": "Gerar chave resistente a quânticos",
"generate_standard_encryption_key": "Gerar chave de criptografia padrão",
"hop_interval": "Intervalo de salto",
"hop_ports": "Portas de salto",
"hop_ports_placeholder": "ex. 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "Expirat",
"extra": "Configurație suplimentară",
"flow": "Flux",
"generate_quantum_resistant_key": "Generează cheie rezistentă la cuantică",
"generate_standard_encryption_key": "Generează cheie de criptare standard",
"hop_interval": "Interval de hop",
"hop_ports": "Porturi hop",
"hop_ports_placeholder": "de ex. 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "Истекло",
"extra": "Дополнительная конфигурация",
"flow": "Поток",
"generate_quantum_resistant_key": "Генерировать квантово-устойчивый ключ",
"generate_standard_encryption_key": "Генерировать стандартный ключ шифрования",
"hop_interval": "Интервал перехода",
"hop_ports": "Порты перехода",
"hop_ports_placeholder": "например, 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "หมดอายุ",
"extra": "การกำหนดค่าพิเศษ",
"flow": "การไหล",
"generate_quantum_resistant_key": "สร้างคีย์ต้านทานควอนตัม",
"generate_standard_encryption_key": "สร้างคีย์เข้ารหัสมาตรฐาน",
"hop_interval": "ช่วงเวลาการกระโดด",
"hop_ports": "พอร์ตการกระโดด",
"hop_ports_placeholder": "เช่น 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "Süresi dolmuş",
"extra": "Ek Yapılandırma",
"flow": "Akış",
"generate_quantum_resistant_key": "Kuantuma Dayanıklı Anahtar Oluştur",
"generate_standard_encryption_key": "Standart Şifreleme Anahtarı Oluştur",
"hop_interval": "Atlama aralığı",
"hop_ports": "Atlama portları",
"hop_ports_placeholder": "örn. 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "Термін дії закінчився",
"extra": "Додаткова конфігурація",
"flow": "Потік",
"generate_quantum_resistant_key": "Згенерувати квантово-стійкий ключ",
"generate_standard_encryption_key": "Згенерувати стандартний ключ шифрування",
"hop_interval": "Інтервал стрибка",
"hop_ports": "Порти стрибка",
"hop_ports_placeholder": "наприклад, 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "Đã hết hạn",
"extra": "Cấu hình thêm",
"flow": "Lưu lượng",
"generate_quantum_resistant_key": "Tạo khóa chống lượng tử",
"generate_standard_encryption_key": "Tạo khóa mã hóa tiêu chuẩn",
"hop_interval": "Khoảng thời gian nhảy",
"hop_ports": "Cổng nhảy",
"hop_ports_placeholder": "vd. 1-65535",

View File

@ -53,6 +53,8 @@
"expired": "已过期",
"extra": "额外配置",
"flow": "流控",
"generate_quantum_resistant_key": "生成抗量子密钥",
"generate_standard_encryption_key": "生成标准加密密钥",
"hop_interval": "跳跃端口间隔",
"hop_ports": "跳跃端口",
"hop_ports_placeholder": "例如 1-65535",

View File

@ -50,6 +50,8 @@
"expired": "已過期",
"extra": "額外配置",
"flow": "流量",
"generate_quantum_resistant_key": "生成抗量子密鑰",
"generate_standard_encryption_key": "生成標準加密密鑰",
"hop_interval": "跳躍間隔",
"hop_ports": "跳躍端口",
"hop_ports_placeholder": "例如 1-65535",

View File

@ -11,6 +11,7 @@
},
"dependencies": {
"@lottiefiles/dotlottie-react": "^0.15.1",
"@noble/curves": "^2.0.1",
"@noble/ed25519": "^3.0.0",
"@tanstack/react-query": "^5.85.5",
"@tanstack/react-query-next-experimental": "^5.85.5",

View File

@ -16,6 +16,7 @@
"@iconify/react": "^5.2.0",
"@lottiefiles/dotlottie-react": "^0.15.1",
"@monaco-editor/react": "^4.7.0",
"@noble/curves": "^2.0.1",
"@radix-ui/react-accordion": "^1.2.12",
"@radix-ui/react-alert-dialog": "^1.1.15",
"@radix-ui/react-aspect-ratio": "^1.1.7",
@ -104,6 +105,7 @@
"name": "ppanel-admin-web",
"dependencies": {
"@lottiefiles/dotlottie-react": "^0.15.1",
"@noble/curves": "^2.0.1",
"@noble/ed25519": "^3.0.0",
"@tanstack/react-query": "^5.85.5",
"@tanstack/react-query-next-experimental": "^5.85.5",
@ -548,8 +550,12 @@
"@next/swc-win32-x64-msvc": ["@next/swc-win32-x64-msvc@15.5.6", "", { "os": "win32", "cpu": "x64" }, "sha512-pxK4VIjFRx1MY92UycLOOw7dTdvccWsNETQ0kDHkBlcFH1GrTLUjSiHU1ohrznnux6TqRHgv5oflhfIWZwVROQ=="],
"@noble/curves": ["@noble/curves@2.0.1", "", { "dependencies": { "@noble/hashes": "2.0.1" } }, "sha512-vs1Az2OOTBiP4q0pwjW5aF0xp9n4MxVrmkFBxc6EKZc6ddYx5gaZiAsZoq0uRRXWbi3AT/sBqn05eRPtn1JCPw=="],
"@noble/ed25519": ["@noble/ed25519@3.0.0", "", {}, "sha512-QyteqMNm0GLqfa5SoYbSC3+Pvykwpn95Zgth4MFVSMKBB75ELl9tX1LAVsN4c3HXOrakHsF2gL4zWDAYCcsnzg=="],
"@noble/hashes": ["@noble/hashes@2.0.1", "", {}, "sha512-XlOlEbQcE9fmuXxrVTXCTlG2nlRXa9Rj3rr5Ue/+tX+nmkgbX720YHh0VR3hBF9xDvwnb8D2shVGOwNx+ulArw=="],
"@nodelib/fs.scandir": ["@nodelib/fs.scandir@2.1.5", "", { "dependencies": { "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" } }, "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g=="],
"@nodelib/fs.stat": ["@nodelib/fs.stat@2.0.5", "", {}, "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A=="],

View File

@ -60,6 +60,7 @@
"@iconify/react": "^5.2.0",
"@lottiefiles/dotlottie-react": "^0.15.1",
"@monaco-editor/react": "^4.7.0",
"@noble/curves": "^2.0.1",
"@radix-ui/react-accordion": "^1.2.12",
"@radix-ui/react-alert-dialog": "^1.1.15",
"@radix-ui/react-aspect-ratio": "^1.1.7",