feat: 新增 anytls/tuic/hysteria2/socks5 协议解析

新增 anytls、tuic(tuic-v5)、hysteria2、socks5/socks5-tls 解析器,
修复 vmess WebSocket path 处理,并优化 Docker 构建配置。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-23 23:43:35 +08:00
parent fb7a30489e
commit 3bdba3e50f
11 changed files with 278 additions and 5 deletions

View File

@@ -0,0 +1,28 @@
import type { ParsedNode } from './ss.js';
import { readInsecure } from './util.js';
// hysteria2://auth@host:port?sni=...&insecure=1&obfs=salamander&obfs-password=...#name
// hy2:// is an accepted alias for the scheme.
export function parseHysteria2(uri: string): ParsedNode {
const url = new URL(uri);
const server = url.hostname;
const port = parseInt(url.port || '443', 10);
const name = decodeURIComponent(url.hash.slice(1)) || 'Hysteria2';
// The auth string lives in the userinfo. For userpass auth it is "username:password".
const user = decodeURIComponent(url.username);
const pass = decodeURIComponent(url.password);
const auth = pass ? `${user}:${pass}` : user;
const params = url.searchParams;
const sni = params.get('sni') || '';
const obfs = params.get('obfs') || '';
const obfsPassword = params.get('obfs-password') || params.get('obfs_password') || '';
let line = `${name} = hysteria2, ${server}, ${port}, password=${auth}`;
if (sni) line += `, sni=${sni}`;
if (obfs === 'salamander' && obfsPassword) line += `, salamander-password=${obfsPassword}`;
line += `, skip-cert-verify=${readInsecure(params)}`;
return { name, type: 'hysteria2', server, port, surgeLine: line };
}