vmess-http-type support

This commit is contained in:
Shawn
2021-07-26 21:14:09 +08:00
parent ecc76c1ea6
commit 756372965b
2 changed files with 91 additions and 67 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -1,5 +1,5 @@
/**
☑️ 资源解析器 ©𝐒𝐡𝐚𝐰𝐧 ⟦2021-07-26 13:58⟧
☑️ 资源解析器 ©𝐒𝐡𝐚𝐰𝐧 ⟦2021-07-26 21:28⟧
----------------------------------------------------------
🛠 发现 𝐁𝐔𝐆 请反馈: @Shawn_KOP_bot
⛳️ 关注 🆃🅶 相关频道: https://t.me/QuanX_API
@@ -139,6 +139,7 @@ var Phin0 = mark0 && para1.indexOf("inhn=") != -1 ? (para1.split("inhn=")[1].spl
var Phout0 = mark0 && para1.indexOf("outhn=") != -1 ? (para1.split("outhn=")[1].split("&")[0].split("+")).map(decodeURIComponent) : null; //hostname
var Preplace = mark0 && para1.indexOf("replace=") != -1 ? para1.split("replace=")[1].split("&")[0] : null; //filter/rewrite 正则替换
var Pemoji = mark0 && para1.indexOf("emoji=") != -1 ? para1.split("emoji=")[1].split("&")[0] : null;
var Pdbg = mark0 && para1.indexOf("dbg=") != -1 ? para1.split("dbg=")[1].split("&")[0] : null;
var Pudp0 = mark0 && para1.indexOf("udp=") != -1 ? para1.split("udp=")[1].split("&")[0] : 0;
var Ptfo0 = mark0 && para1.indexOf("tfo=") != -1 ? para1.split("tfo=")[1].split("&")[0] : 0;
var Prname = mark0 && para1.indexOf("rename=") != -1 ? para1.split("rename=")[1].split("&")[0].split("+") : null;
@@ -197,6 +198,9 @@ function Parser() {
if (type0 != "web"){
try {
//$notify(type0,"hh")
if (Pdbg){
$notify(link0,type0,content0)
}
total = ResourceParse();
} catch (err) {
@@ -1183,10 +1187,10 @@ function VQ2QX(subs, Pudp, Ptfo, Pcert, Ptls13) {
var ip = "vmess=" + server.split(",")[1].trim() + ":" + server.split(",")[2].trim() + ", " + "method=aes-128-gcm, " + "password=" + server.split(",")[4].split("\"")[1] + ", "
var tag = "tag=" + server.split("=")[0]
var tfo = subs.indexOf("tfo=1") != -1 ? "fast-open=true, " : "fast-open=false, "
var udp = Pudp == 1 ? "udp-relay=false, " : "udp-relay=false, ";
var udp = Pudp == 1 ? "udp-relay=false, " : "udp-relay=false, "; // 不支持 vmess 类型 udp
node = ip + tfo + udp
var obfs = ""
if (server.indexOf("obfs=") == -1) { // 非 ws 类型
if (server.indexOf("obfs=") == -1) { // 非 ws/http 类型
obfs = server.indexOf("over-tls=true") != -1 ? "obfs=over-tls, " : "" //over-tls
var host = server.indexOf("tls-host") != -1 ? "obfs-host=" + server.split("tls-host=")[1].split(",")[0] + ", " : ""
obfs = obfs + host
@@ -1196,6 +1200,12 @@ function VQ2QX(subs, Pudp, Ptfo, Pcert, Ptls13) {
obfs = obfs + uri
var host = server.indexOf("obfs-header=") != -1 ? "obfs-host=" + server.split("obfs-header=\"Host:")[1].split("[")[0].trim() + ", " : ""
obfs = obfs + host
} else if (server.indexOf("obfs=http") != -1) {
obfs = "obfs=http, "
var uri = server.indexOf("obfs-path=") != -1 ? "obfs-uri=" + server.split("obfs-path=")[1].split("\"")[1] + ", " : "obfs-uri=/, "
obfs = obfs + uri
var host = server.indexOf("obfs-header=") != -1 ? "obfs-host=" + server.split("obfs-header=\"Host:")[1].split("[")[0].trim() + ", " : ""
obfs = obfs + host
}
if (obfs.indexOf("obfs=over-tls") != -1 || obfs.indexOf("obfs=wss") != -1) {
var cert = Pcert != 0 || subs.indexOf("allowInsecure=1") != -1 ? "tls-verification=false, " : "tls-verification=true, "
@@ -1206,6 +1216,7 @@ function VQ2QX(subs, Pudp, Ptfo, Pcert, Ptls13) {
return node
}
//Shadowrocket 格式的 vmess URI 转换
function VR2QX(subs, Pudp, Ptfo, Pcert, Ptls13) {
var server = String(Base64.decode(subs.replace("vmess://", "").split("?remarks")[0]).trim()).split("\u0000")[0]
@@ -1218,8 +1229,10 @@ function VR2QX(subs, Pudp, Ptfo, Pcert, Ptls13) {
var obfs = subs.split("obfs=")[1].split("&")[0]
if (obfs == "none") { //
obfs = subs.indexOf("tls=1") != -1 ? "obfs=over-tls, " : "" //over-tls
} else if (obfs == "websocket") {
obfs = subs.indexOf("tls=1") != -1 ? "obfs=wss, " : "obfs=ws, " //ws,wss 类型
} else if (obfs == "websocket" || obfs == "http") {
console.log(obfs)
obfs = obfs == "http" ? "obfs=http, " : "obfs=ws, " // http 类型
obfs = subs.indexOf("tls=1") != -1 ? "obfs=wss, " : obfs //ws,wss 类型
var ouri = subs.indexOf("&path=") != -1 ? subs.split("&path=")[1].split("&")[0] : "/" //ws,wss 类型
obfs = obfs + "obfs-uri=" + ouri + ", "
var host = subs.indexOf("&obfsParam=") != -1 ? decodeURIComponent(subs.split("&obfsParam=")[1].split("&")[0]) : ""
@@ -1238,8 +1251,10 @@ function VR2QX(subs, Pudp, Ptfo, Pcert, Ptls13) {
return node
}
//V2RayN uri转换成 QUANX 格式
function V2QX(subs, Pudp, Ptfo, Pcert, Ptls13) {
//console.log("v2 type",subs)
var cert = Pcert
var tls13 = Ptls13
var server = String(Base64.decode(subs.replace("vmess://", "")).trim()).split("\u0000")[0];
@@ -1295,6 +1310,12 @@ function Pobfs(jsonl, Pcert, Ptls13) {
host0 = jsonl.host && jsonl.host != "" ? ", obfs-host=" + jsonl.host : "";
obfsi.push(obfs0 + host0)
return obfsi.join(", ")
} else if (jsonl.tls == "http"){
obfs0 = "obfs=http";
uri0 = jsonl.path && jsonl.path != "" ? "obfs-uri=" + jsonl.path : "obfs-uri=/";
uri0 = uri0.indexOf("uri=/")!=-1 ? uri0:uri0.replace("uri=","uri=/")
host0 = jsonl.host && jsonl.host != "" ? "obfs-host=" + jsonl.host + ", " : "";
obfsi.push(obfs0, host0 + uri0);
} else if (jsonl.net !="tcp"){ // 过滤掉 h2/http 等类型
return "NOT-SUPPORTTED"
} else if (jsonl.net =="tcp" && jsonl.type != "none") {
@@ -2079,13 +2100,15 @@ function CV2QX(cnt) {
ipt = cnt.server+":"+cnt.port
pwd = "password=" + cnt.uuid
mtd = "method="+ "aes-128-gcm" //cnt.cipher
udp = cnt.udp ? "udp-relay=false" : "udp-relay=false"
udp = cnt.udp ? "udp-relay=false" : "udp-relay=false" //暂不支持
tfo = cnt.tfo ? "fast-open=true" : "fast-open=false"
obfs = ""
if (cnt.network == "ws" && cnt.tls) {
obfs = "obfs=wss"
} else if (cnt.network == "ws"){
obfs = "obfs=ws"
} else if (cnt.network == "http"){
obfs = "obfs=http"
} else if (cnt.tls){
obfs = "obfs=over-tls"
}
@@ -2103,6 +2126,7 @@ function CV2QX(cnt) {
return node
}
//Clash Trojan
function CT2QX(cnt) {
tag = "tag="+cnt.name.replace(/\\U.+?\s{1}/gi," ")