Skip to content

Commit

Permalink
luci: Xray Transport: Remove HTTP
Browse files Browse the repository at this point in the history
Migrated to XHTTP "stream-one" mode.
XTLS/Xray-core@ae62a0f
  • Loading branch information
lwb1978 authored Dec 23, 2024
1 parent c6bfee0 commit 52ab893
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 86 deletions.
20 changes: 0 additions & 20 deletions luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ o = s:option(ListValue, _n("transport"), translate("Transport"))
o:value("raw", "RAW (TCP)")
o:value("mkcp", "mKCP")
o:value("ws", "WebSocket")
o:value("h2", "HTTP/2")
o:value("ds", "DomainSocket")
o:value("quic", "QUIC")
o:value("grpc", "gRPC")
Expand Down Expand Up @@ -496,25 +495,6 @@ o = s:option(Value, _n("ws_heartbeatPeriod"), translate("HeartbeatPeriod(second)
o.datatype = "integer"
o:depends({ [_n("transport")] = "ws" })

-- [[ HTTP/2部分 ]]--
o = s:option(Value, _n("h2_host"), translate("HTTP/2 Host"))
o:depends({ [_n("transport")] = "h2" })

o = s:option(Value, _n("h2_path"), translate("HTTP/2 Path"))
o.placeholder = "/"
o:depends({ [_n("transport")] = "h2" })

o = s:option(Flag, _n("h2_health_check"), translate("Health check"))
o:depends({ [_n("transport")] = "h2" })

o = s:option(Value, _n("h2_read_idle_timeout"), translate("Idle timeout"))
o.default = "10"
o:depends({ [_n("h2_health_check")] = true })

o = s:option(Value, _n("h2_health_check_timeout"), translate("Health check timeout"))
o.default = "15"
o:depends({ [_n("h2_health_check")] = true })

-- [[ DomainSocket部分 ]]--
o = s:option(Value, _n("ds_path"), "Path", translate("A legal file path. This file must not exist before running."))
o:depends({ [_n("transport")] = "ds" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ o = s:option(ListValue, _n("transport"), translate("Transport"))
o:value("raw", "RAW")
o:value("mkcp", "mKCP")
o:value("ws", "WebSocket")
o:value("h2", "HTTP/2")
o:value("ds", "DomainSocket")
o:value("quic", "QUIC")
o:value("grpc", "gRPC")
Expand Down Expand Up @@ -245,14 +244,6 @@ o = s:option(Value, _n("xhttp_maxconcurrentuploads"), translate("maxConcurrentUp
o.default = "10"
o:depends({ [_n("transport")] = "xhttp" })

-- [[ HTTP/2部分 ]]--

o = s:option(Value, _n("h2_host"), translate("HTTP/2 Host"))
o:depends({ [_n("transport")] = "h2" })

o = s:option(Value, _n("h2_path"), translate("HTTP/2 Path"))
o:depends({ [_n("transport")] = "h2" })

-- [[ TCP部分 ]]--

-- TCP伪装
Expand Down
9 changes: 0 additions & 9 deletions luci-app-passwall/luasrc/passwall/util_xray.lua
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,6 @@ function gen_outbound(flag, node, tag, proxy_table)
earlyDataHeaderName = (node.ws_earlyDataHeaderName) and node.ws_earlyDataHeaderName or nil,
heartbeatPeriod = tonumber(node.ws_heartbeatPeriod) or nil
} or nil,
httpSettings = (node.transport == "h2") and {
path = node.h2_path or "/",
host = node.h2_host,
read_idle_timeout = tonumber(node.h2_read_idle_timeout) or nil,
health_check_timeout = tonumber(node.h2_health_check_timeout) or nil
} or nil,
dsSettings = (node.transport == "ds") and
{path = node.ds_path} or nil,
quicSettings = (node.transport == "quic") and {
Expand Down Expand Up @@ -488,9 +482,6 @@ function gen_config_server(node)
host = node.ws_host or nil,
path = node.ws_path
} or nil,
httpSettings = (node.transport == "h2") and {
path = node.h2_path, host = node.h2_host
} or nil,
dsSettings = (node.transport == "ds") and {
path = node.ds_path
} or nil,
Expand Down
101 changes: 75 additions & 26 deletions luci-app-passwall/luasrc/view/passwall/node_list/link_share_man.htm
Original file line number Diff line number Diff line change
Expand Up @@ -810,16 +810,22 @@
}

queryParam.type = queryParam.type.toLowerCase();
if (queryParam.type === "kcp" || queryParam.type === "mkcp")
queryParam.type = "mkcp"
if (queryParam.type === "h2" || queryParam.type === "http")
queryParam.type = "h2"
if (queryParam.type === "kcp" || queryParam.type === "mkcp") {
queryParam.type = "mkcp";
}
if (queryParam.type === "h2" || queryParam.type === "http") {
queryParam.type = "http";
}
if (dom_prefix == "singbox_" && queryParam.type === "raw") {
queryParam.type = "tcp";
} else if (dom_prefix == "xray_" && queryParam.type === "tcp") {
queryParam.type = "raw";
}
opt.set(dom_prefix + 'transport', queryParam.type);
if (dom_prefix == "xray_" && queryParam.type === "http") {
opt.set(dom_prefix + 'transport', "xhttp");
} else {
opt.set(dom_prefix + 'transport', queryParam.type);
}
if (queryParam.type === "raw" || queryParam.type === "tcp") {
opt.set(dom_prefix + 'tcp_guise', queryParam.headerType || "none");
if (queryParam.headerType && queryParam.headerType != "none") {
Expand Down Expand Up @@ -848,8 +854,14 @@
}
}
} else if (queryParam.type === "h2" || queryParam.type === "http") {
opt.set(dom_prefix + 'h2_host', queryParam.host || "");
opt.set(dom_prefix + 'h2_path', queryParam.path || "");
if (dom_prefix == "xray_") {
opt.set(dom_prefix + 'xhttp_mode', "stream-one");
opt.set(dom_prefix + 'xhttp_host', queryParam.host || "");
opt.set(dom_prefix + 'xhttp_path', queryParam.path || "");
} else {
opt.set(dom_prefix + 'http_host', queryParam.host || "");
opt.set(dom_prefix + 'http_path', queryParam.path || "");
}
} else if (queryParam.type === "quic") {
opt.set(dom_prefix + 'quic_guise', queryParam.headerType || "none");
opt.set(dom_prefix + 'quic_security', queryParam.quicSecurity);
Expand Down Expand Up @@ -925,16 +937,22 @@
opt.set(dom_prefix + 'password', decodeURIComponent(password));

queryParam.type = queryParam.type.toLowerCase();
if (queryParam.type === "kcp" || queryParam.type === "mkcp")
queryParam.type = "mkcp"
if (queryParam.type === "h2" || queryParam.type === "http")
queryParam.type = "h2"
if (queryParam.type === "kcp" || queryParam.type === "mkcp") {
queryParam.type = "mkcp";
}
if (queryParam.type === "h2" || queryParam.type === "http") {
queryParam.type = "http";
}
if (dom_prefix == "singbox_" && queryParam.type === "raw") {
queryParam.type = "tcp";
queryParam.type = "tcp";
} else if (dom_prefix == "xray_" && queryParam.type === "tcp") {
queryParam.type = "raw";
}
opt.set(dom_prefix + 'transport', queryParam.type);
if (dom_prefix == "xray_" && queryParam.type === "http") {
opt.set(dom_prefix + 'transport', "xhttp");
} else {
opt.set(dom_prefix + 'transport', queryParam.type);
}
if (queryParam.type === "raw" || queryParam.type === "tcp") {
opt.set(dom_prefix + 'tcp_guise', queryParam.headerType || "none");
if (queryParam.headerType && queryParam.headerType != "none") {
Expand Down Expand Up @@ -963,8 +981,14 @@
}
}
} else if (queryParam.type === "h2" || queryParam.type === "http") {
opt.set(dom_prefix + 'h2_host', queryParam.host || "");
opt.set(dom_prefix + 'h2_path', queryParam.path || "");
if (dom_prefix == "xray_") {
opt.set(dom_prefix + 'xhttp_mode', "stream-one");
opt.set(dom_prefix + 'xhttp_host', queryParam.host || "");
opt.set(dom_prefix + 'xhttp_path', queryParam.path || "");
} else {
opt.set(dom_prefix + 'http_host', queryParam.host || "");
opt.set(dom_prefix + 'http_path', queryParam.path || "");
}
} else if (queryParam.type === "quic") {
opt.set(dom_prefix + 'quic_guise', queryParam.headerType || "none");
opt.set(dom_prefix + 'quic_security', queryParam.quicSecurity);
Expand Down Expand Up @@ -1030,7 +1054,14 @@
} else if (dom_prefix == "xray_" && ssm.net === "tcp") {
ssm.net = "raw";
}
opt.set(dom_prefix + 'transport', ssm.net);
if (ssm.net === "h2" || ssm.net === "http") {
ssm.net = "http";
}
if (dom_prefix == "xray_" && ssm.net === "http") {
opt.set(dom_prefix + 'transport', "xhttp");
} else {
opt.set(dom_prefix + 'transport', ssm.net);
}
if (ssm.net === "raw" || ssm.net === "tcp") {
opt.set(dom_prefix + 'tcp_guise', (ssm.host && ssm.path) ? "http" : "none");
if (ssm.host && ssm.path) {
Expand Down Expand Up @@ -1058,9 +1089,15 @@
opt.set(dom_prefix + 'ws_earlyDataHeaderName', 'Sec-WebSocket-Protocol');
}
}
} else if (ssm.net === "h2") {
opt.set(dom_prefix + 'h2_host', ssm.host);
opt.set(dom_prefix + 'h2_path', ssm.path);
} else if (ssm.net === "http") {
if (dom_prefix == "xray_") {
opt.set(dom_prefix + 'xhttp_mode', "stream-one");
opt.set(dom_prefix + 'xhttp_host', ssm.host || "");
opt.set(dom_prefix + 'xhttp_path', ssm.path || "");
} else {
opt.set(dom_prefix + 'http_host', ssm.host || "");
opt.set(dom_prefix + 'http_path', ssm.path || "");
}
} else if (ssm.net === "quic") {
opt.set(dom_prefix + 'quic_security', ssm.securty);
opt.set(dom_prefix + 'quic_key', ssm.key);
Expand Down Expand Up @@ -1134,16 +1171,22 @@
}

queryParam.type = queryParam.type.toLowerCase();
if (queryParam.type === "kcp" || queryParam.type === "mkcp")
queryParam.type = "mkcp"
if (queryParam.type === "h2" || queryParam.type === "http")
queryParam.type = "h2"
if (queryParam.type === "kcp" || queryParam.type === "mkcp") {
queryParam.type = "mkcp";
}
if (queryParam.type === "h2" || queryParam.type === "http") {
queryParam.type = "http";
}
if (dom_prefix == "singbox_" && queryParam.type === "raw") {
queryParam.type = "tcp";
} else if (dom_prefix == "xray_" && queryParam.type === "tcp") {
queryParam.type = "raw";
}
opt.set(dom_prefix + 'transport', queryParam.type);
if (dom_prefix == "xray_" && queryParam.type === "http") {
opt.set(dom_prefix + 'transport', "xhttp");
} else {
opt.set(dom_prefix + 'transport', queryParam.type);
}
if (queryParam.type === "raw" || queryParam.type === "tcp") {
opt.set(dom_prefix + 'tcp_guise', queryParam.headerType || "none");
if (queryParam.headerType && queryParam.headerType != "none") {
Expand Down Expand Up @@ -1172,8 +1215,14 @@
}
}
} else if (queryParam.type === "h2" || queryParam.type === "http") {
opt.set(dom_prefix + 'h2_host', queryParam.host || "");
opt.set(dom_prefix + 'h2_path', queryParam.path || "");
if (dom_prefix == "xray_") {
opt.set(dom_prefix + 'xhttp_mode', "stream-one");
opt.set(dom_prefix + 'xhttp_host', queryParam.host || "");
opt.set(dom_prefix + 'xhttp_path', queryParam.path || "");
} else {
opt.set(dom_prefix + 'http_host', queryParam.host || "");
opt.set(dom_prefix + 'http_path', queryParam.path || "");
}
} else if (queryParam.type === "quic") {
opt.set(dom_prefix + 'quic_guise', queryParam.headerType || "none");
opt.set(dom_prefix + 'quic_security', queryParam.quicSecurity);
Expand Down
73 changes: 51 additions & 22 deletions luci-app-passwall/root/usr/share/passwall/subscribe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,12 @@ local function processData(szType, content, add_mode, add_from)
elseif result.type == "Xray" and info.net == "tcp" then
info.net = "raw"
end
result.transport = info.net
if info.net == 'h2' or info.net == 'http' then
info.net = "http"
result.transport = (result.type == "Xray") and "xhttp" or "http"
else
result.transport = info.net
end
if info.net == 'ws' then
result.ws_host = info.host
result.ws_path = info.path
Expand All @@ -486,9 +491,15 @@ local function processData(szType, content, add_mode, add_from)
end
end
end
if info.net == 'h2' then
result.h2_host = info.host
result.h2_path = info.path
if info.net == "http" then
if result.type == "Xray" then
result.xhttp_mode = "stream-one"
result.xhttp_host = info.host
result.xhttp_path = info.path
else
result.http_host = info.host
result.http_path = info.path
end
end
if info.net == 'raw' or info.net == 'tcp' then
if info.type and info.type ~= "http" then
Expand Down Expand Up @@ -668,7 +679,12 @@ local function processData(szType, content, add_mode, add_from)
elseif result.type == "Xray" and params.type == "tcp" then
params.type = "raw"
end
result.transport = params.type
if params.type == "h2" or params.type == "http" then
params.type = "http"
result.transport = (result.type == "Xray") and "xhttp" or "http"
else
result.transport = params.type
end
if result.type ~= "SS-Rust" and result.type ~= "SS" then
if params.type == 'ws' then
result.ws_host = params.host
Expand All @@ -689,15 +705,16 @@ local function processData(szType, content, add_mode, add_from)
end
end
end
if params.type == 'h2' or params.type == 'http' then
if params.type == "http" then
if result.type == "sing-box" then
result.transport = "http"
result.http_host = params.host
result.http_path = params.path
elseif result.type == "xray" then
result.transport = "h2"
result.h2_host = params.host
result.h2_path = params.path
elseif result.type == "Xray" then
result.transport = "xhttp"
result.xhttp_mode = "stream-one"
result.xhttp_host = params.host
result.xhttp_path = params.path
end
end
if params.type == 'raw' or params.type == 'tcp' then
Expand Down Expand Up @@ -815,7 +832,12 @@ local function processData(szType, content, add_mode, add_from)
elseif result.type == "Xray" and params.type == "tcp" then
params.type = "raw"
end
result.transport = params.type
if params.type == "h2" or params.type == "http" then
params.type = "http"
result.transport = (result.type == "Xray") and "xhttp" or "http"
else
result.transport = params.type
end
if params.type == 'ws' then
result.ws_host = params.host
result.ws_path = params.path
Expand All @@ -835,15 +857,16 @@ local function processData(szType, content, add_mode, add_from)
end
end
end
if params.type == 'h2' or params.type == 'http' then
if params.type == "http" then
if result.type == "sing-box" then
result.transport = "http"
result.http_host = params.host
result.http_path = params.path
elseif result.type == "xray" then
result.transport = "h2"
result.h2_host = params.host
result.h2_path = params.path
elseif result.type == "Xray" then
result.transport = "xhttp"
result.xhttp_mode = "stream-one"
result.xhttp_host = params.host
result.xhttp_path = params.path
end
end
if params.type == 'raw' or params.type == 'tcp' then
Expand Down Expand Up @@ -955,7 +978,12 @@ local function processData(szType, content, add_mode, add_from)
elseif result.type == "Xray" and params.type == "tcp" then
params.type = "raw"
end
result.transport = params.type
if params.type == "h2" or params.type == "http" then
params.type = "http"
result.transport = (result.type == "Xray") and "xhttp" or "http"
else
result.transport = params.type
end
if params.type == 'ws' then
result.ws_host = params.host
result.ws_path = params.path
Expand All @@ -975,15 +1003,16 @@ local function processData(szType, content, add_mode, add_from)
end
end
end
if params.type == 'h2' or params.type == 'http' then
if params.type == "http" then
if result.type == "sing-box" then
result.transport = "http"
result.http_host = params.host
result.http_path = params.path
elseif result.type == "xray" then
result.transport = "h2"
result.h2_host = params.host
result.h2_path = params.path
elseif result.type == "Xray" then
result.transport = "xhttp"
result.xhttp_mode = "stream-one"
result.xhttp_host = params.host
result.xhttp_path = params.path
end
end
if params.type == 'raw' or params.type == 'tcp' then
Expand Down

0 comments on commit 52ab893

Please sign in to comment.