From eee868fe92d994aeefb6c383c1bec0f218fda817 Mon Sep 17 00:00:00 2001 From: xiaorouji <60100640+xiaorouji@users.noreply.github.com> Date: Tue, 4 Apr 2023 01:28:35 +0800 Subject: [PATCH] luci: fixed --- luci-app-passwall/Makefile | 2 +- .../root/usr/share/passwall/app.sh | 6 +++--- .../root/usr/share/passwall/haproxy.lua | 18 ++++++++++++++---- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile index 3c21a4d3d..3566e4903 100644 --- a/luci-app-passwall/Makefile +++ b/luci-app-passwall/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall PKG_VERSION:=4.62 -PKG_RELEASE:=5 +PKG_RELEASE:=6 PKG_CONFIG_DEPENDS:= \ CONFIG_PACKAGE_$(PKG_NAME)_Iptables_Transparent_Proxy \ diff --git a/luci-app-passwall/root/usr/share/passwall/app.sh b/luci-app-passwall/root/usr/share/passwall/app.sh index 56d3dd103..2b8a2da92 100755 --- a/luci-app-passwall/root/usr/share/passwall/app.sh +++ b/luci-app-passwall/root/usr/share/passwall/app.sh @@ -22,7 +22,7 @@ RULES_PATH=/usr/share/${CONFIG}/rules DNS_N=dnsmasq DNS_PORT=15353 TUN_DNS="127.0.0.1#${DNS_PORT}" -LOCAL_DNS=119.29.29.29 +LOCAL_DNS=119.29.29.29,223.5.5.5 DEFAULT_DNS= IFACES= ENABLED_DEFAULT_ACL=0 @@ -1623,8 +1623,8 @@ ISP_DNS=$(cat $RESOLVFILE 2>/dev/null | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+\.[0-9 ISP_DNS6=$(cat $RESOLVFILE 2>/dev/null | grep -E "([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4}" | awk -F % '{print $1}' | awk -F " " '{print $2}'| sort -u | grep -v -Fx ::1 | grep -v -Fx ::) DEFAULT_DNS=$(uci show dhcp | grep "@dnsmasq" | grep "\.server=" | awk -F '=' '{print $2}' | sed "s/'//g" | tr ' ' '\n' | grep -v "\/" | head -2 | sed ':label;N;s/\n/,/;b label') -[ -z "${DEFAULT_DNS}" ] && DEFAULT_DNS=$(echo -n $ISP_DNS | tr ' ' '\n' | head -2 | tr '\n' ',') -LOCAL_DNS="${DEFAULT_DNS:-119.29.29.29}" +[ -z "${DEFAULT_DNS}" ] && [ "$(echo $ISP_DNS | tr ' ' '\n' | wc -l)" -le 2 ] && DEFAULT_DNS=$(echo -n $ISP_DNS | tr ' ' '\n' | head -2 | tr '\n' ',') +LOCAL_DNS="${DEFAULT_DNS:-119.29.29.29,223.5.5.5}" PROXY_IPV6=$(config_t_get global_forwarding ipv6_tproxy 0) DNS_QUERY_STRATEGY="UseIPv4" diff --git a/luci-app-passwall/root/usr/share/passwall/haproxy.lua b/luci-app-passwall/root/usr/share/passwall/haproxy.lua index 42f12c7b9..634464e33 100644 --- a/luci-app-passwall/root/usr/share/passwall/haproxy.lua +++ b/luci-app-passwall/root/usr/share/passwall/haproxy.lua @@ -30,7 +30,7 @@ end local var = api.get_args(arg) local haproxy_path = var["-path"] local haproxy_conf = var["-conf"] -local haproxy_dns = var["-dns"] or "119.29.29.29" +local haproxy_dns = var["-dns"] or "119.29.29.29:53,223.5.5.5:53" local health_check_type = uci:get(appname, "@global_haproxy[0]", "health_check_type") or "tcp" local health_check_inter = uci:get(appname, "@global_haproxy[0]", "health_check_inter") or "10" @@ -69,19 +69,29 @@ defaults maxconn 3000 resolvers mydns - nameserver dns1 %s:53 resolve_retries 3 timeout retry 3s hold valid 600s - ]] f_out:write(string.format(haproxy_config, haproxy_path, health_check_type == "passwall_logic" and string.format([[ external-check insecure-fork-wanted -]]) or "", haproxy_dns +]]) or "" )) +local index = 0 +string.gsub(haproxy_dns, '[^' .. "," .. ']+', function(w) + index = index + 1 + local s = w:gsub("#", ":") + if not s:find(":") then + s = s .. ":53" + end + f_out:write(string.format([[ + nameserver dns%s %s +]], index, s)) +end) + local listens = {} uci:foreach(appname, "haproxy_config", function(t)