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:
28
server/src/parsers/hysteria2.ts
Normal file
28
server/src/parsers/hysteria2.ts
Normal 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 };
|
||||
}
|
||||
Reference in New Issue
Block a user