mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-12 17:05:01 +03:00
b04039c2bd
xray-core v26.10.10 serves MASQUE: CONNECT-IP over HTTP/3 or HTTP/2, always behind TLS, as an inbound and an outbound protocol riding a dedicated "masque" transport. The panel could not create either. Inbound: MASQUE is a multi-user protocol whose users log in with their email and password over Basic auth. The panel keeps the client's "password" like trojan and GenXrayInboundConfig hands it to the core as "pass", so the full-config path, the live AddInbound path and node pushes all emit what the core reads; one user with an empty pass makes the core refuse the whole inbound. Live user adds build a masque.Account from either key, client-only changes diff per user so a new client does not drop every connected tunnel, and client creation, copy, validation and edits key on the password. The address pool and MTU get form fields, TLS is mandatory, and the port check follows the core's listener choice: HTTP/2 on TCP when the ALPN offers h2, HTTP/3 on UDP when it offers h3 or not h2. Nodes may host MASQUE from v3.9.1, the first panel release that knows to rename the password. MASQUE has no share-link format, so links and Clash skip it; the JSON subscription builds the client's masque outbound with its email and password, and the subscription allowlist now lets a subId see MASQUE inbounds at all. The IP-limit job, client pages and traffic tracking list the protocol. Outbound: the form edits the server, remote DNS, and the transport's host, path, Basic credentials, headers and WARP block (enrolled key, endpoint public key, tunnel addresses), which xray-core refuses next to user/pass. The outbound test probes it through the core, since its default HTTP/3 dial is UDP.
123 lines
3.6 KiB
TypeScript
123 lines
3.6 KiB
TypeScript
import { useMemo, useState } from 'react';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { Alert, Modal, Select, Typography, message } from 'antd';
|
|
|
|
import { SelectAllClearButtons } from '@/components/form';
|
|
import type { InboundOption } from '@/hooks/useClients';
|
|
import { formatInboundLabel } from '@/lib/inbounds/label';
|
|
import type { BulkDetachResult } from '@/schemas/client';
|
|
|
|
const MULTI_USER_PROTOCOLS = new Set([
|
|
'vmess',
|
|
'vless',
|
|
'trojan',
|
|
'hysteria',
|
|
'shadowsocks',
|
|
'wireguard',
|
|
'mtproto',
|
|
'amneziawg',
|
|
'tuic',
|
|
'masque',
|
|
]);
|
|
|
|
interface BulkDetachInboundsModalProps {
|
|
open: boolean;
|
|
count: number;
|
|
inbounds: InboundOption[];
|
|
onOpenChange: (open: boolean) => void;
|
|
onSubmit: (inboundIds: number[]) => Promise<BulkDetachResult | null>;
|
|
}
|
|
|
|
export default function BulkDetachInboundsModal({
|
|
open,
|
|
count,
|
|
inbounds,
|
|
onOpenChange,
|
|
onSubmit,
|
|
}: BulkDetachInboundsModalProps) {
|
|
const { t } = useTranslation();
|
|
const [messageApi, messageContextHolder] = message.useMessage();
|
|
const [targetIds, setTargetIds] = useState<number[]>([]);
|
|
const [submitting, setSubmitting] = useState(false);
|
|
|
|
// React resets this during render rather than in an effect so the modal's
|
|
// first open frame already shows cleared fields.
|
|
const [wasOpen, setWasOpen] = useState(false);
|
|
if (open !== wasOpen) {
|
|
setWasOpen(open);
|
|
if (open) setTargetIds([]);
|
|
}
|
|
|
|
const targetOptions = useMemo(() => {
|
|
return (inbounds || [])
|
|
.filter((ib) => MULTI_USER_PROTOCOLS.has((ib.protocol || '').toLowerCase()))
|
|
.map((ib) => ({
|
|
value: ib.id,
|
|
label: formatInboundLabel(ib.tag, ib.remark),
|
|
}));
|
|
}, [inbounds]);
|
|
|
|
async function submit() {
|
|
if (targetIds.length === 0 || count === 0) return;
|
|
setSubmitting(true);
|
|
try {
|
|
const result = await onSubmit(targetIds);
|
|
if (!result) return;
|
|
const detached = result.detached?.length ?? 0;
|
|
const skipped = result.skipped?.length ?? 0;
|
|
const errors = result.errors?.length ?? 0;
|
|
if (errors > 0) {
|
|
messageApi.warning(
|
|
t('pages.clients.detachFromInboundsResultMixed', { detached, skipped, errors }),
|
|
);
|
|
} else {
|
|
messageApi.success(t('pages.clients.detachFromInboundsResult', { detached, skipped }));
|
|
}
|
|
onOpenChange(false);
|
|
} finally {
|
|
setSubmitting(false);
|
|
}
|
|
}
|
|
|
|
return (
|
|
<>
|
|
{messageContextHolder}
|
|
<Modal
|
|
open={open}
|
|
title={t('pages.clients.detachFromInboundsTitle', { count })}
|
|
okText={t('pages.clients.detach')}
|
|
cancelText={t('cancel')}
|
|
okButtonProps={{ danger: true, disabled: targetIds.length === 0, loading: submitting }}
|
|
onCancel={() => onOpenChange(false)}
|
|
onOk={submit}
|
|
destroyOnHidden
|
|
>
|
|
<Typography.Paragraph type="secondary">
|
|
{t('pages.clients.detachFromInboundsDesc', { count })}
|
|
</Typography.Paragraph>
|
|
{targetOptions.length === 0 ? (
|
|
<Alert type="info" showIcon title={t('pages.clients.detachFromInboundsNoTargets')} />
|
|
) : (
|
|
<>
|
|
<SelectAllClearButtons
|
|
options={targetOptions}
|
|
value={targetIds}
|
|
onChange={setTargetIds}
|
|
/>
|
|
<Select
|
|
mode="multiple"
|
|
style={{ width: '100%' }}
|
|
value={targetIds}
|
|
onChange={setTargetIds}
|
|
options={targetOptions}
|
|
placeholder={t('pages.clients.detachFromInboundsTargets')}
|
|
showSearch={{ optionFilterProp: 'label' }}
|
|
autoFocus
|
|
/>
|
|
</>
|
|
)}
|
|
</Modal>
|
|
</>
|
|
);
|
|
}
|