MCPcopy Create free account
hub / github.com/Moli-X/Resources / HPS2QX

Function HPS2QX

Script/Parser.js:1600–1626  ·  view source on GitHub ↗
(subs, Ptfo, Pcert0, PTls13)

Source from the content-addressed store, hash-verified

1598//http=example.com:443, username=name, password=pwd, over-tls=true, tls-host=example.com, tls-verification=true, tls13=true, fast-open=false, udp-relay=false, tag=http-tls-02
1599//HTTPS 类型 URI 转换成 QUANX 格式
1600function HPS2QX(subs, Ptfo, Pcert0, PTls13) {
1601 var type = subs.indexOf("https://")!=-1? "https" : "http"
1602 var server = subs.replace("https://", "").replace("http://", "").trim()//Base64.decode(subs.replace("https://", "")).trim().split("\u0000")[0];
1603 var nss = []
1604 if (server != "") {
1605 if (server.indexOf("@")!=-1) {
1606 var ipport = "http=" + server.split("@")[1].split("#")[0].split("/")[0].split("?")[0];
1607 var uname = "username=" + server.split(":")[0];
1608 var pwd = "password=" + server.split("@")[0].split(":")[1];
1609 } else {
1610 var ipport = server.split("#")[0].indexOf(":")==-1? "http=" + Base64.decode(server.split("#")[0].split("?")[0]) : "http=" + server.split("#")[0].split("?")[0]; // https://b64(ipport)
1611 }
1612 var tag = "tag=" + decodeURIComponent(server.split("#")[1]);
1613 var tls = type == "https"? "over-tls=true": "";
1614 var thost = subs.indexOf("peer=")!= -1? "tls-host=" + subs.split("peer=")[1].split("#")[0].split("&")[0] : "" // 存在peers参数时 https://b64(ipport)?peer=xxx#server-remarks
1615 var cert = Pcert0 != 0 ? "tls-verification=true" : "tls-verification=false";
1616 var tfo = Ptfo == 1 ? "fast-open=true" : "fast-open=false";
1617 var tls13 = PTls13 == 1 ? "tls13=true" : "tls13=false";
1618 if (tls=="") {
1619 cert=""
1620 tls13=""
1621 }
1622 nss.push(ipport, uname, pwd, tls, thost, cert, tfo, tls13, tag)
1623 }
1624 var QX = nss.filter(Boolean).join(",");
1625 return QX
1626}
1627
1628//quantumult 格式的 vmess URI 转换
1629function VQ2QX(subs, Pudp, Ptfo, Pcert0, PTls13) {

Callers 1

Subs2QXFunction · 0.85

Calls 3

indexOfMethod · 0.45
pushMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected