AdGuardHome/docker/dns-bind.awk

31 lines
617 B
Awk
Raw Normal View History

2023-04-12 12:48:42 +01:00
/^[^[:space:]]/ { is_dns = /^dns:/ }
/^[[:space:]]+bind_hosts:/ { if (is_dns) prev_line = FNR }
/^[[:space:]]+- .+/ {
if (FNR - prev_line == 1) {
2023-04-18 14:07:11 +01:00
addrs[$2] = true
2023-04-12 12:48:42 +01:00
prev_line = FNR
2023-04-18 14:07:11 +01:00
if ($2 == "0.0.0.0" || $2 == "::") {
delete addrs
addrs["localhost"] = true
# Drop all the other addresses.
prev_line = -1
}
2023-04-12 12:48:42 +01:00
}
}
/^[[:space:]]+port:/ { if (is_dns) port = $2 }
END {
2023-04-18 14:07:11 +01:00
for (addr in addrs) {
if (match(addr, ":")) {
print "[" addr "]:" port
2023-04-12 12:48:42 +01:00
} else {
2023-04-18 14:07:11 +01:00
print addr ":" port
2023-04-12 12:48:42 +01:00
}
}
}