#!/usr/bin/env bash

# shellcheck shell=bash

### UNUSED FUNCTION

# ``````````````````````````````````````````````````````````````````````````````
# Function name: DomainResolve()
#
# Description:
#   Resolve domain name.
#
# Usage:
#   DomainResolve domain
#
# Examples:
#   DomainResolve example.com
#

function DomainResolve() {

  # shellcheck disable=SC2034
  local _FUNCTION_ID="DomainResolve"
  local _STATE=0

  local _host="$1"

  # shellcheck disable=SC2154
  # _host_ip=$(timeout "$_timeout" dig "$_host" | \
  #            awk '/^;; ANSWER SECTION:$/ { getline ; print $5 }')

  _host_ip=$($_curl_base_remote -ks -m "$_timeout" "https://dns.google.com/resolve?name=${_host}&type=A" | \
  jq '.Answer[0].data' | tr -d "\"")

  if [[ -z "$_host_ip" ]] || [[ "$_host_ip" == "null" ]] ; then

    # shellcheck disable=SC2034
    _STATE="1"

    _logger "stop" \
      "${_FUNCTION_ID}()" \
      "not properly resolve $_host"

  else

    # shellcheck disable=SC2034
    _STATE="0"

    _logger "info" \
      "${_FUNCTION_ID}()" \
      "properly resolve $_host to $_host_ip"

  fi

}
