parent
5d06c7f2e2
commit
682a5c672f
@ -18,7 +18,7 @@ end
|
|||||||
m = Map(appname)
|
m = Map(appname)
|
||||||
|
|
||||||
-- [[ Haproxy Settings ]]--
|
-- [[ Haproxy Settings ]]--
|
||||||
s = m:section(TypedSection, "global_haproxy")
|
s = m:section(TypedSection, "global_haproxy", translate("Basic Settings"))
|
||||||
s.anonymous = true
|
s.anonymous = true
|
||||||
|
|
||||||
s:append(Template(appname .. "/haproxy/status"))
|
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:value("passwall_logic", translate("URL Test") .. string.format("(passwall %s)", translate("Inner implement")))
|
||||||
o:depends("balancing_enable", true)
|
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
|
---- Health Check Inter
|
||||||
o = s:option(Value, "health_check_inter", translate("Health Check Inter"), translate("Units:seconds"))
|
o = s:option(Value, "health_check_inter", translate("Health Check Inter"), translate("Units:seconds"))
|
||||||
o.default = "60"
|
o.default = "60"
|
||||||
@ -69,7 +81,7 @@ end
|
|||||||
o:depends("health_check_type", "passwall_logic")
|
o:depends("health_check_type", "passwall_logic")
|
||||||
|
|
||||||
-- [[ Balancing Settings ]]--
|
-- [[ Balancing Settings ]]--
|
||||||
s = m:section(TypedSection, "haproxy_config", "",
|
s = m:section(TypedSection, "haproxy_config", translate("Node List"),
|
||||||
"<font color='red'>" ..
|
"<font color='red'>" ..
|
||||||
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.") ..
|
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!") ..
|
"\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!") ..
|
||||||
|
@ -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: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()
|
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
|
||||||
|
@ -4,7 +4,17 @@ listen_address=$1
|
|||||||
listen_port=$2
|
listen_port=$2
|
||||||
server_address=$3
|
server_address=$3
|
||||||
server_port=$4
|
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
|
case "$status" in
|
||||||
204|\
|
204|\
|
||||||
200)
|
200)
|
||||||
|
Loading…
Reference in New Issue
Block a user