diff --git a/luci-app-passwall/luasrc/controller/passwall.lua b/luci-app-passwall/luasrc/controller/passwall.lua index add2a564c..a6a2eefe3 100644 --- a/luci-app-passwall/luasrc/controller/passwall.lua +++ b/luci-app-passwall/luasrc/controller/passwall.lua @@ -216,6 +216,9 @@ function index_status() local dns_shunt = uci:get(appname, "@global[0]", "dns_shunt") or "dnsmasq" if dns_shunt == "smartdns" then 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 e.dns_mode_status = luci.sys.call("netstat -apn | grep ':15353 ' >/dev/null") == 0 end @@ -258,19 +261,17 @@ function connect_status() e.use_time = "" local url = luci.http.formvalue("url") 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 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_port = uci:get(appname, "@global[0]", "tcp_node_socks_port") or "1070" - local local_proxy = uci:get(appname, "@global[0]", "localhost_proxy") or "1" - if enabled == "1" and local_proxy == "0" then + 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 ''") + if 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 全局 - url = "-x socks5h://127.0.0.1:" .. socks_port .. " " .. url + url = "-x socks5h://" .. socks_server .. " " .. url elseif baidu == nil then -- 其他代理模式+百度以外网站 - url = "-x socks5h://127.0.0.1:" .. socks_port .. " " .. url + 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) diff --git a/patch-luci-app-passwall.patch b/patch-luci-app-passwall.patch index dd6cab793..e3f286a28 100644 --- a/patch-luci-app-passwall.patch +++ b/patch-luci-app-passwall.patch @@ -20,11 +20,11 @@ index 7c6236f..5486209 100644 define Package/$(PKG_NAME)/postrm 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 +++ b/luci-app-passwall/luasrc/controller/passwall.lua -@@ -273,7 +273,7 @@ function connect_status() - url = "-x socks5h://127.0.0.1:" .. socks_port .. " " .. url +@@ -274,7 +274,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)