添加从Torjan Uri中获取sni值 (#52)

* 添加从Torjan Uri中获取sni值

感谢 Skyxim <skyxim@users.noreply.github.com>
This commit is contained in:
Skyxim 2021-09-09 18:34:12 +08:00 committed by GitHub
parent 87deb369fb
commit a9d8572060
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1376,13 +1376,23 @@ var ProxyUtils = (function () {
line = line.split("trojan://")[1]; line = line.split("trojan://")[1];
const [server, port] = line.split("@")[1].split("?")[0].split(":"); const [server, port] = line.split("@")[1].split("?")[0].split(":");
const name = decodeURIComponent(line.split("#")[1].trim()); const name = decodeURIComponent(line.split("#")[1].trim());
let paramArr = line.split("?")
let sni=null
if (paramArr.length > 1) {
paramArr=paramArr[1].split("#")[0].split("&")
const params = new Map(paramArr.map((item) => {
return item.split("=")
}))
sni = params.get("sni")
}
return { return {
name: name || `[Trojan] ${server}`, // trojan uri may have no server tag! name: name || `[Trojan] ${server}`, // trojan uri may have no server tag!
type: "trojan", type: "trojan",
server, server,
port, port,
password: line.split("@")[0], password: line.split("@")[0],
sni,
supported, supported,
}; };
}; };