Browse Source

Enhanced UltraDNS zone retrieval for accounts with over 100 zones:

1. Modified API call to fetch up to 1000 zones per request.
2. Implemented looping mechanism for thorough search when the correct zone is not initially found.
3. Integrated query filtering to narrow down results to relevant zones only.
pull/4923/head
Nicolai Marck Ødum 1 year ago
committed by GitHub
parent
commit
9a02d29a21
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      dnsapi/dns_ultra.sh

22
dnsapi/dns_ultra.sh

@ -113,16 +113,20 @@ _get_root() {
while true; do while true; do
h=$(printf "%s" "$domain" | cut -d . -f $i-100) h=$(printf "%s" "$domain" | cut -d . -f $i-100)
_debug h "$h" _debug h "$h"
_debug response "$response"
if [ -z "$h" ]; then if [ -z "$h" ]; then
#not valid #not valid
return 1 return 1
fi fi
if ! _ultra_rest GET "zones"; then
while true; do
if ! _ultra_rest GET "zones?limit=1000&q=name:${h}${_cursor_next}"; then
return 1 return 1
fi fi
if _contains "${response}" "${h}." >/dev/null; then
_domain_id=$(echo "$response" | _egrep_o "${h}" | head -1)
_debug response "$response"
_zones=$(echo "$response" | _egrep_o '"zones":\[.*\]')
_debug _zones "${_zones}"
if _contains "${_zones}" "${h}." >/dev/null; then
_domain_id=$(echo "$_zones" | _egrep_o "${h}" | head -1)
_debug "Domainid: $_domain_id"
if [ "$_domain_id" ]; then if [ "$_domain_id" ]; then
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p) _sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
_domain="${h}" _domain="${h}"
@ -132,6 +136,16 @@ _get_root() {
fi fi
return 1 return 1
fi fi
_cursor_info=$(echo "$response" | _egrep_o "\"cursorInfo\":\s*{[^}]*}")
_debug _cursor_info "${_cursor_info}"
if _contains "${_cursor_info}" "\"next\""; then
_next_token=$(echo "${_cursor_info}" | cut -d':' -f3 | cut -d',' -f1 | tr -d '"' )
_debug _next_token "${_next_token}"
_cursor_next="&cursor=${_next_token}"
else
break
fi
done
p=$i p=$i
i=$(_math "$i" + 1) i=$(_math "$i" + 1)
done done

Loading…
Cancel
Save