vless.tsx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { useState } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { Button, Form, Input, InputNumber, Select, Space, Typography } from 'antd';
  4. type VlessAuthKind =
  5. | 'x25519'
  6. | 'x25519_xorpub'
  7. | 'x25519_random'
  8. | 'mlkem768'
  9. | 'mlkem768_xorpub'
  10. | 'mlkem768_random';
  11. interface VlessFieldsProps {
  12. saving: boolean;
  13. selectedVlessAuth: string;
  14. network: string;
  15. security: string;
  16. getNewVlessEnc: (kind: VlessAuthKind) => void;
  17. clearVlessEnc: () => void;
  18. }
  19. export default function VlessFields({
  20. saving,
  21. selectedVlessAuth,
  22. network,
  23. security,
  24. getNewVlessEnc,
  25. clearVlessEnc,
  26. }: VlessFieldsProps) {
  27. const { t } = useTranslation();
  28. const [authKind, setAuthKind] = useState<VlessAuthKind>('x25519');
  29. const authOptions = [
  30. { value: 'x25519', label: t('pages.inbounds.vlessAuthX25519') },
  31. { value: 'x25519_xorpub', label: t('pages.inbounds.vlessAuthX25519Xorpub') },
  32. { value: 'x25519_random', label: t('pages.inbounds.vlessAuthX25519Random') },
  33. { value: 'mlkem768', label: t('pages.inbounds.vlessAuthMlkem768') },
  34. { value: 'mlkem768_xorpub', label: t('pages.inbounds.vlessAuthMlkem768Xorpub') },
  35. { value: 'mlkem768_random', label: t('pages.inbounds.vlessAuthMlkem768Random') },
  36. ];
  37. return (
  38. <>
  39. <Form.Item name={['settings', 'decryption']} label={t('pages.inbounds.decryption')}>
  40. <Input />
  41. </Form.Item>
  42. <Form.Item name={['settings', 'encryption']} label={t('pages.inbounds.encryption')}>
  43. <Input />
  44. </Form.Item>
  45. <Form.Item label={t('pages.inbounds.vlessAuthGenerate')}>
  46. <Space size={8} wrap>
  47. <Select
  48. value={authKind}
  49. onChange={(v) => setAuthKind(v)}
  50. options={authOptions}
  51. style={{ width: 240 }}
  52. />
  53. <Button type="primary" loading={saving} onClick={() => getNewVlessEnc(authKind)}>
  54. {t('pages.inbounds.vlessAuthGenerateButton')}
  55. </Button>
  56. <Button danger onClick={clearVlessEnc}>{t('clear')}</Button>
  57. </Space>
  58. <Typography.Text type="secondary" className="vless-auth-state">
  59. {t('pages.inbounds.vlessAuthSelected', { auth: selectedVlessAuth })}
  60. </Typography.Text>
  61. </Form.Item>
  62. {network === 'tcp' && (security === 'tls' || security === 'reality') && (
  63. <Form.Item
  64. label={t('pages.inbounds.form.visionTestseed')}
  65. extra="Applies only to clients using the xtls-rprx-vision flow; ignored otherwise."
  66. >
  67. <Space.Compact block>
  68. {[900, 500, 900, 256].map((def, i) => (
  69. <Form.Item key={i} name={['settings', 'testseed', i]} noStyle initialValue={def}>
  70. <InputNumber min={1} style={{ width: '25%' }} />
  71. </Form.Item>
  72. ))}
  73. </Space.Compact>
  74. </Form.Item>
  75. )}
  76. </>
  77. );
  78. }