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

Function TJ2QX

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

Source from the content-addressed store, hash-verified

1929
1930//Trojan 类型 URI 转换成 QX, 包含小火箭类型
1931function TJ2QX(subs, Pudp, Ptfo, Pcert0, PTls13) {
1932 var ntrojan = []
1933 var cnt = subs.split("trojan://")[1]
1934 type = "trojan=";
1935 if (cnt.indexOf(":443") != -1) {
1936 ip = cnt.split("@")[1].split(":443")[0] + ":443";
1937 } else {
1938 ip = cnt.split("@")[1].split("?")[0].split("\n")[0].split("#")[0].trim(); //非 443 端口的奇葩机场?
1939 }
1940 pwd = cnt.split("@")[0]? "password=" + decodeURIComponent(cnt.split("@")[0]):"";
1941 obfs = "over-tls=true";
1942 pcert = cnt.indexOf("allowInsecure=0") != -1 ? "tls-verification=true" : "tls-verification=false";
1943 thost = cnt.indexOf("sni=") != -1? "tls-host="+cnt.split("sni=")[1].split(/&|#/)[0]:""
1944 thost = cnt.indexOf("peer=") != -1? "tls-host="+cnt.split("peer=")[1].split(/&|#/)[0]:thost
1945 ptls13 = PTls13 == 1 ? "tls13=true" : "tls13=false"
1946 puri = ""
1947 if (Pcert0 == 0) {
1948 pcert = "tls-verification=false"
1949 } else if (Pcert0 == 1) {
1950 pcert = "tls-verification=true"
1951 }
1952 pudp = (Pudp == 1 || cnt.indexOf("udp=1")!=-1) ? "udp-relay=true" : "udp-relay=false";
1953 ptfo = (Ptfo == 1 || cnt.indexOf("tfo=1")!=-1)? "fast-open=true" : "fast-open=false";
1954 //ptfo = cnt.indexOf("tfo=1") != -1? "fast-open=true" : ptfo
1955 tag = cnt.indexOf("#") != -1 ? "tag=" + decodeURIComponent(cnt.split("#").slice(-1)[0]) : "tag= [trojan]" + ip
1956 if (cnt.indexOf("&plugin=obfs-local")!=-1) {//小火箭内的websocket写法
1957 obfs = cnt.indexOf("obfs=websocket") != -1? "obfs=wss" : obfs
1958 thost=cnt.indexOf("obfs-host=") == -1? thost : "obfs-host=" + decodeURIComponent(cnt.split("obfs-host=")[1].split(";")[0].split("#")[0])
1959 puri = cnt.indexOf("obfs-uri=") == -1? puri : "obfs-uri=" + decodeURIComponent(cnt.split("obfs-uri=")[1].split(";")[0].split("#")[0])
1960 } else if (cnt.indexOf("&type=ws")!=-1 || cnt.indexOf("?type=ws")!=-1) {//v2rayN uri
1961 obfs = cnt.indexOf("security=tls") != -1? "obfs=wss" : obfs
1962 thost=cnt.indexOf("&host=") == -1? thost : "obfs-host=" + decodeURIComponent(cnt.split("&host=")[1].split("&")[0].split("#")[0])
1963 puri = cnt.indexOf("&path=") == -1? puri : "obfs-uri=" + decodeURIComponent(cnt.split("&path=")[1].split("&")[0].split("#")[0])
1964 }
1965 ntrojan.push(type + ip, pwd, obfs, pcert, thost, puri, pudp, ptfo, tag)
1966 QX = ntrojan.filter(Boolean).join(", ");
1967 //$notify("title","subtitle",QX)
1968 return QX;
1969}
1970
1971function joinx(total,item) {
1972 return total+":"+item

Callers 1

Subs2QXFunction · 0.85

Calls 3

indexOfMethod · 0.45
pushMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…