diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua index a02f7846e..effc8fa2d 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/haproxy.lua @@ -18,7 +18,7 @@ end m = Map(appname) -- [[ Haproxy Settings ]]-- -s = m:section(TypedSection, "global_haproxy") +s = m:section(TypedSection, "global_haproxy", translate("Basic Settings")) s.anonymous = true s:append(Template(appname .. "/haproxy/status")) @@ -56,6 +56,18 @@ o:value("tcp", "TCP") o:value("passwall_logic", translate("URL Test") .. string.format("(passwall %s)", translate("Inner implement"))) o:depends("balancing_enable", true) +---- Passwall Inner implement Probe URL +o = s:option(Value, "health_probe_url", translate("Probe URL")) +o.default = "https://www.google.com/generate_204" +o:value("https://cp.cloudflare.com/", "Cloudflare") +o:value("https://www.gstatic.com/generate_204", "Gstatic") +o:value("https://www.google.com/generate_204", "Google") +o:value("https://www.youtube.com/generate_204", "YouTube") +o:value("https://connect.rom.miui.com/generate_204", "MIUI (CN)") +o:value("https://connectivitycheck.platform.hicloud.com/generate_204", "HiCloud (CN)") +o.description = translate("The URL used to detect the connection status.") +o:depends("health_check_type", "passwall_logic") + ---- Health Check Inter o = s:option(Value, "health_check_inter", translate("Health Check Inter"), translate("Units:seconds")) o.default = "60" @@ -69,7 +81,7 @@ end o:depends("health_check_type", "passwall_logic") -- [[ Balancing Settings ]]-- -s = m:section(TypedSection, "haproxy_config", "", +s = m:section(TypedSection, "haproxy_config", translate("Node List"), "" .. translate("Add a node, Export Of Multi WAN Only support Multi Wan. Load specific gravity range 1-256. Multiple primary servers can be load balanced, standby will only be enabled when the primary server is offline! Multiple groups can be set, Haproxy port same one for each group.") .. "\n" .. translate("Note that the node configuration parameters for load balancing must be consistent when use TCP health check type, otherwise it cannot be used normally!") .. diff --git a/luci-app-passwall/root/usr/share/passwall/haproxy.lua b/luci-app-passwall/root/usr/share/passwall/haproxy.lua index 3e794b578..67366ae1f 100644 --- a/luci-app-passwall/root/usr/share/passwall/haproxy.lua +++ b/luci-app-passwall/root/usr/share/passwall/haproxy.lua @@ -220,3 +220,11 @@ listen console f_out:write("\n" .. string.format(str, console_port, (console_user and console_user ~= "" and console_password and console_password ~= "") and "stats auth " .. console_user .. ":" .. console_password or "")) f_out:close() + +--passwall内置健康检查URL +if health_check_type == "passwall_logic" then + local probeUrl = uci:get(appname, "@global_haproxy[0]", "health_probe_url") or "https://www.google.com/generate_204" + local f_url = io.open(haproxy_path .. "/Probe_URL", "w") + f_url:write(probeUrl) + f_url:close() +end diff --git a/luci-app-passwall/root/usr/share/passwall/haproxy_check.sh b/luci-app-passwall/root/usr/share/passwall/haproxy_check.sh index 870ffb575..dcf2879af 100755 --- a/luci-app-passwall/root/usr/share/passwall/haproxy_check.sh +++ b/luci-app-passwall/root/usr/share/passwall/haproxy_check.sh @@ -4,7 +4,17 @@ listen_address=$1 listen_port=$2 server_address=$3 server_port=$4 -status=$(/usr/bin/curl -I -o /dev/null -skL -x socks5h://${server_address}:${server_port} --connect-timeout 3 --retry 3 -w %{http_code} "https://www.google.com/generate_204") + +probe_file="/tmp/etc/passwall/haproxy/Probe_URL" +probeUrl="https://www.google.com/generate_204" +if [ -f "$probe_file" ]; then + firstLine=$(head -n 1 "$probe_file" | tr -d ' \t') + if [ -n "$firstLine" ]; then + probeUrl="$firstLine" + fi +fi + +status=$(/usr/bin/curl -I -o /dev/null -skL -x socks5h://${server_address}:${server_port} --connect-timeout 3 --retry 3 -w %{http_code} "${probeUrl}") case "$status" in 204|\ 200)