From 0ea224a9e442a7994e5b271a7df60b64b6860ba7 Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Thu, 13 Apr 2023 17:40:45 +0300 Subject: [PATCH] Pull request 1826: 5714 fix-docker-health Merge in DNS/adguard-home from 5714-fix-docker-health to master Updates #5714. Squashed commit of the following: commit 61251bffd7a21f1ceb867cc89de0a171645ca4c2 Author: Eugene Burkov Date: Thu Apr 13 16:45:41 2023 +0300 docker: use localhost for unspecified --- docker/dns-bind.awk | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/docker/dns-bind.awk b/docker/dns-bind.awk index 4580638e..4173614c 100644 --- a/docker/dns-bind.awk +++ b/docker/dns-bind.awk @@ -4,19 +4,27 @@ /^[[:space:]]+- .+/ { if (FNR - prev_line == 1) { - addrs[addrsnum++] = $2 + addrs[$2] = true prev_line = FNR + + if ($2 == "0.0.0.0" || $2 == "::") { + delete addrs + addrs["localhost"] = true + + # Drop all the other addresses. + prev_line = -1 + } } } /^[[:space:]]+port:/ { if (is_dns) port = $2 } END { - for (i in addrs) { - if (match(addrs[i], ":")) { - print "[" addrs[i] "]:" port + for (addr in addrs) { + if (match(addr, ":")) { + print "[" addr "]:" port } else { - print addrs[i] ":" port + print addr ":" port } } }