import { useTranslation } from 'react-i18next'; import { Button, Form, Input, InputNumber, Radio, Select, Space, Switch } from 'antd'; import { CloudDownloadOutlined, FileProtectOutlined, MinusOutlined, PlusOutlined, } from '@ant-design/icons'; import { useFieldArray, useFormContext, useWatch } from 'react-hook-form'; import { CipherSuitesSelect } from '@/components/form'; import { FormField } from '@/components/form/rhf'; import { ALPN_OPTION, DOMAIN_STRATEGY_OPTION, TLS_VERSION_OPTION, USAGE_OPTION, UTLS_FINGERPRINT, } from '@/schemas/primitives'; import { SockoptStreamSettingsSchema } from '@/schemas/protocols/stream/sockopt'; const { TextArea } = Input; const CERT_LINES_TRANSFORM = { input: (v: unknown) => (Array.isArray(v) ? v.join('\n') : v), output: (raw: unknown) => (typeof raw === 'string' ? raw.split('\n') : raw), }; interface TlsFormProps { saving: boolean; setCertFromPanel: (certName: number) => void; clearCertFiles: (certName: number) => void; pinFromCert: () => void; pinFromRemote: () => void; getNewEchCert: () => void; clearEchCert: () => void; } interface CertRowProps { index: number; total: number; saving: boolean; onRemove: () => void; setCertFromPanel: (certName: number) => void; clearCertFiles: (certName: number) => void; } function CertRow({ index, total, saving, onRemove, setCertFromPanel, clearCertFiles, }: CertRowProps) { const { t } = useTranslation(); const { control } = useFormContext(); const useFile = useWatch({ control, name: `streamSettings.tlsSettings.certificates.${index}.useFile`, }); const usage = useWatch({ control, name: `streamSettings.tlsSettings.certificates.${index}.usage`, }); return (
{t('pages.inbounds.certificatePath')} {t('pages.inbounds.certificateContent')} {total > 1 && ( )} {useFile ? ( <> ) : ( <>