mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-08 11:46:35 +00:00
d14354e892 added both probes reading only /etc/dnsmasq.conf, but svc-net-tor writes its onion zone to /etc/dnsmasq.d/tor-onion.conf and leaves the main file with nothing but a conf-dir pointer. Every Tor host of run 33698844864 therefore captured resolve-inzone.txt as '[no output, exit 2]' and all 471 sampler lines as inzone=unconfigured: during the resolver outage that ended Gitea#0, nobody ever asked dnsmasq for an onion name, and two investigations went without the one measurement that would have settled them.
Both probes now follow the conf-dir pointer, main file first so a lab node with its zone in the main config answers as before. Each is exercised by a test that runs it against real files rather than comparing its text, which the rescue constant had no test for at all.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
52 lines
1.5 KiB
Bash
Executable File
52 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
# Run 32118850138 could bound the dnsmasq listener loss only to a 6m39s
|
|
# window between two host DNS consumers; one line per 10s pins it to one
|
|
# sample bucket and names which :53 listener (hex local_address) was left.
|
|
set -u
|
|
|
|
EXTERNAL_PROBE_NAME=deb.debian.org
|
|
|
|
sample_once() {
|
|
socks="$(awk '$2 ~ /:0035$/ && $3 == "00000000:0000" {printf " %s", $2}' "${1}")"
|
|
printf '%s%s\n' "$(date -u '+%Y-%m-%dT%H:%M:%SZ')" "${socks:- none}"
|
|
}
|
|
|
|
zone_probe_name() {
|
|
dirs="$(sed -n 's|^[[:space:]]*conf-dir=\([^,[:space:]]*\).*|\1|p' "${1}" 2>/dev/null)"
|
|
# shellcheck disable=SC2086 # a dnsmasq conf-dir path carries no whitespace
|
|
zone="$(grep -rhs '^[[:space:]]*address=/' "${1}" ${dirs} |
|
|
sed -n 's|^[[:space:]]*address=/\([^/]*\)/.*|\1|p' | head -n1)"
|
|
[ -n "${zone}" ] || return 0
|
|
printf 'rescue-probe.%s' "${zone}"
|
|
}
|
|
|
|
answer_once() {
|
|
name="${1}"
|
|
start="$(date -u '+%s%3N')"
|
|
if timeout 3 getent ahosts "${name}" >/dev/null 2>&1; then
|
|
verdict=ok
|
|
else
|
|
verdict=fail
|
|
fi
|
|
printf ' %s=%s/%sms' "${name}" "${verdict}" "$(($(date -u '+%s%3N') - start))"
|
|
}
|
|
|
|
[ "${DNS53_SAMPLER_LIB:-}" = "1" ] && return 0
|
|
|
|
: "${INFINITO_DNS53_SAMPLER_LOG:?INFINITO_DNS53_SAMPLER_LOG must be set}"
|
|
mkdir -p "$(dirname "${INFINITO_DNS53_SAMPLER_LOG}")"
|
|
while :; do
|
|
{
|
|
printf '%s' "$(sample_once /proc/net/udp)"
|
|
inzone="$(zone_probe_name /etc/dnsmasq.conf)"
|
|
if [ -n "${inzone}" ]; then
|
|
answer_once "${inzone}"
|
|
else
|
|
printf ' inzone=unconfigured'
|
|
fi
|
|
answer_once "${EXTERNAL_PROBE_NAME}"
|
|
printf '\n'
|
|
} >>"${INFINITO_DNS53_SAMPLER_LOG}"
|
|
sleep 10
|
|
done
|