From 9bdb794d3f3846944b3f8d7bcc4c959959d7f838 Mon Sep 17 00:00:00 2001 From: sbwml Date: Fri, 8 Sep 2023 14:33:51 +0800 Subject: [PATCH] luci-app-passwall2: sync upstream --- luci-app-passwall2/Makefile | 2 +- .../cbi/passwall2/client/type/sing-box.lua | 9 ++++ .../model/cbi/passwall2/server/type/ray.lua | 4 +- .../cbi/passwall2/server/type/sing-box.lua | 9 ++++ .../luasrc/passwall2/util_sing-box.lua | 50 +++++++++++++++---- 5 files changed, 61 insertions(+), 13 deletions(-) diff --git a/luci-app-passwall2/Makefile b/luci-app-passwall2/Makefile index 8cc395e46..97023c708 100644 --- a/luci-app-passwall2/Makefile +++ b/luci-app-passwall2/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall2 -PKG_VERSION:=1.20-5 +PKG_VERSION:=1.20-6 PKG_RELEASE:= PKG_CONFIG_DEPENDS:= \ diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/sing-box.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/sing-box.lua index b6c1eac39..cc48f64f2 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/sing-box.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/sing-box.lua @@ -325,6 +325,9 @@ if singbox_tags:find("with_quic") then o = s:option(Flag, option_name("hysteria_disable_mtu_discovery"), translate("Disable MTU detection")) o:depends({ [option_name("protocol")] = "hysteria" }) + + o = s:option(Value, option_name("hysteria_alpn"), translate("QUIC TLS ALPN")) + o:depends({ [option_name("protocol")] = "hysteria" }) end if singbox_tags:find("with_quic") then @@ -408,10 +411,16 @@ o:depends({ [option_name("tls")] = true }) o = s:option(Value, option_name("tls_serverName"), translate("Domain")) o:depends({ [option_name("tls")] = true }) +o:depends({ [option_name("protocol")] = "hysteria"}) +o:depends({ [option_name("protocol")] = "tuic" }) +o:depends({ [option_name("protocol")] = "hysteria2" }) o = s:option(Flag, option_name("tls_allowInsecure"), translate("allowInsecure"), translate("Whether unsafe connections are allowed. When checked, Certificate validation will be skipped.")) o.default = "0" o:depends({ [option_name("tls")] = true }) +o:depends({ [option_name("protocol")] = "hysteria"}) +o:depends({ [option_name("protocol")] = "tuic" }) +o:depends({ [option_name("protocol")] = "hysteria2" }) if singbox_tags:find("with_utls") then o = s:option(Flag, option_name("utls"), translate("uTLS")) diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/server/type/ray.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/server/type/ray.lua index 9ad0feffd..5f4b1f793 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/server/type/ray.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/server/type/ray.lua @@ -398,9 +398,8 @@ for key, value in pairs(s.fields) do s.fields[key].write = rm_prefix_write s.fields[key].remove = rm_prefix_remove end - end - local deps = s.fields[key].deps + local deps = s.fields[key].deps if #deps > 0 then for index, value in ipairs(deps) do deps[index]["type"] = type_name @@ -408,4 +407,5 @@ for key, value in pairs(s.fields) do else s.fields[key]:depends({ type = type_name }) end + end end diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/server/type/sing-box.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/server/type/sing-box.lua index 843567035..5c793c064 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/server/type/sing-box.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/server/type/sing-box.lua @@ -131,6 +131,9 @@ if singbox_tags:find("with_quic") then o = s:option(Flag, option_name("hysteria_disable_mtu_discovery"), translate("Disable MTU detection")) o:depends({ [option_name("protocol")] = "hysteria" }) + + o = s:option(Value, option_name("hysteria_alpn"), translate("QUIC TLS ALPN")) + o:depends({ [option_name("protocol")] = "hysteria" }) end if singbox_tags:find("with_quic") then @@ -245,6 +248,9 @@ o:depends({ [option_name("protocol")] = "trojan" }) o = s:option(FileUpload, option_name("tls_certificateFile"), translate("Public key absolute path"), translate("as:") .. "/etc/ssl/fullchain.pem") o.default = m:get(s.section, "tls_certificateFile") or "/etc/config/ssl/" .. arg[1] .. ".pem" o:depends({ [option_name("tls")] = true }) +o:depends({ [option_name("protocol")] = "hysteria" }) +o:depends({ [option_name("protocol")] = "tuic" }) +o:depends({ [option_name("protocol")] = "hysteria2" }) o.validate = function(self, value, t) if value and value ~= "" then if not nixio.fs.access(value) then @@ -259,6 +265,9 @@ end o = s:option(FileUpload, option_name("tls_keyFile"), translate("Private key absolute path"), translate("as:") .. "/etc/ssl/private.key") o.default = m:get(s.section, "tls_keyFile") or "/etc/config/ssl/" .. arg[1] .. ".key" o:depends({ [option_name("tls")] = true }) +o:depends({ [option_name("protocol")] = "hysteria" }) +o:depends({ [option_name("protocol")] = "tuic" }) +o:depends({ [option_name("protocol")] = "hysteria2" }) o.validate = function(self, value, t) if value and value ~= "" then if not nixio.fs.access(value) then diff --git a/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua b/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua index 77f5b25fb..898848aef 100644 --- a/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua +++ b/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua @@ -264,8 +264,8 @@ function gen_outbound(flag, node, tag, proxy_table) if node.protocol == "hysteria" then protocol_table = { - up = node.hysteria_up_mbps .. " Mbps", - down = node.hysteria_down_mbps .. " Mbps", + up = node.hysteria_up_mbps .. " Mbps", + down = node.hysteria_down_mbps .. " Mbps", up_mbps = tonumber(node.hysteria_up_mbps), down_mbps = tonumber(node.hysteria_down_mbps), obfs = node.hysteria_obfs, @@ -274,7 +274,14 @@ function gen_outbound(flag, node, tag, proxy_table) recv_window_conn = tonumber(node.hysteria_recv_window_conn), recv_window = tonumber(node.hysteria_recv_window), disable_mtu_discovery = (node.hysteria_disable_mtu_discovery == "1") and true or false, - tls = tls, + tls = { + enabled = true, + server_name = node.tls_serverName, + insecure = (node.tls_allowInsecure == "1") and true or false, + alpn = (node.hysteria_alpn and node.hysteria_alpn ~= "") and { + node.hysteria_alpn + } or nil + } } end @@ -295,7 +302,11 @@ function gen_outbound(flag, node, tag, proxy_table) udp_over_stream = false, zero_rtt_handshake = (node.tuic_zero_rtt_handshake == "1") and true or false, heartbeat = tonumber(node.tuic_heartbeat), - tls = tls, + tls = { + enabled = true, + server_name = node.tls_serverName, + insecure = (node.tls_allowInsecure == "1") and true or false, + }, } end @@ -308,7 +319,11 @@ function gen_outbound(flag, node, tag, proxy_table) password = node.hysteria2_obfs_password }, password = node.hysteria2_auth_password or nil, - tls = tls, + tls = { + enabled = true, + server_name = node.tls_serverName, + insecure = (node.tls_allowInsecure == "1") and true or false, + }, } end @@ -490,8 +505,8 @@ function gen_config_server(node) if node.protocol == "hysteria" then protocol_table = { - up = node.hysteria_up_mbps .. " Mbps", - down = node.hysteria_down_mbps .. " Mbps", + up = node.hysteria_up_mbps .. " Mbps", + down = node.hysteria_down_mbps .. " Mbps", up_mbps = tonumber(node.hysteria_up_mbps), down_mbps = tonumber(node.hysteria_down_mbps), obfs = node.hysteria_obfs, @@ -506,7 +521,14 @@ function gen_config_server(node) recv_window_client = node.hysteria_recv_window_client and tonumber(node.hysteria_recv_window_client) or nil, max_conn_client = node.hysteria_max_conn_client and tonumber(node.hysteria_max_conn_client) or nil, disable_mtu_discovery = (node.hysteria_disable_mtu_discovery == "1") and true or false, - tls = tls, + tls = { + enabled = true, + certificate_path = node.tls_certificateFile, + key_path = node.tls_keyFile, + alpn = (node.hysteria_alpn and node.hysteria_alpn ~= "") and { + node.hysteria_alpn + } or nil + } } end @@ -522,7 +544,11 @@ function gen_config_server(node) congestion_control = node.tuic_congestion_control or "cubic", zero_rtt_handshake = (node.tuic_zero_rtt_handshake == "1") and true or false, heartbeat = node.tuic_heartbeat .. "s", - tls = tls, + tls = { + enabled = true, + certificate_path = node.tls_certificateFile, + key_path = node.tls_keyFile, + } } end @@ -541,7 +567,11 @@ function gen_config_server(node) } }, ignore_client_bandwidth = (node.hysteria2_ignore_client_bandwidth == "1") and true or false, - tls = tls, + tls = { + enabled = true, + certificate_path = node.tls_certificateFile, + key_path = node.tls_keyFile, + } } end