import { useTranslation } from 'react-i18next'; import { Form, Input, InputNumber, Select, Switch, type FormInstance } from 'antd'; import { HeaderMapEditor } from '@/components/form'; import type { InboundFormValues } from '@/schemas/forms/inbound-form'; import { XHttpXmuxSchema } from '@/schemas/protocols/stream/xhttp'; const XMUX_DEFAULTS = XHttpXmuxSchema.parse({}); export default function XhttpForm({ form }: { form: FormInstance }) { const { t } = useTranslation(); const xhttpMode = Form.useWatch(['streamSettings', 'xhttpSettings', 'mode'], form); const xhttpObfsMode = Form.useWatch(['streamSettings', 'xhttpSettings', 'xPaddingObfsMode'], form) ?? false; const xhttpSessionPlacement = Form.useWatch(['streamSettings', 'xhttpSettings', 'sessionPlacement'], form); const xhttpSeqPlacement = Form.useWatch(['streamSettings', 'xhttpSettings', 'seqPlacement'], form); const xhttpUplinkPlacement = Form.useWatch(['streamSettings', 'xhttpSettings', 'uplinkDataPlacement'], form); function onXmuxToggle(checked: boolean) { if (!checked) return; const existing = form.getFieldValue(['streamSettings', 'xhttpSettings', 'xmux']); const hasValues = existing && typeof existing === 'object' && Object.keys(existing).length > 0; if (hasValues) return; form.setFieldValue(['streamSettings', 'xhttpSettings', 'xmux'], { ...XMUX_DEFAULTS }); } return ( <> )} {xhttpMode === 'stream-up' && ( <> )} )} )} )} {xhttpMode === 'packet-up' && ( <> )} )} {/* XMUX is the connection-multiplexing layer xHTTP uses to fan out parallel requests over a small pool of upstream connections. UI-only toggle (enableXmux) hides the 6 nested knobs when off. */} {() => { if (!form.getFieldValue([ 'streamSettings', 'xhttpSettings', 'enableXmux', ])) return null; return ( <> ); }} ); }