Skip to content

Commit 2e31806

Browse files
authored
Merge pull request #1885 from zxlhhyccc/tuic
luci-app-ssr-plus: remove allowInsecure in xray 26.1.31 or later.
2 parents bd3f0b1 + f499809 commit 2e31806

File tree

6 files changed

+771
-608
lines changed

6 files changed

+771
-608
lines changed

luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ local m, s, o
1212

1313
local sid = arg[1]
1414
local uuid = luci.sys.exec("cat /proc/sys/kernel/random/uuid")
15+
local xray_version = nil
1516

1617
-- 确保正确判断程序是否存在
1718
local function is_finded(e)
@@ -22,6 +23,14 @@ local function is_installed(e)
2223
return luci.model.ipkg.installed(e)
2324
end
2425

26+
-- 获取 Xray 版本号
27+
if is_finded("xray") then
28+
local version = luci.sys.exec("xray version 2>&1")
29+
if version and version ~= "" then
30+
xray_version = version:match("Xray%s+([%d%.]+)")
31+
end
32+
end
33+
2534
-- 默认的保存并应用行为
2635
local function apply_redirect(m)
2736
local tmp_uci_file = "/etc/config/" .. "shadowsocksr" .. "_redirect"
@@ -1266,17 +1275,43 @@ o:depends("tuic_dual_stack", true)
12661275
-- [[ allowInsecure ]]--
12671276
o = s:option(Flag, "insecure", translate("allowInsecure"))
12681277
o.rmempty = false
1269-
o:depends("tls", true)
12701278
o:depends("type", "hysteria2")
1279+
o:depends("type", "trojan")
12711280
o:depends("type", "tuic")
1272-
o:depends({type = "v2ray", v2ray_protocol = "vless", reality = true})
12731281
o.description = translate("If true, allowss insecure connection at TLS client, e.g., TLS server uses unverifiable certificates.")
1282+
-- Xray 的26.1.31 以下版本使用
1283+
if xray_version and xray_version ~= "" then
1284+
-- 提取所有数字部分,允许版本号有1到3个部分,不足部分补0
1285+
local major, minor, patch =
1286+
xray_version:match("(%d+)%.?(%d*)%.?(%d*)")
1287+
-- 将字符串转换为数字,空字符串转为0
1288+
major = tonumber(major) or 0
1289+
minor = tonumber(minor) or 0
1290+
patch = tonumber(patch) or 0
1291+
-- 如果版本低于 26.1.31
1292+
if (major * 10000 + minor * 100 + patch) < 260131 then
1293+
o:depends("tls", true)
1294+
o:depends({ type = "v2ray", v2ray_protocol = "vless", reality = true })
1295+
end
1296+
end
12741297

12751298
-- [[ Hysteria2 TLS pinSHA256 ]] --
12761299
o = s:option(Value, "pinsha256", translate("Certificate fingerprint"))
12771300
o:depends("type", "hysteria2")
12781301
o.rmempty = true
12791302

1303+
-- [[ Xray TLS pinSHA256 ]] --
1304+
o = s:option(Value, "chain_fingerprint", translate("TLS Chain Fingerprint (SHA256)"), translate("Once set, connects only when the server’s chain fingerprint matches."))
1305+
o.rmempty = true
1306+
o:depends({type = "v2ray", tls = true})
1307+
o:depends({type = "v2ray", reality = true})
1308+
1309+
-- [[ Xray TLS verify leaf certificate name ]] --
1310+
o = s:option(Value, "verify_name", translate("TLS Certificate Name (CertName)"), translate("TLS is used to verify the leaf certificate name."))
1311+
o.rmempty = true
1312+
o:depends({type = "v2ray", tls = true})
1313+
o:depends({type = "v2ray", reality = true})
1314+
12801315
-- [[ Mux.Cool ]] --
12811316
o = s:option(Flag, "mux", translate("Mux"), translate("Enable Mux.Cool"))
12821317
o.rmempty = false

luci-app-ssr-plus/luasrc/view/shadowsocksr/ssrurl.htm

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@
122122

123123
document.getElementsByName('cbid.shadowsocksr.' + sid + '.transport_protocol')[0].value = params.get("protocol") || "udp";
124124
}
125-
126125
if (params.get("pinSHA256")) {
127126
document.getElementsByName('cbid.shadowsocksr.' + sid + '.pinsha256')[0].value = params.get("pinSHA256") || "";
128127
}
@@ -131,6 +130,13 @@
131130
document.getElementsByName('cbid.shadowsocksr.' + sid + '.type')[0].dispatchEvent(event);
132131
document.getElementsByName('cbid.shadowsocksr.' + sid + '.v2ray_protocol')[0].value = (ssu[0] === "hy2") ? "hysteria2" : ssu[0];
133132
document.getElementsByName('cbid.shadowsocksr.' + sid + '.v2ray_protocol')[0].dispatchEvent(event);
133+
134+
if (params.get("pcs")) {
135+
document.getElementsByName('cbid.shadowsocksr.' + sid + '.chain_fingerprint')[0].value = params.get("pcs") || "";
136+
}
137+
if (params.get("vcn")) {
138+
document.getElementsByName('cbid.shadowsocksr.' + sid + '.verify_name')[0].value = params.get("vcn") || "";
139+
}
134140
}
135141
document.getElementsByName('cbid.shadowsocksr.' + sid + '.server')[0].value = url.hostname;
136142
document.getElementsByName('cbid.shadowsocksr.' + sid + '.server_port')[0].value = url.port || "443";
@@ -167,10 +173,10 @@
167173
document.getElementsByName('cbid.shadowsocksr.' + sid + '.tls_alpn')[0].value = params.get("alpn") || "";
168174
}
169175
}
170-
if (params.get("insecure") === "1") {
171-
document.getElementsByName('cbid.shadowsocksr.' + sid + '.insecure')[0].checked = true;
172-
document.getElementsByName('cbid.shadowsocksr.' + sid + '.insecure')[0].dispatchEvent(event);
173-
}
176+
document.getElementsByName('cbid.shadowsocksr.' + sid + '.insecure')[0].checked =
177+
!!(params.get("insecure") ?? params.get("allowInsecure")); // 设置 insecure true
178+
document.getElementsByName('cbid.shadowsocksr.' + sid + '.insecure')[0].dispatchEvent(event); // 触发事件
179+
174180
document.getElementsByName('cbid.shadowsocksr.' + sid + '.alias')[0].value = url.hash ? decodeURIComponent(url.hash.slice(1)) : "";
175181

176182
s.innerHTML = "<font style=\'color:green\'><%:Import configuration information successfully.%></font>";
@@ -398,6 +404,12 @@
398404
setElementValue('cbid.shadowsocksr.' + sid + '.reality_mldsa65verify', params.pqv || "");
399405
}
400406
}
407+
if (params.pcs && params.pcs.trim() !== "") {
408+
setElementValue('cbid.shadowsocksr.' + sid + '.chain_fingerprint', params.pcs);
409+
}
410+
if (params.vcn && params.vcn.trim() !== "") {
411+
setElementValue('cbid.shadowsocksr.' + sid + '.verify_name', params.vcn);
412+
}
401413
setElementValue('cbid.shadowsocksr.' + sid + '.tls_flow', params.flow || "none");
402414
dispatchEventIfExists('cbid.shadowsocksr.' + sid + '.tls_flow', event);
403415

@@ -557,6 +569,12 @@
557569
if (params.get("security") === "tls") {
558570
document.getElementsByName('cbid.shadowsocksr.' + sid + '.tls_alpn')[0].value = params.get("alpn") || "";
559571
document.getElementsByName('cbid.shadowsocksr.' + sid + '.fingerprint')[0].value = params.get("fp") || "";
572+
if (params.get("pcs") && params.get("pcs").trim() !== "") {
573+
document.getElementsByName('cbid.shadowsocksr.' + sid + '.chain_fingerprint')[0].value = params.get("pcs");
574+
}
575+
if (params.get("vcn") && params.get("vcn").trim() !== "") {
576+
document.getElementsByName('cbid.shadowsocksr.' + sid + '.verify_name')[0].value = params.get("vcn");
577+
}
560578
}
561579
switch (params.get("type")) {
562580
case "ws":
@@ -692,6 +710,12 @@
692710
document.getElementsByName('cbid.shadowsocksr.' + sid + '.enable_ech')[0].dispatchEvent(event); // 触发事件
693711
document.getElementsByName('cbid.shadowsocksr.' + sid + '.ech_config')[0].value = ssm.ech;
694712
}
713+
if (params.pcs && params.pcs.trim() !== "") {
714+
document.getElementsByName('cbid.shadowsocksr.' + sid + '.chain_fingerprint')[0].value = ssm.pcs;
715+
}
716+
if (params.vcn && params.vcn.trim() !== "") {
717+
document.getElementsByName('cbid.shadowsocksr.' + sid + '.verify_name')[0].value = ssm.vcn;
718+
}
695719
document.getElementsByName('cbid.shadowsocksr.' + sid + '.insecure')[0].checked =
696720
!!(ssm.allowInsecure ?? ssm.allowlnsecure ?? ssm['skip-cert-verify']); // 设置 insecure 为 true
697721
document.getElementsByName('cbid.shadowsocksr.' + sid + '.insecure')[0].dispatchEvent(event); // 触发事件
@@ -776,6 +800,12 @@
776800
setElementValue('cbid.shadowsocksr.' + sid + '.reality_mldsa65verify', params.get("pqv") || "");
777801
}
778802
}
803+
if (params.get("pcs") && params.get("pcs").trim() !== "") {
804+
setElementValue('cbid.shadowsocksr.' + sid + '.chain_fingerprint', params.get("pcs"));
805+
}
806+
if (params.get("vcn") && params.get("vcn").trim() !== "") {
807+
setElementValue('cbid.shadowsocksr.' + sid + '.verify_name', params.get("vcn"));
808+
}
779809

780810
setElementValue('cbid.shadowsocksr.' + sid + '.tls_alpn', params.get("alpn") || "");
781811
setElementValue('cbid.shadowsocksr.' + sid + '.fingerprint', params.get("fp") || "");

0 commit comments

Comments
 (0)