| 1664 | |
| 1665 | //Shadowrocket 格式的 vmess URI 转换 |
| 1666 | function VR2QX(subs, Pudp, Ptfo, Pcert0, PTls13) { |
| 1667 | var server = String(Base64.decode(subs.replace("vmess://", "").split("?remark")[0].split("&remark")[0].split("?")[0]).trim()).split("\u0000")[0] |
| 1668 | var node = "" |
| 1669 | var ip = "vmess=" + server.split("@")[1] + ", " + "method=aes-128-gcm, " + "password=" + server.split("@")[0].split(":")[1] + ", " |
| 1670 | var tag = /remarks*=/.test(subs)? "tag=" + decodeURIComponent(subs.split(/remarks*=/)[1].split("&")[0]) : "tag="+server.split("@")[1] //部分无节点名的情况 |
| 1671 | var tfo = subs.indexOf("tfo=1") != -1 ? "fast-open=true, " : "fast-open=false, " |
| 1672 | var udp = Pudp == 1 ? "udp-relay=false, " : "udp-relay=false, "; |
| 1673 | var pdrop = 0 |
| 1674 | node = ip + tfo + udp |
| 1675 | var obfs = subs.indexOf("obfs=")!=-1 ? subs.split("obfs=")[1].split("&")[0].trim() : "none" |
| 1676 | if (obfs == "none") { // |
| 1677 | obfs = subs.indexOf("tls=1") != -1 ? "obfs=over-tls, " : "" //over-tls |
| 1678 | } else if (obfs == "websocket" || obfs == "http") { |
| 1679 | obfs = obfs == "http" ? "obfs=http, " : "obfs=ws, " // http 类型 |
| 1680 | obfs = subs.indexOf("tls=1") != -1 ? "obfs=wss, " : obfs //ws,wss 类型 |
| 1681 | var ouri = subs.indexOf("&path=") != -1 ? decodeURIComponent(subs.split("&path=")[1].split("&")[0]) : "/" //ws,wss 类型 |
| 1682 | obfs = obfs + "obfs-uri=" + ouri + ", " |
| 1683 | var host = subs.indexOf("&obfsParam=") != -1 ? decodeURIComponent(subs.split("&obfsParam=")[1].split("&")[0].split("\n")[0]).split("\n")[0].trim() : "" |
| 1684 | if (host.indexOf("\"Host\"")!=-1 && host.indexOf("{")!=-1) { |
| 1685 | host = JSON.parse(host)["Host"] |
| 1686 | } |
| 1687 | host = host!="{}" && host ? "obfs-host=" + host + ", " : "" |
| 1688 | obfs = obfs + host |
| 1689 | } else if (obfs=="grpc" || obfs =="h2") { |
| 1690 | Perror = 1 // 不需要反馈的类型 |
| 1691 | if (Pntf0!=0) { |
| 1692 | $notify( "⚠️ Quantumult X 暂不支持该类型节点", "已忽略以下 grpc|h2 vmess 节点",subs) |
| 1693 | } |
| 1694 | pdrop = 1 |
| 1695 | } |
| 1696 | if (obfs.indexOf("obfs=over-tls") != -1 || obfs.indexOf("obfs=wss") != -1) { |
| 1697 | var cert = Pcert0 != 0 || subs.indexOf("allowInsecure=1") != -1 ? "tls-verification=false, " : "tls-verification=true, " |
| 1698 | var tls13 = PTls13 == 1 ? "tls13=true, " : "" |
| 1699 | obfs = obfs + cert + tls13 |
| 1700 | } |
| 1701 | caead="aead=false, " |
| 1702 | if (subs.indexOf("alterId=") != -1) { |
| 1703 | caead = Number(subs.split("alterId=")[1].split("&")[0]) != 0 ? "aead=false, " : "" |
| 1704 | } |
| 1705 | node = pdrop==0? node + obfs +caead+ tag : "" |
| 1706 | //$notify(node) |
| 1707 | return node |
| 1708 | } |
| 1709 | |
| 1710 | //Shadowrocket 格式的 socks URI 转换 |
| 1711 | function S5R2QX(cnt,tlsp="false") { |