From c0c4f3d4a629c1e8067a8842060caa242942757a Mon Sep 17 00:00:00 2001 From: kenzok8 Date: Sun, 4 May 2025 16:26:33 +0800 Subject: [PATCH] update 2025-05-04 16:26:33 --- .../model/cbi/passwall2/client/acl_config.lua | 7 + .../model/cbi/passwall2/client/node_list.lua | 2 + .../model/cbi/passwall2/client/other.lua | 7 + .../cbi/passwall2/client/type/sing-box.lua | 10 ++ .../cbi/passwall2/server/type/sing-box.lua | 12 ++ luci-app-passwall2/luasrc/passwall2/api.lua | 18 +- .../luasrc/passwall2/util_sing-box.lua | 19 ++ .../luasrc/view/passwall2/global/faq.htm | 2 +- .../passwall2/node_list/link_add_node.htm | 13 +- .../passwall2/node_list/link_share_man.htm | 152 +++++++++++++++- luci-app-passwall2/po/zh-cn/passwall2.po | 3 + .../root/usr/share/passwall2/iptables.sh | 116 +++++++++---- .../root/usr/share/passwall2/nftables.sh | 21 ++- .../root/usr/share/passwall2/subscribe.lua | 162 +++++++++++++++--- 14 files changed, 467 insertions(+), 77 deletions(-) diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/acl_config.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/acl_config.lua index c850fdba5..94f1ec34b 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/acl_config.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/acl_config.lua @@ -232,6 +232,13 @@ o:value("1:65535", translate("All")) o.validate = port_validate o:depends({ _hide_node_option = "1", ['!reverse'] = true }) +o = s:option(DummyValue, "tips", " ") +o.rawhtml = true +o.cfgvalue = function(t, n) + return string.format('%s', + translate("The port settings support single ports and ranges.
Separate multiple ports with commas (,).
Example: 21,80,443,1000:2000.")) +end + o = s:option(ListValue, "direct_dns_query_strategy", translate("Direct Query Strategy")) o.default = "UseIP" o:value("UseIP") diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_list.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_list.lua index da017c850..e633f3fcf 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_list.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_list.lua @@ -114,6 +114,8 @@ o.cfgvalue = function(t, n) protocol = "HY" elseif protocol == "hysteria2" then protocol = "HY2" + elseif protocol == "anytls" then + protocol = "AnyTLS" else protocol = protocol:gsub("^%l",string.upper) end diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/other.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/other.lua index 64548c3e6..0889ab697 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/other.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/other.lua @@ -95,6 +95,13 @@ o.default = "1:65535" o:value("1:65535", translate("All")) o.validate = port_validate +o = s:option(DummyValue, "tips", " ") +o.rawhtml = true +o.cfgvalue = function(t, n) + return string.format('%s', + translate("The port settings support single ports and ranges.
Separate multiple ports with commas (,).
Example: 21,80,443,1000:2000.")) +end + ---- Use nftables o = s:option(ListValue, "use_nft", translate("Firewall tools")) o.default = "0" 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 f995a5f78..075199f9b 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 @@ -8,6 +8,9 @@ if not singbox_bin then return end +local local_version = api.get_app_version("sing-box") +local version_ge_1_12_0 = api.compare_versions(local_version:match("[^v]+"), ">=", "1.12.0") + local singbox_tags = luci.sys.exec(singbox_bin .. " version | grep 'Tags:' | awk '{print $2}'") local appname = api.appname @@ -59,6 +62,9 @@ end if singbox_tags:find("with_quic") then o:value("hysteria2", "Hysteria2") end +if version_ge_1_12_0 then + o:value("anytls", "AnyTLS") +end o:value("_urltest", translate("URLTest")) o:value("_shunt", translate("Shunt")) o:value("_iface", translate("Custom Interface")) @@ -254,6 +260,7 @@ o:depends({ [_n("protocol")] = "shadowsocks" }) o:depends({ [_n("protocol")] = "shadowsocksr" }) o:depends({ [_n("protocol")] = "trojan" }) o:depends({ [_n("protocol")] = "tuic" }) +o:depends({ [_n("protocol")] = "anytls" }) o = s:option(ListValue, _n("security"), translate("Encrypt Method")) for a, t in ipairs(security_list) do o:value(t) end @@ -434,6 +441,7 @@ o:depends({ [_n("protocol")] = "vless" }) o:depends({ [_n("protocol")] = "http" }) o:depends({ [_n("protocol")] = "trojan" }) o:depends({ [_n("protocol")] = "shadowsocks" }) +o:depends({ [_n("protocol")] = "anytls" }) o = s:option(ListValue, _n("alpn"), translate("alpn")) o.default = "default" @@ -527,6 +535,7 @@ if singbox_tags:find("with_utls") then o:depends({ [_n("protocol")] = "shadowsocks", [_n("utls")] = true }) o:depends({ [_n("protocol")] = "socks", [_n("utls")] = true }) o:depends({ [_n("protocol")] = "trojan", [_n("utls")] = true }) + o:depends({ [_n("protocol")] = "anytls", [_n("utls")] = true }) o = s:option(Value, _n("reality_publicKey"), translate("Public Key")) o:depends({ [_n("utls")] = true, [_n("reality")] = true }) @@ -752,6 +761,7 @@ o:depends({ [_n("protocol")] = "hysteria" }) o:depends({ [_n("protocol")] = "vless" }) o:depends({ [_n("protocol")] = "tuic" }) o:depends({ [_n("protocol")] = "hysteria2" }) +o:depends({ [_n("protocol")] = "anytls" }) o = s:option(ListValue, _n("chain_proxy"), translate("Chain Proxy")) o:value("", translate("Close(Not use)")) 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 dbb4138c1..85a79dbb8 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 @@ -8,6 +8,11 @@ if not singbox_bin then return end +local local_version = api.get_app_version("sing-box") +local version_ge_1_12_0 = api.compare_versions(local_version:match("[^v]+"), ">=", "1.12.0") + +local fs = api.fs + local singbox_tags = luci.sys.exec(singbox_bin .. " version | grep 'Tags:' | awk '{print $2}'") local type_name = "sing-box" @@ -48,6 +53,9 @@ end if singbox_tags:find("with_quic") then o:value("hysteria2", "Hysteria2") end +if version_ge_1_12_0 then + o:value("anytls", "AnyTLS") +end o:value("direct", "Direct") o = s:option(Value, _n("port"), translate("Listen Port")) @@ -71,6 +79,7 @@ o:depends({ [_n("protocol")] = "http" }) o = s:option(Value, _n("username"), translate("Username")) o:depends({ [_n("auth")] = true }) o:depends({ [_n("protocol")] = "naive" }) +o:depends({ [_n("protocol")] = "anytls" }) o = s:option(Value, _n("password"), translate("Password")) o.password = true @@ -78,6 +87,7 @@ o:depends({ [_n("auth")] = true }) o:depends({ [_n("protocol")] = "shadowsocks" }) o:depends({ [_n("protocol")] = "naive" }) o:depends({ [_n("protocol")] = "tuic" }) +o:depends({ [_n("protocol")] = "anytls" }) if singbox_tags:find("with_quic") then o = s:option(Value, _n("hysteria_up_mbps"), translate("Max upload Mbps")) @@ -221,6 +231,7 @@ o:depends({ [_n("protocol")] = "http" }) o:depends({ [_n("protocol")] = "vmess" }) o:depends({ [_n("protocol")] = "vless" }) o:depends({ [_n("protocol")] = "trojan" }) +o:depends({ [_n("protocol")] = "anytls" }) if singbox_tags:find("with_reality_server") then -- [[ REALITY部分 ]] -- @@ -230,6 +241,7 @@ if singbox_tags:find("with_reality_server") then o:depends({ [_n("protocol")] = "vmess", [_n("tls")] = true }) o:depends({ [_n("protocol")] = "vless", [_n("tls")] = true }) o:depends({ [_n("protocol")] = "trojan", [_n("tls")] = true }) + o:depends({ [_n("protocol")] = "anytls", [_n("tls")] = true }) o = s:option(Value, _n("reality_private_key"), translate("Private Key")) o:depends({ [_n("reality")] = true }) diff --git a/luci-app-passwall2/luasrc/passwall2/api.lua b/luci-app-passwall2/luasrc/passwall2/api.lua index 65e873c79..798310a5c 100644 --- a/luci-app-passwall2/luasrc/passwall2/api.lua +++ b/luci-app-passwall2/luasrc/passwall2/api.lua @@ -471,6 +471,8 @@ function get_valid_nodes() protocol = "HY" elseif protocol == "hysteria2" then protocol = "HY2" + elseif protocol == "anytls" then + protocol = "AnyTLS" else protocol = protocol:gsub("^%l",string.upper) end @@ -504,9 +506,22 @@ function get_node_remarks(n) protocol = "VMess" elseif protocol == "vless" then protocol = "VLESS" + elseif protocol == "shadowsocks" then + protocol = "SS" + elseif protocol == "shadowsocksr" then + protocol = "SSR" + elseif protocol == "wireguard" then + protocol = "WG" + elseif protocol == "hysteria" then + protocol = "HY" + elseif protocol == "hysteria2" then + protocol = "HY2" + elseif protocol == "anytls" then + protocol = "AnyTLS" else protocol = protocol:gsub("^%l",string.upper) end + if type2 == "sing-box" then type2 = "Sing-Box" end type2 = type2 .. " " .. protocol end remarks = "%s:[%s]" % {type2, n.remarks} @@ -849,7 +864,8 @@ local default_file_tree = { armv5 = "arm.*5", armv6 = "arm.*6[^4]*", armv7 = "arm.*7", - armv8 = "arm64" + armv8 = "arm64", + riscv64 = "riscv64" } function get_api_json(url) diff --git a/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua b/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua index 480e987b2..7ab92964a 100644 --- a/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua +++ b/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua @@ -382,6 +382,13 @@ function gen_outbound(flag, node, tag, proxy_table) } end + if node.protocol == "anytls" then + protocol_table = { + password = (node.password and node.password ~= "") and node.password or "", + tls = tls + } + end + if protocol_table then for key, value in pairs(protocol_table) do result[key] = value @@ -667,6 +674,18 @@ function gen_config_server(node) } end + if node.protocol == "anytls" then + protocol_table = { + users = { + { + name = (node.username and node.username ~= "") and node.username or "sekai", + password = node.password + } + }, + tls = tls, + } + end + if node.protocol == "direct" then protocol_table = { network = (node.d_protocol ~= "TCP,UDP") and node.d_protocol or nil, diff --git a/luci-app-passwall2/luasrc/view/passwall2/global/faq.htm b/luci-app-passwall2/luasrc/view/passwall2/global/faq.htm index ae9d0aa8e..b3c26ff52 100644 --- a/luci-app-passwall2/luasrc/view/passwall2/global/faq.htm +++ b/luci-app-passwall2/luasrc/view/passwall2/global/faq.htm @@ -28,7 +28,7 @@ local api = require "luci.passwall2.api" line-height: 1.2rem; } -
+
    <%:DNS related issues:%> diff --git a/luci-app-passwall2/luasrc/view/passwall2/node_list/link_add_node.htm b/luci-app-passwall2/luasrc/view/passwall2/node_list/link_add_node.htm index 1a42aa8ed..0aece6af5 100644 --- a/luci-app-passwall2/luasrc/view/passwall2/node_list/link_add_node.htm +++ b/luci-app-passwall2/luasrc/view/passwall2/node_list/link_add_node.htm @@ -4,9 +4,20 @@ local api = require "luci.passwall2.api"