From eb4c801ef908e168bceb96c5ad1261ba6446dea4 Mon Sep 17 00:00:00 2001 From: Shawn <45581750+KOP-XIAO@users.noreply.github.com> Date: Mon, 24 Aug 2020 21:21:02 +0800 Subject: [PATCH] =?UTF-8?q?clash-ssr=20=E7=B1=BB=E5=9E=8B=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=EF=BC=8C=E4=BB=A5=E5=8F=8A=E6=84=9A=E8=A0=A2=E3=81=AE?= =?UTF-8?q?=E6=89=8B=E5=8A=A8=E4=BF=AE=E6=AD=A3=E6=9F=90=E4=BA=9B=20yaml?= =?UTF-8?q?=20=E6=A0=BC=E5=BC=8F=E7=9A=84=E8=A7=A3=E6=9E=90=F0=9F=98=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/resource-parser.js | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/Scripts/resource-parser.js b/Scripts/resource-parser.js index 8dcacdc..cd0707b 100644 --- a/Scripts/resource-parser.js +++ b/Scripts/resource-parser.js @@ -1,5 +1,5 @@ /** -☑️ 资源解析器 ©𝐒𝐡𝐚𝐰𝐧 ⟦2020-08-24 17:30⟧ +☑️ 资源解析器 ©𝐒𝐡𝐚𝐰𝐧 ⟦2020-08-24 21:30⟧ ---------------------------------------------------------- 🛠 发现 𝐁𝐔𝐆 请反馈: @Shawn_KOP_bot ⛳️ 关注 🆃🅶 相关频道: https://t.me/QuanX_API @@ -1461,9 +1461,13 @@ function LoonSSR2QX(cnt) { } -// manual fix yaml parser mistakes +// stuppid manual fix for yaml parse mistakes function YAMLFix(cnt){ - cnt = cnt.replace(/ -\n.*name/g," - name") //类型 ① 修复 + cnt = cnt.replace(/: {/g, ": {, ").replace(/, host/g,", host") + cnt = cnt.replace(/name: /g,"name: \"").replace(/, server:/g,"\", server:") + cnt = cnt.replace(/{|}/g,"").replace(/,/g,"\n ") + cnt = cnt.replace(/ -\n.*name/g," - name") + //console.log(cnt) return cnt } @@ -1481,6 +1485,8 @@ function Clash2QX(cnt) { typec = node.type if (typec == "ss") { node = CSS2QX(node) + } else if (typec == "ssr"){ + node = CSSR2QX(node) } else if (typec == "vmess"){ node = CV2QX(node) } else if (typec == "trojan"){ @@ -1508,6 +1514,23 @@ function CSS2QX(cnt) { return node } +//Clash ssr type server +function CSSR2QX(cnt) { + tag = "tag="+cnt.name.replace(/\\U.+?\s{1}/gi,"") + ipt = cnt.server+":"+cnt.port + pwd = "password=" + cnt.password + mtd = "method="+ cnt.cipher + udp = cnt.udp ? "udp-relay=true" : "udp-relay=false" + tfo = cnt.tfo ? "fast-open=true" : "fast-open=false" + prot = "ssr-protocol=" + cnt.protocol + ppara = "ssr-protocol-param=" + cnt["protocol-param"] + obfs = "obfs=" + cnt.obfs + ohost = "obfs-host=" + cnt["obfs-param"] + node = "shadowsocks="+[ipt, pwd, mtd, udp, tfo, prot, ppara, obfs, ohost, tag].filter(Boolean).join(", ") + //console.log(node) + return node +} + //Clash vmess type server function CV2QX(cnt) { tag = "tag="+cnt.name.replace(/\\U.+?\s{1}/gi," ") @@ -1558,7 +1581,7 @@ function CH2QX(cnt){ pwd = cnt.password ? "password=" + cnt.password : "" tls = cnt.tls ? "over-tls=true" : "" cert = cnt["skip-cert-verify"] && cnt.tls ? "tls-verification=false" : "" - if (Pcert0 == 0) { cert = "tls-verification=false" } + if (Pcert0 == 0 && cnt.tls) { cert = "tls-verification=false" } node = "http="+[ipt, uname, pwd, tls, cert, tag].filter(Boolean).join(", ") //console.log(node) return node