MCPcopy Index your code
hub / github.com/Moli-X/Resources / Subs2QX

Function Subs2QX

Script/Parser.js:1427–1524  ·  view source on GitHub ↗
(subs, Pudp, Ptfo, Pcert0, PTls13)

Source from the content-addressed store, hash-verified

1425
1426//混合订阅类型,用于未整体进行 base64 encode 以及已经 decode 后的类型
1427function Subs2QX(subs, Pudp, Ptfo, Pcert0, PTls13) {
1428 if (Pdbg) {$notify("subs", "node", subs)}
1429 var list0 = subs.split("\n");
1430 var QuanXK = ["shadowsocks=", "trojan=", "vmess=", "http=","socks5="];
1431 var SurgeK = ["=ss,", "=vmess,", "=trojan,", "=http,", "=https,", "=custom,", "=socks5", "=socks5-tls"];
1432 var LoonK = ["=shadowsocks", "=shadowsocksr"]
1433 var QXlist = [];
1434 var failedList = [];
1435 for (var i = 0; i < list0.length; i++) {
1436 var node = ""
1437 //if (Pdbg) {$notify(i, "node", list0[i])}
1438 if (list0[i].trim().length > 3 && !/\;|\/|\#/.test(list0[i][0]) && list0[i].indexOf(" url ")==-1) {
1439 var type = list0[i].split("://")[0].trim()
1440 var listi = list0[i].replace(/ /g, "")
1441 var tag0 = list0[i].indexOf("tag=")!=-1 ? list0[i].split(/\&*(emoji|udp|tfo|cert|rename|replace)\=/)[0].split("tag=")[1] : ""
1442 list0[i] = (type == "vmess" || type=="ssr") ? list0[i].split(/#|,|,/)[0] : list0[i]
1443 const NodeCheck = (item) => listi.toLowerCase().indexOf(item) != -1;
1444 const NodeCheck1 = (item) => listi.toLowerCase().indexOf(item) == 0;
1445 try {
1446 if (Pdbg) {$notify(i, type, list0[i])}
1447 if (type == "vmess" && (list0[i].indexOf("remark=") == -1 && list0[i].indexOf("remarks=") == -1) && !/(obfs|alterId)\=/.test(list0[i])) {
1448 var bnode = Base64.decode(list0[i].split("vmess://")[1])
1449 if (bnode.indexOf("over-tls=") == -1) { //v2rayN
1450 node = V2QX(list0[i], Pudp, Ptfo, Pcert0, PTls13)
1451 } else { //quantumult 类型
1452 node = VQ2QX(list0[i], Pudp, Ptfo, Pcert0, PTls13)
1453 }
1454 node = tag0 != "" ? URI_TAG(node, tag0) : node
1455 } else if (type == "vmess" && ( list0[i].indexOf("remark=") != -1 || list0[i].indexOf("remarks=") != -1 || /(obfs|alterId)\=/.test(list0[i]))) { //shadowrocket 类型
1456 node = VR2QX(list0[i], Pudp, Ptfo, Pcert0, PTls13)
1457 node = tag0 != "" ? URI_TAG(node, tag0) : node
1458 } else if (type == "socks" && list0[i].indexOf("remarks=") != -1) { //shadowrocket socks5 类型
1459 node = S5R2QX(list0[i])
1460 node = tag0 != "" ? URI_TAG(node, tag0) : node
1461 } else if (type == "ssocks" && list0[i].indexOf("remarks=") != -1) { //shadowrocket socks5-tls 类型
1462 node = S5R2QX(list0[i],tlsp="over-tls")
1463 node = tag0 != "" ? URI_TAG(node, tag0) : node
1464 } else if (type == "ssr") {
1465 node = SSR2QX(list0[i], Pudp, Ptfo)
1466 node = tag0 != "" ? URI_TAG(node, tag0) : node
1467 } else if (type == "ss") {
1468 node = SS2QX(list0[i], Pudp, Ptfo)
1469 node = tag0 != "" ? URI_TAG(node, tag0) : node
1470 } else if (type == "ssd") {
1471 node = SSD2QX(list0[i], Pudp, Ptfo)
1472 } else if (type == "trojan") {
1473 node = TJ2QX(list0[i], Pudp, Ptfo, Pcert0, PTls13)
1474 node = tag0 != "" ? URI_TAG(node, tag0) : node
1475 } else if ((type == "https" || type == "http") && list0[i].indexOf(",") == -1) {
1476 if (listi.indexOf("@") != -1) {
1477 node = HPS2QX(list0[i], Ptfo, Pcert0, PTls13)
1478 node = tag0 != "" ? URI_TAG(node, tag0) : node
1479 } else { // b64 类型 http/https
1480 var listh = Base64.decode(listi.split(type+"://")[1].split("#")[0].split("?")[0])
1481 listh = list0[i].replace(listi.split(type+"://")[1].split("#")[0].split("?")[0],listh) //type+"://" + listh + "#" + listi.split(type+"://")[1].split("#")[1]
1482 node = HPS2QX(listh, Ptfo, Pcert0, PTls13)
1483 node = tag0 != "" ? URI_TAG(node, tag0) : node
1484 }

Callers 1

ResourceParseFunction · 0.85

Calls 15

V2QXFunction · 0.85
VQ2QXFunction · 0.85
URI_TAGFunction · 0.85
VR2QXFunction · 0.85
S5R2QXFunction · 0.85
SSR2QXFunction · 0.85
SS2QXFunction · 0.85
SSD2QXFunction · 0.85
TJ2QXFunction · 0.85
HPS2QXFunction · 0.85
QX_TLSFunction · 0.85
isQuanXFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…