96
96
# Returns : Resolved host's IP in "$host_ip"
97
97
traffic_accounting_get_host()
99
host_ip="" # Reset result
102
103
if is_numeric_ip "$host"; then
108
printf "${INDENT}Resolving \"$host\" -> "
110
# First try to get host from host-cache
111
if [ "$TRAFFIC_ACCOUNTING_USE_HOST_CACHE" != "0" ] && \
112
[ -n "$TA_HOST_CACHE" ] && [ -e "$TA_HOST_CACHE" ]; then
114
local find_host=`grep "^$host " -m1 "$TA_HOST_CACHE"`
115
if [ -n "$find_host" ]; then
116
host_ip=`echo "$find_host" |cut -s -f2 -d' '`
118
echo "$host_ip (cached)"
123
# Perform normal lookup
124
DNS_FAST_FAIL_ONCE="$DYNDNS_DNS_FAST_FAIL"
125
host_ip=`gethostbyname "$host"`
128
if [ -z "$host_ip" -o $retval -ne 0 ]; then
129
printf "\033[40m\033[1;31mFAILED!\n\033[0m"
130
echo "** ERROR($retval): Unresolvable host \"$host\"! **" >&2
105
printf "${INDENT}Resolving \"$host\" -> "
106
if [ "$TRAFFIC_ACCOUNTING_USE_HOST_CACHE" != "0" ] && \
107
[ -n "$TA_HOST_CACHE" ] && [ -e "$TA_HOST_CACHE" ]; then
108
host_ip=`grep "^$host " -m1 "$TA_HOST_CACHE" |cut -s -f2 -d' '`
110
if [ -n "$host_ip" ]; then
111
echo "$host_ip (cached)"
115
if [ -z "$host_ip" ]; then
116
# Perform normal lookup
117
host_ip=`gethostbyname "$host"`
118
if [ -n "$host_ip" ]; then
121
printf "\033[40m\033[1;31mFAILED!\n\033[0m"
170
traffic_accounting_get_host "$host"
172
# If it fails use old IP
173
if [ -z "$host_ip" ]; then
180
# Get host_ip, if it fails, skip rule
181
if ! traffic_accounting_get_host "$host"; then
182
echo "** WARNING: Skipping rule for \"$host\"! **" >&2