| 1974 | |
| 1975 | //SS 类型 URI 转换 quanx 格式 |
| 1976 | function SS2QX(subs, Pudp, Ptfo) { |
| 1977 | var nssr = [] |
| 1978 | var cnt = subs.split("ss://")[1] |
| 1979 | if (cnt.split(":").length <= 6) { //排除难搞的 ipv6 节点 |
| 1980 | type = "shadowsocks="; |
| 1981 | let cntt = cnt.split("#")[0] |
| 1982 | //console.log(cntt) |
| 1983 | if (cntt.indexOf("@") != -1 && cntt.indexOf(":") != -1) { |
| 1984 | ip = cnt.split("@")[1].split("#")[0].split("/")[0].split("?")[0]; |
| 1985 | pwdmtd = Base64.decode(cnt.split("@")[0].replace(/-/g, "+").replace(/_/g, "/")).split("\u0000")[0].split(":") |
| 1986 | } else if (cntt.indexOf("?")==-1) { // 后部 b64 encode 类型 |
| 1987 | var cnt0 = Base64.decode(cnt.split("#")[0].replace(/-/g, "+").replace(/_/g, "/").split("\u0000")[0]); |
| 1988 | ip = cnt0.split("@")[1].split("#")[0].split("/")[0]; |
| 1989 | pwdmtd = cnt0.split("@")[0].split(":") |
| 1990 | } else if (cntt.indexOf("?") !=-1) { // 火箭类型? |
| 1991 | var cnt0 = Base64.decode(cnt.split("#")[0].split("?")[0].replace(/-/g, "+").replace(/_/g, "/").split("\u0000")[0]); |
| 1992 | var cnt1 = Base64.decode(cnt.split("#")[0].split("?")[1].split("=")[1].replace(/-/g, "+").replace(/_/g, "/").split("\u0000")[0]); |
| 1993 | ip = cnt0.split("@")[1].split("#")[0].split("/")[0]; |
| 1994 | pwdmtd = cnt0.split("@")[0].split(":") |
| 1995 | } |
| 1996 | mtd = "method=" + pwdmtd[0]; |
| 1997 | pwdmtd.splice(0,1) |
| 1998 | pwd = "password=" + pwdmtd.reduce(joinx); |
| 1999 | if (cntt.indexOf("v2ray-plugin")==-1 && cntt.indexOf("plugin=v2ray")==-1) { //Shadowrocket style v2-plugin |
| 2000 | obfs = cnt.split("obfs%3D")[1] != null ? ", obfs=" + cnt.split("obfs%3D")[1].split("%3B")[0].split("#")[0] : ""; |
| 2001 | obfshost = cnt.split("obfs-host%3D")[1] != null ? ", obfs-host=" + cnt.split("obfs-host%3D")[1].split("&")[0].split("#")[0] : ""; |
| 2002 | } else if (cnt1 != undefined){ |
| 2003 | cnt1 = JSON.parse(cnt1) |
| 2004 | obfs= cnt1.tls? ", obfs=wss" : ", obfs=ws" |
| 2005 | obfshost = cnt1.host? ", obfs-host="+cnt1.host+", tls-verification=false" : "" |
| 2006 | } else if (cntt.indexOf("v2ray-plugin")!=-1){ |
| 2007 | cnt1 = decodeURIComponent(cntt.split("v2ray-plugin")[1]) |
| 2008 | obfs= cnt1.indexOf("tls")!=-1? ", obfs=wss" : ", obfs=ws" |
| 2009 | obfshost = cnt1.indexOf("host=")!=-1? ", obfs-host="+cnt1.split("host=")[1].split(";")[0].split("#")[0].trim() : "" |
| 2010 | obfshost = obfshost != "obfs-host="? obfshost : "" |
| 2011 | //$notify("CNTT","",cnt1+obfs+obfshost) |
| 2012 | } else if (cntt.indexOf("plugin=v2ray")!=-1) { |
| 2013 | cnt1 = decodeURIComponent(cntt.split("plugin=v2ray")[1]) |
| 2014 | obfs= cnt1.indexOf("tls")!=-1? ", obfs=wss" : ", obfs=ws" |
| 2015 | obfshost = cnt1.indexOf("host=")!=-1? ", obfs-host="+cnt1.split("host=")[1].split(";")[0].split("#")[0].trim() : "" |
| 2016 | obfshost = obfshost != "obfs-host="? obfshost : "" |
| 2017 | //$notify("CNTT","",cnt1+obfs+obfshost) |
| 2018 | |
| 2019 | } |
| 2020 | tag = decodeURIComponent(cnt.split("#")[1])!="undefined"? "tag=" + decodeURIComponent(cnt.split("#")[1]) : "tag=" + ip |
| 2021 | pudp = Pudp == 1 ? "udp-relay=true" : "udp-relay=false"; |
| 2022 | ptfo = Ptfo == 1 ? "fast-open=true" : "fast-open=false"; |
| 2023 | nssr.push(type + ip, pwd, mtd + obfs + obfshost, pudp, ptfo, tag) |
| 2024 | QX = nssr.join(", ") |
| 2025 | //$notify(QX) |
| 2026 | return QX; |
| 2027 | } |
| 2028 | } |
| 2029 | |
| 2030 | |
| 2031 | //SSD 类型 URI 转换 quanx 格式 |