[DNSAPI/BUG] Fixes naive top domain detection.

In order to properly detect the top domain, lets query the NS through
the SOA record and get the top domain being validated.

This fixes incorrect top domain detection under TLDs such as 'com.br',
'co.uk', etc.

This solution could be used for other DNS APIs as well.
This commit is contained in:
Felipe Wilhelms Damasio 2019-08-09 19:53:23 -03:00
parent c7849a43e1
commit 17ecff7a3b

View File

@ -72,19 +72,17 @@ EOF
# _domain=domain.com # _domain=domain.com
_get_root() { _get_root() {
domain=$1 domain=$1
i="$(echo "$fulldomain" | tr '.' ' ' | wc -w)"
i=$(_math "$i" - 1)
while true; do d=$(dig soa "$domain" | grep -v ^\; | grep SOA | awk '{print $1}')
h=$(printf "%s" "$domain" | cut -d . -f "$i"-100) if [ -z "${d}" ]; then
if [ -z "$h" ]; then _debug "$domain not found"
return 1 return 1
fi fi
_domain="$h"
return 0 d=${d%?} # remove last '.'
done
_debug "$domain not found" _domain="$d"
return 1 return 0
} }
_checkKey() { _checkKey() {