import { useTranslation } from 'react-i18next'; import { Button, Form, Input, InputNumber, Select, Space, Switch, type FormInstance } from 'antd'; import { DOMAIN_STRATEGY_OPTION, TCP_CONGESTION_OPTION } from '@/schemas/primitives'; import { HappyEyeballsSchema, SockoptStreamSettingsSchema } from '@/schemas/protocols/stream/sockopt'; import type { OutboundFormValues } from '@/schemas/forms/outbound-form'; import { ADDRESS_PORT_STRATEGY_OPTIONS } from '../outbound-form-constants'; export default function SockoptForm({ form, outboundTags = [], }: { form: FormInstance; outboundTags?: string[]; }) { const { t } = useTranslation(); return ( {() => { const hasSockopt = !!form.getFieldValue([ 'streamSettings', 'sockopt', ]); const dialerProxy = (form.getFieldValue([ 'streamSettings', 'sockopt', 'dialerProxy', ]) ?? '') as string; const dialerProxyOptions = Array.from( new Set([...outboundTags, dialerProxy].filter(Boolean)), ).map((tg) => ({ value: tg, label: tg })); return ( <> { form.setFieldValue( ['streamSettings', 'sockopt'], checked ? SockoptStreamSettingsSchema.parse({}) : undefined, ); }} /> {hasSockopt && ( <> ({ value: v, label: v, }))} /> ({ value: v, label: v, }))} /> ))} )} )} ); }} ); }