#!/bin/sh
# dnseval against the packaged public resolver lists: full list when the
# host has IPv6 connectivity, v4-only otherwise (v6 entries on a v4-only
# network just burn the reply timeout)
list=/usr/share/dnsdiag/public-servers.txt
if ! { command -v ip >/dev/null 2>&1 && ip -6 route show default 2>/dev/null | grep -q .; } \
    && [ -z "$(getent ahostsv6 ipv6.test 2>/dev/null | head -1)" ]; then
    list=/usr/share/dnsdiag/public-v4.txt
fi
# dnseval requires a hostname positional: default it when none (or only
# options) were given
if [ "$#" -eq 0 ] || case "$1" in -*) true;; *) false;; esac ]; then
    set -- "$@" example.com
fi
exec dnseval -f "$list" "$@"
