diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile index b83e4c1a4..44f595842 100644 --- a/luci-app-passwall/Makefile +++ b/luci-app-passwall/Makefile @@ -12,6 +12,7 @@ PKG_RELEASE:=1 PKG_CONFIG_DEPENDS:= \ CONFIG_PACKAGE_$(PKG_NAME)_Iptables_Transparent_Proxy \ CONFIG_PACKAGE_$(PKG_NAME)_Nftables_Transparent_Proxy \ + CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Geoview \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Haproxy \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Hysteria \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_NaiveProxy \ @@ -26,7 +27,6 @@ PKG_CONFIG_DEPENDS:= \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Trojan_Plus \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_tuic_client \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Geodata \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Geoview \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Plugin \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Xray \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Xray_Plugin @@ -64,6 +64,11 @@ config PACKAGE_$(PKG_NAME)_Nftables_Transparent_Proxy select PACKAGE_kmod-nft-nat default y if PACKAGE_firewall4 +config PACKAGE_$(PKG_NAME)_INCLUDE_Geoview + bool "Include Geoview" + select PACKAGE_geoview + default n + config PACKAGE_$(PKG_NAME)_INCLUDE_Haproxy bool "Include Haproxy" select PACKAGE_haproxy @@ -141,11 +146,6 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Geodata select PACKAGE_v2ray-geosite default n -config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Geoview - bool "Include V2ray_Geoview" - select PACKAGE_geoview - default n - config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Plugin bool "Include V2ray-Plugin (Shadowsocks Plugin)" select PACKAGE_v2ray-plugin diff --git a/luci-app-passwall/luasrc/controller/passwall.lua b/luci-app-passwall/luasrc/controller/passwall.lua index 8df6d62d0..f5a412974 100644 --- a/luci-app-passwall/luasrc/controller/passwall.lua +++ b/luci-app-passwall/luasrc/controller/passwall.lua @@ -289,6 +289,12 @@ function connect_status() local gfw_list = uci:get(appname, "@global[0]", "use_gfw_list") or "1" local proxy_mode = uci:get(appname, "@global[0]", "tcp_proxy_mode") or "proxy" local socks_server = api.get_cache_var("GLOBAL_TCP_SOCKS_server") + + -- 兼容 curl 8.6 time_starttransfer 错误 + local curl_ver = luci.sys.exec("curl -V 2>/dev/null | head -n 1 | awk '{print $2}' | cut -d. -f1,2 | tr -d ' \n'") or "0" + url = (curl_ver == "8.6") and "-w %{http_code}:%{time_appconnect} https://" .. url + or "-w %{http_code}:%{time_starttransfer} http://" .. url + if socks_server and socks_server ~= "" then if (chn_list == "proxy" and gfw_list == "0" and proxy_mode ~= "proxy" and baidu ~= nil) or (chn_list == "0" and gfw_list == "0" and proxy_mode == "proxy") then -- 中国列表+百度 or 全局 @@ -298,7 +304,7 @@ function connect_status() url = "-x socks5h://" .. socks_server .. " " .. url end end - local result = luci.sys.exec('curl --connect-timeout 3 -o /dev/null -I -sk -w "%{http_code}:%{time_starttransfer}" ' .. url) + local result = luci.sys.exec('curl --connect-timeout 3 -o /dev/null -I -sk ' .. 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}'") 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 c5ed6e209..b32f24099 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 @@ -290,6 +290,9 @@ o:depends({ _tcp_node_bool = "1" }) o:value("dnsmasq", "Dnsmasq") o:value("chinadns-ng", translate("ChinaDNS-NG (recommended)")) +o = s:option(DummyValue, "view_chinadns_log", " ") +o.template = appname .. "/acl/view_chinadns_log" + o = s:option(Flag, "filter_proxy_ipv6", translate("Filter Proxy Host IPv6"), translate("Experimental feature.")) o.default = "0" o:depends({ _tcp_node_bool = "1" }) @@ -418,6 +421,4 @@ o:value("direct", translate("Direct DNS")) o.description = desc .. "" o:depends({dns_shunt = "dnsmasq", tcp_proxy_mode = "proxy", chn_list = "direct"}) -m:append(Template(appname .. "/acl/footer")) - return m diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/log.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/log.lua index 6d2033936..0f96f015b 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/log.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/log.lua @@ -16,9 +16,9 @@ s = fb:section(SimpleSection, translate("Backup and Restore"), translate("Backup "
" .. translate("Note: Restoring configurations across different versions may cause compatibility issues.") .. "") -o = s:option(DummyValue, '', nil) -o.template = appname .. "/log/backup_restore" +s.anonymous = true +s:append(Template(appname .. "/log/backup_restore")) local backup_files = { "/etc/config/passwall", diff --git a/luci-app-passwall/luasrc/passwall/api.lua b/luci-app-passwall/luasrc/passwall/api.lua index 1dbeb84ad..3d9ac3882 100644 --- a/luci-app-passwall/luasrc/passwall/api.lua +++ b/luci-app-passwall/luasrc/passwall/api.lua @@ -4,7 +4,6 @@ bin = require "nixio".bin fs = require "nixio.fs" sys = require "luci.sys" uci = require "luci.model.uci".cursor() -libuci = require "uci".cursor() util = require "luci.util" datatypes = require "luci.cbi.datatypes" jsonc = require "luci.jsonc" @@ -35,33 +34,20 @@ function is_js_luci() return sys.call('[ -f "/www/luci-static/resources/uci.js" ]') == 0 end -function uci_set_list(cursor, config, section, option, value) - if config and section and option then - if not value or #value == 0 then - return cursor:delete(config, section, option) - end - return cursor:set( - config, section, option, - ( type(value) == "table" and value or { value } ) - ) - end - return false -end - -function uci_section(cursor, config, type, name, values) - local stat = true - if name then - stat = cursor:set(config, name, type) - else - name = cursor:add(config, type) - stat = name and true - end - - return stat and name +function is_old_uci() + return sys.call("grep 'require \"uci\"' /usr/lib/lua/luci/model/uci.lua >/dev/null 2>&1") == 0 end function uci_save(cursor, config, commit, apply) - if is_js_luci() then + if is_old_uci() then + cursor:save(config) + if commit then + cursor:commit(config) + if apply then + sys.call("/etc/init.d/" .. config .. " reload > /dev/null 2>&1 &") + end + end + else commit = true if commit then if apply then @@ -70,14 +56,6 @@ function uci_save(cursor, config, commit, apply) sh_uci_commit(config) end end - else - cursor:save(config) - if commit then - cursor:commit(config) - if apply then - sys.call("/etc/init.d/" .. config .. " reload > /dev/null 2>&1 &") - end - end end end diff --git a/luci-app-passwall/luasrc/view/passwall/acl/footer.htm b/luci-app-passwall/luasrc/view/passwall/acl/view_chinadns_log.htm similarity index 81% rename from luci-app-passwall/luasrc/view/passwall/acl/footer.htm rename to luci-app-passwall/luasrc/view/passwall/acl/view_chinadns_log.htm index 6026e6dc9..7c9933a08 100644 --- a/luci-app-passwall/luasrc/view/passwall/acl/footer.htm +++ b/luci-app-passwall/luasrc/view/passwall/acl/view_chinadns_log.htm @@ -5,12 +5,6 @@ local api = require "luci.passwall.api" //' + "?flag=" + sid + "', '_blank')"); + logLink.setAttribute("onclick", "window.open('" + '<%=api.url("get_chinadns_log") .. "?flag=" .. section%>' + "', '_blank')"); select.insertAdjacentElement("afterend", logLink); } }, 1000); diff --git a/luci-app-passwall/luasrc/view/passwall/global/status.htm b/luci-app-passwall/luasrc/view/passwall/global/status.htm index a8729505e..133c2951b 100644 --- a/luci-app-passwall/luasrc/view/passwall/global/status.htm +++ b/luci-app-passwall/luasrc/view/passwall/global/status.htm @@ -166,7 +166,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md -
+
@@ -178,7 +178,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
-
+
@@ -190,7 +190,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
-
+
@@ -202,7 +202,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
-
+
diff --git a/luci-app-passwall/luasrc/view/passwall/log/backup_restore.htm b/luci-app-passwall/luasrc/view/passwall/log/backup_restore.htm index 9bbd10b39..737099acb 100644 --- a/luci-app-passwall/luasrc/view/passwall/log/backup_restore.htm +++ b/luci-app-passwall/luasrc/view/passwall/log/backup_restore.htm @@ -2,25 +2,24 @@ local api = require "luci.passwall.api" -%> -<%+cbi/valueheader%>
- +
- +
- +
@@ -32,8 +31,8 @@ local api = require "luci.passwall.api"
- - + +
@@ -131,4 +130,3 @@ local api = require "luci.passwall.api" } } -<%+cbi/valuefooter%> diff --git a/luci-app-passwall/luasrc/view/passwall/socks_auto_switch/btn.htm b/luci-app-passwall/luasrc/view/passwall/socks_auto_switch/btn.htm index 287c1d2f4..37186c4b2 100644 --- a/luci-app-passwall/luasrc/view/passwall/socks_auto_switch/btn.htm +++ b/luci-app-passwall/luasrc/view/passwall/socks_auto_switch/btn.htm @@ -20,6 +20,9 @@ local api = require "luci.passwall.api" //]]>
" data-index="<%=self.index%>" data-depends="<%=pcdata(self:deplist2json(section))%>"> - - -
\ No newline at end of file + +
+ + +
+
diff --git a/luci-app-passwall/root/usr/share/passwall/app.sh b/luci-app-passwall/root/usr/share/passwall/app.sh index 57b989bd2..45e23031b 100755 --- a/luci-app-passwall/root/usr/share/passwall/app.sh +++ b/luci-app-passwall/root/usr/share/passwall/app.sh @@ -233,11 +233,7 @@ check_ver() { get_new_port() { port=$1 - [ "$port" == "auto" ] && { - port=2082 - local GET_NEW_PORT=$(get_cache_var "get_new_port") - [ -n "${GET_NEW_PORT}" ] && port=${GET_NEW_PORT} - } + [ "$port" == "auto" ] && port=2082 protocol=$(echo $2 | tr 'A-Z' 'a-z') result=$(check_port_exists $port $protocol) if [ "$result" != 0 ]; then @@ -249,7 +245,6 @@ get_new_port() { fi get_new_port $temp $protocol else - set_cache_var "get_new_port" "$port" echo $port fi } diff --git a/luci-app-passwall/root/usr/share/passwall/rules/direct_host b/luci-app-passwall/root/usr/share/passwall/rules/direct_host index 90bcf58a9..ae67f3b87 100644 --- a/luci-app-passwall/root/usr/share/passwall/rules/direct_host +++ b/luci-app-passwall/root/usr/share/passwall/rules/direct_host @@ -4,13 +4,15 @@ microsoft.com dyndns.com douyucdn.cn douyucdn2.cn -ghgo.xyz -gitmirror.com location.services.mozilla.com # google dl.google.com +# github proxy +gh-proxy.com +gitmirror.com + #steam steamcontent.com dl.steam.clngaa.com diff --git a/luci-app-passwall/root/usr/share/passwall/rules/direct_ip b/luci-app-passwall/root/usr/share/passwall/rules/direct_ip index d48bc4a0f..ada52ad89 100644 --- a/luci-app-passwall/root/usr/share/passwall/rules/direct_ip +++ b/luci-app-passwall/root/usr/share/passwall/rules/direct_ip @@ -4,11 +4,11 @@ 223.6.6.6 119.29.29.29 180.76.76.76 -34.149.0.0/16 -72.18.83.0/24 1.12.12.12 120.53.53.53 -203.208.39.192/28 -203.208.40.0/23 180.184.1.1 180.184.2.2 +203.208.39.192/28 +203.208.40.0/23 +34.149.0.0/16 +72.18.83.0/24 diff --git a/luci-app-passwall/root/usr/share/passwall/subscribe.lua b/luci-app-passwall/root/usr/share/passwall/subscribe.lua index 696c18e78..546a41e86 100755 --- a/luci-app-passwall/root/usr/share/passwall/subscribe.lua +++ b/luci-app-passwall/root/usr/share/passwall/subscribe.lua @@ -17,7 +17,7 @@ local ssub, slen, schar, sbyte, sformat, sgsub = string.sub, string.len, string. local split = api.split local jsonParse, jsonStringify = luci.jsonc.parse, luci.jsonc.stringify local base64Decode = api.base64Decode -local uci = api.libuci +local uci = api.uci local fs = api.fs uci:revert(appname) @@ -228,7 +228,7 @@ do set = function(o) for kk, vv in pairs(CONFIG) do if (vv.remarks == id .. "备用节点的列表") then - api.uci_set_list(uci, appname, id, "autoswitch_backup_node", vv.new_nodes) + uci:set_list(appname, id, "autoswitch_backup_node", vv.new_nodes) end end end @@ -299,8 +299,8 @@ do if (vv.remarks == "Xray负载均衡节点[" .. node_id .. "]列表") then uci:foreach(appname, "nodes", function(node2) if node2[".name"] == node[".name"] then - local section = api.uci_section(uci, appname, "nodes", node_id) - api.uci_set_list(uci, appname, section, "balancing_node", vv.new_nodes) + local section = uci:section(appname, "nodes", node_id) + uci:set_list(appname, section, "balancing_node", vv.new_nodes) end end) end @@ -1454,7 +1454,7 @@ local function update_node(manual) local remark = v["remark"] local list = v["list"] for _, vv in ipairs(list) do - local cfgid = api.uci_section(uci, appname, "nodes", api.gen_short_uuid()) + local cfgid = uci:section(appname, "nodes", api.gen_short_uuid()) for kkk, vvv in pairs(vv) do uci:set(appname, cfgid, kkk, vvv) -- sing-box 域名解析策略 diff --git a/luci-app-passwall/root/usr/share/passwall/test.sh b/luci-app-passwall/root/usr/share/passwall/test.sh index 1f596e929..3c54f9805 100755 --- a/luci-app-passwall/root/usr/share/passwall/test.sh +++ b/luci-app-passwall/root/usr/share/passwall/test.sh @@ -73,10 +73,15 @@ url_test_node() { local curlx="socks5h://127.0.0.1:${_tmp_port}" fi sleep 1s + # 兼容 curl 8.6 time_starttransfer 错误 + local curl_ver=$(curl -V 2>/dev/null | head -n 1 | awk '{print $2}' | cut -d. -f1,2 | tr -d ' \n') + local curl_arg="-w %{http_code}:%{time_starttransfer} http://" + [ "${curl_ver}" = "8.6" ] && curl_arg="-w %{http_code}:%{time_appconnect} https://" + local chn_list=$(config_n_get @global[0] chn_list direct) - local probeUrl="https://www.google.com/generate_204" - [ "${chn_list}" = "proxy" ] && probeUrl="https://www.baidu.com" - result=$(curl --connect-timeout 3 -o /dev/null -I -skL -w "%{http_code}:%{time_appconnect}" -x $curlx "${probeUrl}") + local probeUrl="www.google.com/generate_204" + [ "${chn_list}" = "proxy" ] && probeUrl="www.baidu.com" + result=$(curl --connect-timeout 3 -o /dev/null -I -skL -x $curlx ${curl_arg}${probeUrl}) pgrep -af "url_test_${node_id}" | awk '! /test\.sh/{print $1}' | xargs kill -9 >/dev/null 2>&1 rm -rf "/tmp/etc/${CONFIG}/url_test_${node_id}.json" } diff --git a/patch-luci-app-passwall.patch b/patch-luci-app-passwall.patch index af13fe1ec..28e014204 100644 --- a/patch-luci-app-passwall.patch +++ b/patch-luci-app-passwall.patch @@ -1,16 +1,16 @@ diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile -index 6653f5f..b83e4c1 100644 +index 18cdd8d..44f5958 100644 --- a/luci-app-passwall/Makefile +++ b/luci-app-passwall/Makefile -@@ -144,7 +144,7 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Geodata - config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Geoview - bool "Include V2ray_Geoview" +@@ -67,7 +67,7 @@ config PACKAGE_$(PKG_NAME)_Nftables_Transparent_Proxy + config PACKAGE_$(PKG_NAME)_INCLUDE_Geoview + bool "Include Geoview" select PACKAGE_geoview - default y if aarch64||arm||i386||x86_64 + default n - config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Plugin - bool "Include V2ray-Plugin (Shadowsocks Plugin)" + config PACKAGE_$(PKG_NAME)_INCLUDE_Haproxy + bool "Include Haproxy" @@ -177,7 +177,6 @@ define Package/$(PKG_NAME)/conffiles /usr/share/passwall/rules/lanlist_ipv4 /usr/share/passwall/rules/lanlist_ipv6 @@ -19,19 +19,6 @@ index 6653f5f..b83e4c1 100644 endef define Package/$(PKG_NAME)/postrm -diff --git a/luci-app-passwall/luasrc/controller/passwall.lua b/luci-app-passwall/luasrc/controller/passwall.lua -index c01e5ef..8df6d62 100644 ---- a/luci-app-passwall/luasrc/controller/passwall.lua -+++ b/luci-app-passwall/luasrc/controller/passwall.lua -@@ -298,7 +298,7 @@ function connect_status() - url = "-x socks5h://" .. socks_server .. " " .. url - end - end -- local result = luci.sys.exec('curl --connect-timeout 3 -o /dev/null -I -sk -w "%{http_code}:%{time_appconnect}" ' .. 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}'") diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua index 3f6dd8c..952e4c8 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua @@ -59,7 +46,7 @@ index 3f6dd8c..952e4c8 100644 if (m:get("@global_forwarding[0]", "use_nft") or "0") == "1" then diff --git a/luci-app-passwall/luasrc/view/passwall/global/status.htm b/luci-app-passwall/luasrc/view/passwall/global/status.htm -index e8d76ec..a872950 100644 +index eb5527e..133c295 100644 --- a/luci-app-passwall/luasrc/view/passwall/global/status.htm +++ b/luci-app-passwall/luasrc/view/passwall/global/status.htm @@ -1,5 +1,11 @@ @@ -105,42 +92,6 @@ index e8d76ec..a872950 100644 .check { cursor: pointer; } -@@ -138,7 +166,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md -
-
-
--
-+
-
-
-
-@@ -150,7 +178,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md -
-
-
--
-+
-
-
-
-@@ -162,7 +190,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md -
-
-
--
-+
-
-
-
-@@ -174,7 +202,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md -
-
-
--
-+
-
-
-
diff --git a/luci-app-passwall/root/usr/share/passwall/0_default_config b/luci-app-passwall/root/usr/share/passwall/0_default_config index acacfed..427dc3a 100644 --- a/luci-app-passwall/root/usr/share/passwall/0_default_config @@ -155,24 +106,24 @@ index acacfed..427dc3a 100644 config global_forwarding option tcp_no_redir_ports 'disable' diff --git a/luci-app-passwall/root/usr/share/passwall/rules/direct_host b/luci-app-passwall/root/usr/share/passwall/rules/direct_host -index a3b1464..90bcf58 100644 +index a3b1464..ae67f3b 100644 --- a/luci-app-passwall/root/usr/share/passwall/rules/direct_host +++ b/luci-app-passwall/root/usr/share/passwall/rules/direct_host -@@ -4,8 +4,13 @@ microsoft.com - dyndns.com - douyucdn.cn +@@ -6,6 +6,13 @@ douyucdn.cn douyucdn2.cn -+ghgo.xyz -+gitmirror.com location.services.mozilla.com +# google +dl.google.com ++ ++# github proxy ++gh-proxy.com ++gitmirror.com + #steam steamcontent.com dl.steam.clngaa.com -@@ -19,6 +24,15 @@ cdn-qc.content.steamchina.com +@@ -19,6 +26,15 @@ cdn-qc.content.steamchina.com cdn-ali.content.steamchina.com epicgames-download1-1251447533.file.myqcloud.com @@ -189,21 +140,17 @@ index a3b1464..90bcf58 100644 dns.alidns.com doh.pub diff --git a/luci-app-passwall/root/usr/share/passwall/rules/direct_ip b/luci-app-passwall/root/usr/share/passwall/rules/direct_ip -index b73edaa..d48bc4a 100644 +index b73edaa..ada52ad 100644 --- a/luci-app-passwall/root/usr/share/passwall/rules/direct_ip +++ b/luci-app-passwall/root/usr/share/passwall/rules/direct_ip -@@ -4,7 +4,11 @@ - 223.6.6.6 - 119.29.29.29 - 180.76.76.76 -+34.149.0.0/16 -+72.18.83.0/24 - 1.12.12.12 +@@ -8,3 +8,7 @@ 120.53.53.53 -+203.208.39.192/28 -+203.208.40.0/23 180.184.1.1 180.184.2.2 ++203.208.39.192/28 ++203.208.40.0/23 ++34.149.0.0/16 ++72.18.83.0/24 diff --git a/luci-app-passwall/root/usr/share/passwall/rules/proxy_host b/luci-app-passwall/root/usr/share/passwall/rules/proxy_host index 72c498c..4aa1a8c 100644 --- a/luci-app-passwall/root/usr/share/passwall/rules/proxy_host