| 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 格式 |
| 1600 | function 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 转换 |
| 1629 | function VQ2QX(subs, Pudp, Ptfo, Pcert0, PTls13) { |