luci-app-passwall: sync upstream

last commit: 1d01f164b2
This commit is contained in:
gitea-action 2024-12-06 11:00:21 +08:00
parent 72e6dbb7fa
commit 5a4461e545
2 changed files with 10 additions and 9 deletions

View File

@ -216,6 +216,9 @@ function index_status()
local dns_shunt = uci:get(appname, "@global[0]", "dns_shunt") or "dnsmasq" local dns_shunt = uci:get(appname, "@global[0]", "dns_shunt") or "dnsmasq"
if dns_shunt == "smartdns" then if dns_shunt == "smartdns" then
e.dns_mode_status = luci.sys.call("pidof smartdns >/dev/null") == 0 e.dns_mode_status = luci.sys.call("pidof smartdns >/dev/null") == 0
elseif dns_shunt == "chinadns-ng" then
local port = string.match(luci.sys.exec("cat /tmp/etc/passwall/acl/default/chinadns_ng.conf"), "bind%-port%s*(%d+)") or "65353"
e.dns_mode_status = luci.sys.call(string.format("netstat -apn | grep ':%s ' >/dev/null", port)) == 0
else else
e.dns_mode_status = luci.sys.call("netstat -apn | grep ':15353 ' >/dev/null") == 0 e.dns_mode_status = luci.sys.call("netstat -apn | grep ':15353 ' >/dev/null") == 0
end end
@ -258,19 +261,17 @@ function connect_status()
e.use_time = "" e.use_time = ""
local url = luci.http.formvalue("url") local url = luci.http.formvalue("url")
local baidu = string.find(url, "baidu") local baidu = string.find(url, "baidu")
local enabled = uci:get(appname, "@global[0]", "enabled") or "0"
local chn_list = uci:get(appname, "@global[0]", "chn_list") or "direct" local chn_list = uci:get(appname, "@global[0]", "chn_list") or "direct"
local gfw_list = uci:get(appname, "@global[0]", "use_gfw_list") or "1" 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 proxy_mode = uci:get(appname, "@global[0]", "tcp_proxy_mode") or "proxy"
local socks_port = uci:get(appname, "@global[0]", "tcp_node_socks_port") or "1070" local socks_server = luci.sys.exec("[ -f /tmp/etc/passwall/acl/default/TCP_SOCKS_server ] && echo -n $(cat /tmp/etc/passwall/acl/default/TCP_SOCKS_server) || echo -n ''")
local local_proxy = uci:get(appname, "@global[0]", "localhost_proxy") or "1" if socks_server ~= "" then
if enabled == "1" and local_proxy == "0" 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 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 全局 -- 中国列表+百度 or 全局
url = "-x socks5h://127.0.0.1:" .. socks_port .. " " .. url url = "-x socks5h://" .. socks_server .. " " .. url
elseif baidu == nil then elseif baidu == nil then
-- 其他代理模式+百度以外网站 -- 其他代理模式+百度以外网站
url = "-x socks5h://127.0.0.1:" .. socks_port .. " " .. url url = "-x socks5h://" .. socks_server .. " " .. url
end end
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 -w "%{http_code}:%{time_starttransfer}" ' .. url)

View File

@ -20,11 +20,11 @@ index 7c6236f..5486209 100644
define Package/$(PKG_NAME)/postrm define Package/$(PKG_NAME)/postrm
diff --git a/luci-app-passwall/luasrc/controller/passwall.lua b/luci-app-passwall/luasrc/controller/passwall.lua diff --git a/luci-app-passwall/luasrc/controller/passwall.lua b/luci-app-passwall/luasrc/controller/passwall.lua
index 8cc5965..add2a56 100644 index 58c7d1a..a6a2eef 100644
--- a/luci-app-passwall/luasrc/controller/passwall.lua --- a/luci-app-passwall/luasrc/controller/passwall.lua
+++ b/luci-app-passwall/luasrc/controller/passwall.lua +++ b/luci-app-passwall/luasrc/controller/passwall.lua
@@ -273,7 +273,7 @@ function connect_status() @@ -274,7 +274,7 @@ function connect_status()
url = "-x socks5h://127.0.0.1:" .. socks_port .. " " .. url url = "-x socks5h://" .. socks_server .. " " .. url
end end
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_appconnect}" ' .. url)