import { useTranslation } from 'react-i18next';
import { Button, Form, Input, InputNumber, Radio, Select, Space, Switch } from 'antd';
import { MinusOutlined, PlusOutlined, ReloadOutlined } from '@ant-design/icons';
import {
ALPN_OPTION,
TLS_CIPHER_OPTION,
TLS_VERSION_OPTION,
USAGE_OPTION,
UTLS_FINGERPRINT,
} from '@/schemas/primitives';
const { TextArea } = Input;
interface TlsFormProps {
saving: boolean;
setCertFromPanel: (certName: number) => void;
clearCertFiles: (certName: number) => void;
generateRandomPinHash: () => void;
getNewEchCert: () => void;
clearEchCert: () => void;
}
export default function TlsForm({
saving,
setCertFromPanel,
clearCertFiles,
generateRandomPinHash,
getNewEchCert,
clearEchCert,
}: TlsFormProps) {
const { t } = useTranslation();
return (
<>
{(certFields, { add, remove }) => (
<>
{certFields.map((certField, idx) => (
{t('pages.inbounds.certificatePath')}
{t('pages.inbounds.certificateContent')}
{certFields.length > 1 && (
)}
prev.streamSettings?.tlsSettings?.certificates?.[certField.name]?.useFile
!== curr.streamSettings?.tlsSettings?.certificates?.[certField.name]?.useFile
}
>
{({ getFieldValue }) => {
const useFile = getFieldValue([
'streamSettings', 'tlsSettings', 'certificates',
certField.name, 'useFile',
]);
return useFile ? (
<>
>
) : (
<>
typeof v === 'string'
? v.split('\n')
: v}
getValueProps={(v) => ({
value: Array.isArray(v) ? v.join('\n') : v,
})}
>
typeof v === 'string'
? v.split('\n')
: v}
getValueProps={(v) => ({
value: Array.isArray(v) ? v.join('\n') : v,
})}
>
>
);
}}
prev.streamSettings?.tlsSettings?.certificates?.[certField.name]?.usage
!== curr.streamSettings?.tlsSettings?.certificates?.[certField.name]?.usage
}
>
{({ getFieldValue }) => {
const usage = getFieldValue([
'streamSettings', 'tlsSettings', 'certificates',
certField.name, 'usage',
]);
if (usage !== 'issue') return null;
return (
);
}}
))}
>
)}
}
onClick={generateRandomPinHash}
title={t('pages.inbounds.form.generateRandomPin')}
/>
>
);
}