Add a maximum timeout for service checks.

The connec timeout did not include DNS looksup, and if DNS is broken this can hang forever. Add
a maxmimum timeout so this call will eventually terminate regardless.
This commit is contained in:
Tim Wilkinson 2023-01-08 00:02:08 -08:00 committed by Joe AE6XE
parent fb6060cf3a
commit 8b3551b539
1 changed files with 1 additions and 1 deletions

View File

@ -192,7 +192,7 @@ if validate then
valid_services[#valid_services + 1] = service valid_services[#valid_services + 1] = service
elseif proto == "http" then elseif proto == "http" then
-- http so looks like a link. http check it -- http so looks like a link. http check it
local status, effective_url = io.popen("/usr/bin/curl --retry 0 --connect-timeout 2 --speed-time 5 --speed-limit 1000 --silent --output /dev/null --location --write-out '%{http_code} %{url_effective}' " .. "http://" .. hostname .. ":" .. port .. path):read("*a"):match("^(%d+) (.*)") local status, effective_url = io.popen("/usr/bin/curl --max-time 10 --retry 0 --connect-timeout 2 --speed-time 5 --speed-limit 1000 --silent --output /dev/null --location --write-out '%{http_code} %{url_effective}' " .. "http://" .. hostname .. ":" .. port .. path):read("*a"):match("^(%d+) (.*)")
if status == "200" or status == "401" then if status == "200" or status == "401" then
valid_services[#valid_services + 1] = service valid_services[#valid_services + 1] = service
elseif status == "301" or status == "302" or status == "303" or status == "307" or status == "308" then elseif status == "301" or status == "302" or status == "303" or status == "307" or status == "308" then