Skip to content

Commit

Permalink
docker: imp zeroes check
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Apr 18, 2023
1 parent 584182e commit 67365d0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
7 changes: 3 additions & 4 deletions docker/dns-bind.awk
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
addrs[$2] = true
prev_line = FNR

if ($2 == "0.0.0.0" || $2 == "::") {
delete addrs
addrs["localhost"] = true

if ($2 == "0.0.0.0" || $2 == "\"\"" || $2 == "'::'") {
# Drop all the other addresses.
delete addrs
addrs[""] = true
prev_line = -1
}
}
Expand Down
28 changes: 23 additions & 5 deletions docker/healthcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ then
error_exit "no DNS bindings could be retrieved from $filename"
fi

first_dns="$( echo "$dns_hosts" | head -n 1 )"
readonly first_dns

# TODO(e.burkov): Deal with 0 port.
case "$( echo "$dns_hosts" | head -n 1 )"
case "$first_dns"
in
(*':0')
error_exit '0 in DNS port is not supported by healthcheck'
Expand All @@ -82,8 +85,23 @@ esac
# See https://github.com/AdguardTeam/AdGuardHome/issues/5642.
wget --no-check-certificate "$web_url" -O /dev/null -q || exit 1

echo "$dns_hosts" | while read -r host
do
nslookup -type=a healthcheck.adguardhome.test. "$host" > /dev/null ||\
test_fqdn="healthcheck.adguardhome.test."
readonly test_fqdn

# The awk script currently returns only port prefixed with colon in case of
# unspecified address.
case "$first_dns"
in
(':'*)
nslookup -type=a "$test_fqdn" "127.0.0.1$first_dns" > /dev/null ||\
nslookup -type=a "$test_fqdn" "[::1]$first_dns" > /dev/null ||\
error_exit "nslookup failed for $host"
done
;;
(*)
echo "$dns_hosts" | while read -r host
do
nslookup -type=a "$test_fqdn" "$host" > /dev/null ||\
error_exit "nslookup failed for $host"
done
;;
esac

0 comments on commit 67365d0

Please sign in to comment.