From 6969c54a3dc185027f3d343e78ac5f6261475aee Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 19:54:59 +0800 Subject: [PATCH] update 2024-02-19 19:54:59 --- luci-app-passwall/Makefile | 14 +- .../luasrc/controller/passwall.lua | 43 +-- .../luasrc/model/cbi/passwall/client/acl.lua | 33 -- .../model/cbi/passwall/client/acl_config.lua | 250 ++++++------ .../model/cbi/passwall/client/global.lua | 101 ++--- .../cbi/passwall/client/node_subscribe.lua | 5 - .../passwall/client/node_subscribe_config.lua | 5 - .../model/cbi/passwall/client/other.lua | 2 +- .../model/cbi/passwall/client/type/brook.lua | 40 -- .../cbi/passwall/client/type/trojan-go.lua | 119 ------ .../model/cbi/passwall/server/type/brook.lua | 41 -- .../cbi/passwall/server/type/trojan-go.lua | 159 -------- luci-app-passwall/luasrc/passwall/com.lua | 27 -- .../luasrc/passwall/server_app.lua | 12 - .../luasrc/passwall/util_trojan.lua | 54 --- .../luasrc/view/passwall/global/status.htm | 7 +- .../passwall/node_list/link_share_man.htm | 207 ---------- luci-app-passwall/po/zh-cn/passwall.po | 25 +- .../root/usr/share/passwall/0_default_config | 12 +- .../root/usr/share/passwall/app.sh | 265 +++++-------- .../usr/share/passwall/helper_dnsmasq_add.lua | 218 ++++++----- .../root/usr/share/passwall/iptables.sh | 352 ++++++++--------- .../root/usr/share/passwall/nftables.sh | 359 +++++++++--------- .../root/usr/share/passwall/rules/proxy_host | 1 + .../root/usr/share/passwall/subscribe.lua | 78 +--- 25 files changed, 791 insertions(+), 1638 deletions(-) delete mode 100644 luci-app-passwall/luasrc/model/cbi/passwall/client/type/brook.lua delete mode 100644 luci-app-passwall/luasrc/model/cbi/passwall/client/type/trojan-go.lua delete mode 100644 luci-app-passwall/luasrc/model/cbi/passwall/server/type/brook.lua delete mode 100644 luci-app-passwall/luasrc/model/cbi/passwall/server/type/trojan-go.lua diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile index 1e3f9001..7befa193 100644 --- a/luci-app-passwall/Makefile +++ b/luci-app-passwall/Makefile @@ -6,13 +6,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall -PKG_VERSION:=4.73-3 +PKG_VERSION:=4.74-1 PKG_RELEASE:= PKG_CONFIG_DEPENDS:= \ CONFIG_PACKAGE_$(PKG_NAME)_Iptables_Transparent_Proxy \ CONFIG_PACKAGE_$(PKG_NAME)_Nftables_Transparent_Proxy \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Brook \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Haproxy \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Hysteria \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_NaiveProxy \ @@ -24,7 +23,6 @@ PKG_CONFIG_DEPENDS:= \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Libev_Server \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Simple_Obfs \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_SingBox \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Trojan_GO \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Trojan_Plus \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_tuic_client \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Geodata \ @@ -67,11 +65,6 @@ config PACKAGE_$(PKG_NAME)_Nftables_Transparent_Proxy depends on PACKAGE_$(PKG_NAME) default y if PACKAGE_firewall4 -config PACKAGE_$(PKG_NAME)_INCLUDE_Brook - bool "Include Brook" - select PACKAGE_brook - default n - config PACKAGE_$(PKG_NAME)_INCLUDE_Haproxy bool "Include Haproxy" select PACKAGE_haproxy @@ -132,11 +125,6 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_SingBox select PACKAGE_sing-box default y if aarch64||arm||i386||x86_64 -config PACKAGE_$(PKG_NAME)_INCLUDE_Trojan_GO - bool "Include Trojan-GO" - select PACKAGE_trojan-go - default n - config PACKAGE_$(PKG_NAME)_INCLUDE_Trojan_Plus bool "Include Trojan-Plus" select PACKAGE_trojan-plus diff --git a/luci-app-passwall/luasrc/controller/passwall.lua b/luci-app-passwall/luasrc/controller/passwall.lua index a9882b33..83fc01d2 100644 --- a/luci-app-passwall/luasrc/controller/passwall.lua +++ b/luci-app-passwall/luasrc/controller/passwall.lua @@ -224,35 +224,22 @@ function socks_status() end function connect_status() - local e = {} - e.use_time = "" - local url = luci.http.formvalue("url") - local hostname = url:match("//([^/]+)") - local pingOutput = luci.sys.exec("ping -c 3 " .. hostname .. " | tail -1") - if pingOutput and pingOutput:find("min/avg/max") then - local avgPingTime = pingOutput:match("/(%d+%.%d+)/") - if avgPingTime then - e.use_time = string.format("%.2f", tonumber(avgPingTime)) - e.ping_type = "ping" - else - e.use_time = "N/A" - e.ping_type = "ping" - end - else - local result = luci.sys.exec('curl --connect-timeout 3 -o /dev/null -I -sk -w "%{http_code}:%{time_appconnect}" ' .. url) - local code = tonumber(luci.sys.exec("echo -n '" .. result .. "' | awk -F ':' '{print $1}'") or "0") - if code ~= 0 then - local use_time = luci.sys.exec("echo -n '" .. result .. "' | awk -F ':' '{print $2}'") - if use_time:find("%.") then - e.use_time = string.format("%.2f", use_time * 1000) - else - e.use_time = string.format("%.2f", use_time / 1000) - end - e.ping_type = "curl" + local e = {} + e.use_time = "" + local url = luci.http.formvalue("url") + local result = luci.sys.exec('curl --connect-timeout 3 -o /dev/null -I -sk -w "%{http_code}:%{time_starttransfer}" ' .. url) + local code = tonumber(luci.sys.exec("echo -n '" .. result .. "' | awk -F ':' '{print $1}'") or "0") + if code ~= 0 then + local use_time = luci.sys.exec("echo -n '" .. result .. "' | awk -F ':' '{print $2}'") + if use_time:find("%.") then + e.use_time = string.format("%.2f", use_time * 1000) + else + e.use_time = string.format("%.2f", use_time / 1000) end - end - luci.http.prepare_content("application/json") - luci.http.write_json(e) + e.ping_type = "curl" + end + luci.http.prepare_content("application/json") + luci.http.write_json(e) end function ping_node() diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/acl.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/acl.lua index 2378a999..475df256 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/acl.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/acl.lua @@ -1,7 +1,6 @@ local api = require "luci.passwall.api" local appname = api.appname local sys = api.sys -local has_chnlist = api.fs.access("/usr/share/passwall/rules/chnlist") m = Map(appname) api.set_apply_on_parse(m) @@ -13,8 +12,6 @@ o = s:option(Flag, "acl_enable", translate("Main switch")) o.rmempty = false o.default = false -local global_proxy_mode = (m:get("@global[0]", "tcp_proxy_mode") or "") .. (m:get("@global[0]", "udp_proxy_mode") or "") - -- [[ ACLs Settings ]]-- s = m:section(TypedSection, "acl_rule") s.template = "cbi/tblsection" @@ -66,36 +63,6 @@ o.cfgvalue = function(t, n) return e end ----- TCP Proxy Mode -tcp_proxy_mode = s:option(ListValue, "tcp_proxy_mode", "TCP " .. translate("Proxy Mode")) -tcp_proxy_mode.default = "default" -tcp_proxy_mode.rmempty = false -tcp_proxy_mode:value("default", translate("Default")) -tcp_proxy_mode:value("disable", translate("No Proxy")) -tcp_proxy_mode:value("global", translate("Global Proxy")) -if has_chnlist and global_proxy_mode:find("returnhome") then - tcp_proxy_mode:value("returnhome", translate("China List")) -else - tcp_proxy_mode:value("gfwlist", translate("GFW List")) - tcp_proxy_mode:value("chnroute", translate("Not China List")) -end -tcp_proxy_mode:value("direct/proxy", translate("Only use direct/proxy list")) - ----- UDP Proxy Mode -udp_proxy_mode = s:option(ListValue, "udp_proxy_mode", "UDP " .. translate("Proxy Mode")) -udp_proxy_mode.default = "default" -udp_proxy_mode.rmempty = false -udp_proxy_mode:value("default", translate("Default")) -udp_proxy_mode:value("disable", translate("No Proxy")) -udp_proxy_mode:value("global", translate("Global Proxy")) -if has_chnlist and global_proxy_mode:find("returnhome") then - udp_proxy_mode:value("returnhome", translate("China List")) -else - udp_proxy_mode:value("gfwlist", translate("GFW List")) - udp_proxy_mode:value("chnroute", translate("Not China List")) -end -udp_proxy_mode:value("direct/proxy", translate("Only use direct/proxy list")) - --[[ ---- TCP No Redir Ports o = s:option(Value, "tcp_no_redir_ports", translate("TCP No Redir Ports")) diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/acl_config.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/acl_config.lua index 81b147c9..45b909c7 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/acl_config.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/acl_config.lua @@ -1,9 +1,12 @@ local api = require "luci.passwall.api" local appname = api.appname +local uci = api.uci local sys = api.sys local has_singbox = api.finded_com("singbox") local has_xray = api.finded_com("xray") +local has_gfwlist = api.fs.access("/usr/share/passwall/rules/gfwlist") local has_chnlist = api.fs.access("/usr/share/passwall/rules/chnlist") +local has_chnroute = api.fs.access("/usr/share/passwall/rules/chnroute") local port_validate = function(self, value, t) return value:gsub("-", ":") @@ -17,8 +20,6 @@ for k, e in ipairs(api.get_valid_nodes()) do nodes_table[#nodes_table + 1] = e end -local global_proxy_mode = (m:get("@global[0]", "tcp_proxy_mode") or "") .. (m:get("@global[0]", "udp_proxy_mode") or "") - local dynamicList_write = function(self, section, value) local t = {} local t2 = {} @@ -140,92 +141,17 @@ sources.validate = function(self, value, t) end sources.write = dynamicList_write ----- TCP No Redir Ports -o = s:option(Value, "tcp_no_redir_ports", translate("TCP No Redir Ports")) -o.default = "default" -o:value("disable", translate("No patterns are used")) -o:value("default", translate("Default")) -o:value("1:65535", translate("All")) -o.validate = port_validate - ----- UDP No Redir Ports -o = s:option(Value, "udp_no_redir_ports", translate("UDP No Redir Ports")) -o.default = "default" -o:value("disable", translate("No patterns are used")) -o:value("default", translate("Default")) -o:value("1:65535", translate("All")) -o.validate = port_validate - ----- TCP Proxy Drop Ports -o = s:option(Value, "tcp_proxy_drop_ports", translate("TCP Proxy Drop Ports")) -o.default = "default" -o:value("disable", translate("No patterns are used")) -o:value("default", translate("Default")) -o.validate = port_validate - ----- UDP Proxy Drop Ports -o = s:option(Value, "udp_proxy_drop_ports", translate("UDP Proxy Drop Ports")) -o.default = "default" -o:value("disable", translate("No patterns are used")) -o:value("default", translate("Default")) -o:value("80,443", translate("QUIC")) -o.validate = port_validate - ----- TCP Redir Ports -o = s:option(Value, "tcp_redir_ports", translate("TCP Redir Ports")) -o.default = "default" -o:value("default", translate("Default")) -o:value("1:65535", translate("All")) -o:value("80,443", "80,443") -o:value("80:65535", "80 " .. translate("or more")) -o:value("1:443", "443 " .. translate("or less")) -o.validate = port_validate - ----- UDP Redir Ports -o = s:option(Value, "udp_redir_ports", translate("UDP Redir Ports")) -o.default = "default" -o:value("default", translate("Default")) -o:value("1:65535", translate("All")) -o:value("53", "53") -o.validate = port_validate - ----- TCP Proxy Mode -tcp_proxy_mode = s:option(ListValue, "tcp_proxy_mode", "TCP " .. translate("Proxy Mode")) -tcp_proxy_mode.default = "default" -tcp_proxy_mode.rmempty = false -tcp_proxy_mode:value("default", translate("Default")) -tcp_proxy_mode:value("disable", translate("No Proxy")) -tcp_proxy_mode:value("global", translate("Global Proxy")) -if has_chnlist and global_proxy_mode:find("returnhome") then - tcp_proxy_mode:value("returnhome", translate("China List")) -else - tcp_proxy_mode:value("gfwlist", translate("GFW List")) - tcp_proxy_mode:value("chnroute", translate("Not China List")) -end -tcp_proxy_mode:value("direct/proxy", translate("Only use direct/proxy list")) - ----- UDP Proxy Mode -udp_proxy_mode = s:option(ListValue, "udp_proxy_mode", "UDP " .. translate("Proxy Mode")) -udp_proxy_mode.default = "default" -udp_proxy_mode.rmempty = false -udp_proxy_mode:value("default", translate("Default")) -udp_proxy_mode:value("disable", translate("No Proxy")) -udp_proxy_mode:value("global", translate("Global Proxy")) -if has_chnlist and global_proxy_mode:find("returnhome") then - udp_proxy_mode:value("returnhome", translate("China List")) -else - udp_proxy_mode:value("gfwlist", translate("GFW List")) - udp_proxy_mode:value("chnroute", translate("Not China List")) -end -udp_proxy_mode:value("direct/proxy", translate("Only use direct/proxy list")) - +local TCP_NODE = uci:get(appname, "@global[0]", "tcp_node") tcp_node = s:option(ListValue, "tcp_node", "" .. translate("TCP Node") .. "") tcp_node.default = "default" -tcp_node:value("default", translate("Default")) +tcp_node:value("nil", translate("Close")) +tcp_node:value("default", translate("Use global config") .. "(" .. TCP_NODE .. ")") +local UDP_NODE = uci:get(appname, "@global[0]", "udp_node") udp_node = s:option(ListValue, "udp_node", "" .. translate("UDP Node") .. "") udp_node.default = "default" -udp_node:value("default", translate("Default")) +udp_node:value("nil", translate("Close")) +udp_node:value("default", translate("Use global config") .. "(" .. UDP_NODE .. ")") udp_node:value("tcp", translate("Same as the tcp node")) for k, v in pairs(nodes_table) do @@ -233,13 +159,112 @@ for k, v in pairs(nodes_table) do udp_node:value(v.id, v["remark"]) end +---- TCP No Redir Ports +local TCP_NO_REDIR_PORTS = uci:get(appname, "@global_forwarding[0]", "tcp_no_redir_ports") +o = s:option(Value, "tcp_no_redir_ports", translate("TCP No Redir Ports")) +o.default = "default" +o:value("disable", translate("No patterns are used")) +o:value("default", translate("Use global config") .. "(" .. TCP_NO_REDIR_PORTS .. ")") +o:value("1:65535", translate("All")) +o.validate = port_validate +o:depends({ tcp_node = "nil", ['!reverse'] = true }) + +---- UDP No Redir Ports +local UDP_NO_REDIR_PORTS = uci:get(appname, "@global_forwarding[0]", "udp_no_redir_ports") +o = s:option(Value, "udp_no_redir_ports", translate("UDP No Redir Ports")) +o.default = "default" +o:value("disable", translate("No patterns are used")) +o:value("default", translate("Use global config") .. "(" .. UDP_NO_REDIR_PORTS .. ")") +o:value("1:65535", translate("All")) +o.validate = port_validate +o:depends({ udp_node = "nil", ['!reverse'] = true }) + +---- TCP Proxy Drop Ports +local TCP_PROXY_DROP_PORTS = uci:get(appname, "@global_forwarding[0]", "tcp_proxy_drop_ports") +o = s:option(Value, "tcp_proxy_drop_ports", translate("TCP Proxy Drop Ports")) +o.default = "default" +o:value("disable", translate("No patterns are used")) +o:value("default", translate("Default")) +o.validate = port_validate +o:value("default", translate("Use global config") .. "(" .. TCP_PROXY_DROP_PORTS .. ")") +o:depends({ tcp_node = "nil", ['!reverse'] = true }) + +---- UDP Proxy Drop Ports +local UDP_PROXY_DROP_PORTS = uci:get(appname, "@global_forwarding[0]", "udp_proxy_drop_ports") +o = s:option(Value, "udp_proxy_drop_ports", translate("UDP Proxy Drop Ports")) +o.default = "default" +o:value("disable", translate("No patterns are used")) +o:value("default", translate("Use global config") .. "(" .. UDP_PROXY_DROP_PORTS .. ")") +o:value("80,443", translate("QUIC")) +o.validate = port_validate +o:depends({ udp_node = "nil", ['!reverse'] = true }) + +---- TCP Redir Ports +local TCP_REDIR_PORTS = uci:get(appname, "@global_forwarding[0]", "tcp_redir_ports") +o = s:option(Value, "tcp_redir_ports", translate("TCP Redir Ports")) +o.default = "default" +o:value("default", translate("Use global config") .. "(" .. TCP_REDIR_PORTS .. ")") +o:value("1:65535", translate("All")) +o:value("80,443", "80,443") +o:value("80:65535", "80 " .. translate("or more")) +o:value("1:443", "443 " .. translate("or less")) +o.validate = port_validate +o:depends({ tcp_node = "nil", ['!reverse'] = true }) + +---- UDP Redir Ports +local UDP_REDIR_PORTS = uci:get(appname, "@global_forwarding[0]", "udp_redir_ports") +o = s:option(Value, "udp_redir_ports", translate("UDP Redir Ports")) +o.default = "default" +o:value("default", translate("Use global config") .. "(" .. UDP_REDIR_PORTS .. ")") +o:value("1:65535", translate("All")) +o:value("53", "53") +o.validate = port_validate +o:depends({ udp_node = "nil", ['!reverse'] = true }) + +o = s:option(Flag, "use_direct_list", translatef("Use %s", translate("Direct List"))) +o.default = "1" +o:depends({ tcp_node = "nil", ['!reverse'] = true }) + +o = s:option(Flag, "use_proxy_list", translatef("Use %s", translate("Proxy List"))) +o.default = "1" +o:depends({ tcp_node = "nil", ['!reverse'] = true }) + +o = s:option(Flag, "use_block_list", translatef("Use %s", translate("Block List"))) +o.default = "1" +o:depends({ tcp_node = "nil", ['!reverse'] = true }) + +if has_gfwlist then + o = s:option(Flag, "use_gfw_list", translatef("Use %s", translate("GFW List"))) + o.default = "1" + o:depends({ tcp_node = "nil", ['!reverse'] = true }) +end + +if has_chnlist or has_chnroute then + o = s:option(ListValue, "chn_list", translate("China List")) + o:value("0", translate("Close(Not use)")) + o:value("direct", translate("Direct Connection")) + o:value("proxy", translate("Proxy")) + o.default = "direct" + o:depends({ tcp_node = "nil", ['!reverse'] = true }) +end + +o = s:option(ListValue, "tcp_proxy_mode", "TCP " .. translate("Proxy Mode")) +o:value("disable", translate("No Proxy")) +o:value("proxy", translate("Proxy")) +o:depends({ tcp_node = "nil", ['!reverse'] = true }) + +o = s:option(ListValue, "udp_proxy_mode", "UDP " .. translate("Proxy Mode")) +o:value("disable", translate("No Proxy")) +o:value("proxy", translate("Proxy")) +o:depends({ udp_node = "nil", ['!reverse'] = true }) + o = s:option(Flag, "filter_proxy_ipv6", translate("Filter Proxy Host IPv6"), translate("Experimental feature.")) o.default = "0" -o:depends({ tcp_node = "default", ['!reverse'] = true }) +o:depends({ tcp_node = "nil", ['!reverse'] = true }) ---- DNS Forward Mode o = s:option(ListValue, "dns_mode", translate("Filter Mode")) -o:depends({ tcp_node = "default", ['!reverse'] = true }) +o:depends({ tcp_node = "nil", ['!reverse'] = true }) if api.is_finded("dns2socks") then o:value("dns2socks", "dns2socks") end @@ -338,46 +363,33 @@ end if api.is_finded("chinadns-ng") then o = s:option(Flag, "chinadns_ng", translate("ChinaDNS-NG"), translate("The effect is better, but will increase the memory.")) o.default = "0" - o:depends({ tcp_proxy_mode = "gfwlist", dns_mode = "dns2socks" }) - o:depends({ tcp_proxy_mode = "gfwlist", dns_mode = "xray" }) - o:depends({ tcp_proxy_mode = "gfwlist", dns_mode = "sing-box" }) - o:depends({ tcp_proxy_mode = "chnroute", dns_mode = "dns2socks" }) - o:depends({ tcp_proxy_mode = "chnroute", dns_mode = "xray" }) - o:depends({ tcp_proxy_mode = "chnroute", dns_mode = "sing-box" }) - chinadns_ng_default_tag = s:option(ListValue, "chinadns_ng_default_tag", translate("ChinaDNS-NG Domain Default Tag")) - chinadns_ng_default_tag.default = "smart" - chinadns_ng_default_tag:value("smart", translate("Smart DNS")) - chinadns_ng_default_tag:value("gfw", translate("Remote DNS")) - chinadns_ng_default_tag:value("chn", translate("Direct DNS")) - chinadns_ng_default_tag.description = "