From 2f64f53745d524887b5c8ba231ed6482a1437e7f Mon Sep 17 00:00:00 2001 From: gitea-action Date: Tue, 29 Oct 2024 00:30:28 +0800 Subject: [PATCH] luci-app-passwall: sync upstream last commit: https://github.com/xiaorouji/openwrt-passwall/commit/06b7f5f70ff825b21ed090bb86ac9704983ad1d3 --- .../model/cbi/passwall/client/type/sing-box.lua | 12 +++++++++++- .../model/cbi/passwall/server/type/sing-box.lua | 12 +++++++++++- luci-app-passwall/luasrc/passwall/util_sing-box.lua | 11 ++++++----- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/type/sing-box.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/type/sing-box.lua index 1b2ffbba3..8e8824a79 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/type/sing-box.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/type/sing-box.lua @@ -408,9 +408,19 @@ if singbox_tags:find("with_ech") then o:depends({ [option_name("protocol")] = "hysteria" }) o:depends({ [option_name("protocol")] = "hysteria2" }) - o = s:option(Value, option_name("ech_config"), translate("ECH Config")) + o = s:option(TextValue, option_name("ech_config"), translate("ECH Config")) o.default = "" + o.rows = 5 + o.wrap = "off" o:depends({ [option_name("ech")] = true }) + o.validate = function(self, value) + value = value:gsub("^%s+", ""):gsub("%s+$","\n"):gsub("\r\n","\n"):gsub("[ \t]*\n[ \t]*", "\n") + value = value:gsub("^%s*\n", "") + if value:sub(-1) == "\n" then + value = value:sub(1, -2) + end + return value + end o = s:option(Flag, option_name("pq_signature_schemes_enabled"), translate("PQ signature schemes")) o.default = "0" diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/server/type/sing-box.lua b/luci-app-passwall/luasrc/model/cbi/passwall/server/type/sing-box.lua index e50395534..638460af8 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/server/type/sing-box.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/server/type/sing-box.lua @@ -291,9 +291,19 @@ if singbox_tags:find("with_ech") then o:depends({ [option_name("protocol")] = "tuic" }) o:depends({ [option_name("protocol")] = "hysteria2" }) - o = s:option(Value, option_name("ech_key"), translate("ECH Key")) + o = s:option(TextValue, option_name("ech_key"), translate("ECH Key")) o.default = "" + o.rows = 5 + o.wrap = "off" o:depends({ [option_name("ech")] = true }) + o.validate = function(self, value) + value = value:gsub("^%s+", ""):gsub("%s+$","\n"):gsub("\r\n","\n"):gsub("[ \t]*\n[ \t]*", "\n") + value = value:gsub("^%s*\n", "") + if value:sub(-1) == "\n" then + value = value:sub(1, -2) + end + return value + end o = s:option(Flag, option_name("pq_signature_schemes_enabled"), translate("PQ signature schemes")) o.default = "0" diff --git a/luci-app-passwall/luasrc/passwall/util_sing-box.lua b/luci-app-passwall/luasrc/passwall/util_sing-box.lua index abbe6fa03..4ae77e5a3 100644 --- a/luci-app-passwall/luasrc/passwall/util_sing-box.lua +++ b/luci-app-passwall/luasrc/passwall/util_sing-box.lua @@ -5,6 +5,7 @@ local sys = api.sys local jsonc = api.jsonc local appname = "passwall" local fs = api.fs +local split = api.split local new_port @@ -96,7 +97,7 @@ function gen_outbound(flag, node, tag, proxy_table) --max_version = "1.3", ech = { enabled = (node.ech == "1") and true or false, - config = (node.ech_config and node.ech_config:gsub("\\n","\n")) and node.ech_config:gsub("\\n","\n") or nil, + config = node.ech_config and split(node.ech_config:gsub("\\n", "\n"), "\n") or {}, pq_signature_schemes_enabled = node.pq_signature_schemes_enabled and true or false, dynamic_record_sizing_disabled = node.dynamic_record_sizing_disabled and true or false }, @@ -306,7 +307,7 @@ function gen_outbound(flag, node, tag, proxy_table) } or nil, ech = { enabled = (node.ech == "1") and true or false, - config = (node.ech_config and node.ech_config:gsub("\\n","\n")) and node.ech_config:gsub("\\n","\n") or nil, + config = node.ech_config and split(node.ech_config:gsub("\\n", "\n"), "\n") or {}, pq_signature_schemes_enabled = node.pq_signature_schemes_enabled and true or false, dynamic_record_sizing_disabled = node.dynamic_record_sizing_disabled and true or false } @@ -340,7 +341,7 @@ function gen_outbound(flag, node, tag, proxy_table) } or nil, ech = { enabled = (node.ech == "1") and true or false, - config = (node.ech_config and node.ech_config:gsub("\\n","\n")) and node.ech_config:gsub("\\n","\n") or nil, + config = node.ech_config and split(node.ech_config:gsub("\\n", "\n"), "\n") or {}, pq_signature_schemes_enabled = node.pq_signature_schemes_enabled and true or false, dynamic_record_sizing_disabled = node.dynamic_record_sizing_disabled and true or false } @@ -363,7 +364,7 @@ function gen_outbound(flag, node, tag, proxy_table) insecure = (node.tls_allowInsecure == "1") and true or false, ech = { enabled = (node.ech == "1") and true or false, - config = (node.ech_config and node.ech_config:gsub("\\n","\n")) and node.ech_config:gsub("\\n","\n") or nil, + config = node.ech_config and split(node.ech_config:gsub("\\n", "\n"), "\n") or {}, pq_signature_schemes_enabled = node.pq_signature_schemes_enabled and true or false, dynamic_record_sizing_disabled = node.dynamic_record_sizing_disabled and true or false } @@ -411,7 +412,7 @@ function gen_config_server(node) if node.tls == "1" and node.ech == "1" then tls.ech = { enabled = true, - key = (node.ech_key and node.ech_key:gsub("\\n","\n")) and node.ech_key:gsub("\\n","\n") or nil, + key = node.ech_key and split(node.ech_key:gsub("\\n", "\n"), "\n") or {}, pq_signature_schemes_enabled = (node.pq_signature_schemes_enabled == "1") and true or false, dynamic_record_sizing_disabled = (node.dynamic_record_sizing_disabled == "1") and true or false, }