feat: fix ss

This commit is contained in:
2026-07-21 18:09:25 +08:00
parent d708240acf
commit 6b4285bc82
4 changed files with 35 additions and 11 deletions

View File

@@ -1,4 +1,5 @@
import type { ParsedNode } from './ss.js';
import { normalizeWsPath } from './util.js';
export function parseTrojan(uri: string): ParsedNode {
const url = new URL(uri);
@@ -9,7 +10,13 @@ export function parseTrojan(uri: string): ParsedNode {
const params = url.searchParams;
const sni = params.get('sni') || server;
const surgeLine = `${name} = trojan, ${server}, ${port}, password=${password}, tls=true, sni=${sni}, skip-cert-verify=false`;
let surgeLine = `${name} = trojan, ${server}, ${port}, password=${password}, tls=true, sni=${sni}, skip-cert-verify=false`;
if (params.get('type') === 'ws') {
const path = params.get('path') || '/';
const host = params.get('host') || sni;
surgeLine += `, ws=true, ws-path=${normalizeWsPath(path)}, ws-headers=Host:${host}`;
}
return { name, type: 'trojan', server, port, surgeLine };
}