init: init proj

This commit is contained in:
2026-08-25 11:35:05 +08:00
commit bf7f2df67e
80 changed files with 9936 additions and 0 deletions

50
shared/src/protocols.ts Normal file
View File

@@ -0,0 +1,50 @@
export const PROTOCOLS = ['vmess', 'trojan', 'shadowsocks', 'hysteria2'] as const;
export type Protocol = (typeof PROTOCOLS)[number];
export const CLIENTS = ['surge', 'shadowrocket', 'clash'] as const;
export type ClientType = (typeof CLIENTS)[number];
export const CLIENT_LABELS: Record<ClientType, string> = {
surge: 'Surge (macOS)',
shadowrocket: 'ShadowRocket (iOS)',
clash: 'ClashMeta (Android)',
};
/**
* ShadowRocket 分两步导入:节点走订阅、策略组与规则走配置文件。
* 配置文件里的策略组用 `use=true` 引用订阅,因此 App 内的订阅名必须与此一致。
*/
export const SHADOWROCKET_SUB_NAME = 'Proxy Station';
export type Egress = 'direct' | 'warp' | 'unknown';
/** Surge 与 Clash 使用 IETF 命名,Xray 分享链接使用简名 */
export const SS_CIPHER_ALIASES: Record<string, string> = {
'chacha20-poly1305': 'chacha20-ietf-poly1305',
'xchacha20-poly1305': 'xchacha20-ietf-poly1305',
};
export function normalizeSsCipher(method: string): string {
return SS_CIPHER_ALIASES[method] ?? method;
}
export interface NodeCapabilityInput {
protocol: Protocol;
network: 'tcp' | 'ws';
}
export interface CapabilityVerdict {
ok: boolean;
reason?: string;
}
/**
* 客户端能力矩阵:不支持的组合在下发订阅时自动屏蔽。
* Surge 的 ss 类型没有 WebSocket 传输(仅 simple-obfs),SS over WS 线路必须排除。
*/
export function clientSupports(client: ClientType, node: NodeCapabilityInput): CapabilityVerdict {
if (client === 'surge' && node.protocol === 'shadowsocks' && node.network === 'ws') {
return { ok: false, reason: 'Surge 不支持 Shadowsocks over WebSocket' };
}
return { ok: true };
}