feat: fix ss
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user