Files
3x-ui/docs/lib/xray/protocols.ts
T
MHSanaei 9b91f0f42e docs: vendor the documentation site into the monorepo
Fold the standalone 3x-ui-docs project (Next.js 16 + Fumadocs, deployed to
docs.sanaei.dev) into docs/ so the panel and its documentation share a single
source of truth, the way sing-box keeps its docs in-tree. The old repo becomes
redundant and can be retired.

- Import the full site under docs/ (app, components, content, lib, public,
  scripts, config). The self-contained pnpm project sits alongside the existing
  engineering notes with no filename collisions.
- Re-point "Edit on GitHub" links from MHSanaei/3x-ui-docs to this repo's
  docs/content/docs path (docs/lib/shared.ts, docs/app/.../page.tsx).
- Add docs-ci.yml and docs-deploy.yml under .github/workflows/, scoped to
  docs/** and run with working-directory: docs, since GitHub only runs
  workflows from the repo-root .github/. deploy-static.yml's GitHub Pages
  publish (CNAME docs.sanaei.dev) carries over unchanged.

Follow-up (outside this commit): attach the docs.sanaei.dev custom domain to
this repository's Pages (or set the Vercel project's root directory to docs),
confirm the site is live from the monorepo, then delete MHSanaei/3x-ui-docs.
2026-07-07 23:07:14 +02:00

88 lines
2.8 KiB
TypeScript

// Pure decision logic for the protocol wizard. No React/DOM.
export type UseCase = 'censorship' | 'general' | 'speed';
export type CensorshipLevel = 'high' | 'medium' | 'low';
export type ClientSupport = 'modern' | 'broad';
export interface WizardAnswers {
useCase: UseCase;
censorship: CensorshipLevel;
clientSupport: ClientSupport;
}
export interface Recommendation {
protocol: string;
transport: string;
security: string;
rationale: string;
links: { title: string; href: string }[];
}
const REALITY_LINK = { title: 'REALITY setup', href: '/docs/config/reality' };
const TRANSPORTS_LINK = { title: 'Transports', href: '/docs/config/transports' };
const INBOUNDS_LINK = { title: 'Inbounds', href: '/docs/config/inbounds' };
export function recommend(a: WizardAnswers): Recommendation {
const heavyCensorship = a.useCase === 'censorship' || a.censorship === 'high';
if (heavyCensorship) {
if (a.clientSupport === 'modern') {
return {
protocol: 'VLESS',
transport: 'TCP',
security: 'REALITY + XTLS-Vision',
rationale:
'REALITY disguises traffic as a real TLS site without a certificate, and XTLS-Vision keeps it fast. The best stealth option for heavy censorship — needs a modern client.',
links: [REALITY_LINK, INBOUNDS_LINK],
};
}
return {
protocol: 'VMess',
transport: 'WebSocket',
security: 'TLS',
rationale:
'WebSocket + TLS works through CDNs and is supported by almost every client, making it a resilient fallback when broad client support matters more than peak stealth.',
links: [TRANSPORTS_LINK, INBOUNDS_LINK],
};
}
if (a.useCase === 'speed') {
if (a.clientSupport === 'modern') {
return {
protocol: 'VLESS',
transport: 'TCP',
security: 'REALITY + XTLS-Vision',
rationale:
'XTLS-Vision over raw TCP has the lowest overhead, so it is the fastest option for modern clients.',
links: [REALITY_LINK, TRANSPORTS_LINK],
};
}
return {
protocol: 'Trojan',
transport: 'TCP',
security: 'TLS',
rationale: 'Trojan over TCP + TLS is simple and fast, and is widely supported by clients.',
links: [INBOUNDS_LINK, TRANSPORTS_LINK],
};
}
// general use
if (a.clientSupport === 'modern') {
return {
protocol: 'VLESS',
transport: 'WebSocket',
security: 'TLS',
rationale:
'VLESS + WebSocket + TLS is a flexible, CDN-friendly default for everyday use with modern clients.',
links: [TRANSPORTS_LINK, INBOUNDS_LINK],
};
}
return {
protocol: 'VMess',
transport: 'WebSocket',
security: 'TLS',
rationale: 'VMess + WebSocket + TLS is the most broadly compatible everyday setup.',
links: [TRANSPORTS_LINK, INBOUNDS_LINK],
};
}