AdGuardHome/docker/dns-bind.awk
Ainar Garipov f553eee842 Pull request 1804: newline-lint
Merge in DNS/adguard-home from newline-lint to master

Squashed commit of the following:

commit 2fc0b662b9ac9d954275c5ebe8c140be4cd365be
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Apr 6 14:16:14 2023 +0300

    client: rm line

commit 10246727179a84094edd17fad5cd6f0a5c38b821
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Apr 6 13:51:06 2023 +0300

    all: add newline lint
2023-04-06 14:21:46 +03:00

23 lines
441 B
Awk

/^[^[:space:]]/ { is_dns = /^dns:/ }
/^[[:space:]]+bind_hosts:/ { if (is_dns) prev_line = FNR }
/^[[:space:]]+- .+/ {
if (FNR - prev_line == 1) {
addrs[addrsnum++] = $2
prev_line = FNR
}
}
/^[[:space:]]+port:/ { if (is_dns) port = $2 }
END {
for (i in addrs) {
if (match(addrs[i], ":")) {
print "[" addrs[i] "]:" port
} else {
print addrs[i] ":" port
}
}
}