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

Function SVmess2QX

Script/Parser.js:2548–2576  ·  view source on GitHub ↗
(content)

Source from the content-addressed store, hash-verified

2546
2547// surge 中的 Vmess 类型
2548function SVmess2QX(content) {
2549 var cnt = content;
2550 var tag = "tag=" + cnt.split("=")[0].trim();
2551 var ipport = cnt.split(",")[1].trim() + ":" + cnt.split(",")[2].trim();
2552 var puname = cnt.indexOf("username") != -1 ? "password=" + cnt.split("username")[1].split(",")[0].split("=")[1].trim() : "";
2553 var pmtd = "method=aes-128-gcm";
2554 var ptls13 = paraCheck(cnt, "tls13") == "true" ? "tls13=true" : "tls13=false";
2555 var pverify = cnt.replace(/ /g,"").indexOf("skip-cert-verify=false") != -1 ? "tls-verification=true" : "tls-verification=false";
2556 pvefify = Pcert0 == 1? "tls-verification=true" : pverify ;
2557 if (paraCheck(cnt.replace(/tls13/, ""), "tls") == "true" && paraCheck(cnt.replace(/ws-header/, ""), "ws") == "true") {
2558 pobfs = "obfs=wss" + ", " + ptls13 + ", " + pverify
2559 } else if (paraCheck(cnt.replace(/ws-header/, ""), "ws") == "true") {
2560 pobfs = "obfs=ws"
2561 } else if (paraCheck(cnt.replace(/tls13/, ""), "tls") != "false") {
2562 pobfs = "obfs=over-tls" + ", " + ptls13 + ", " + pverify
2563 } else if (paraCheck(cnt.replace(/ws-header/, ""), "ws") == "false") {
2564 pobfs = ""
2565 }
2566 var puri = paraCheck(cnt, "ws-path") != "false" ? "obfs-uri=" + cnt.split("ws-path")[1].split(",")[0].split("=")[1].trim() : "obfs-uri=/"
2567 var phost = cnt.indexOf("ws-headers") != -1 ? "obfs-host=" + cnt.split("ws-headers")[1].split(",")[0].split("=")[1].split(":")[1].trim() : "";
2568 if (pobfs.indexOf("ws" || "wss") != -1) {
2569 if (phost != "") {
2570 pobfs = pobfs + ", " + puri + ", " + phost
2571 } else { pobfs = pobfs + ", " + puri }
2572 }
2573 var ptfo = paraCheck(cnt, "tfo") == "true" ? "fast-open=true" : "fast-open=false";
2574 var nserver = pobfs != "" ? "vmess= " + [ipport, puname, pmtd, pobfs, ptfo, tag].join(", ") : "vmess= " + [ipport, puname, pmtd, ptfo, tag].join(", ");
2575 return nserver
2576}
2577
2578// 用于过滤非节点部分(比如整份配置中其它内容)
2579function isSurge(content) {

Callers 1

Surge2QXFunction · 0.85

Calls 3

paraCheckFunction · 0.85
indexOfMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected