#!/bin/sh
# This is a legacy script that uses "dig" or "drill" to do DNS lookups via TCP.

# DNS server used to resolve names
test -z "$DNS_SERVER" && DNS_SERVER=8.8.8.8


if [ $# = 0 ] ; then
	echo "	usage:"
	echo "		proxyresolv <hostname> "
	exit
fi


test -z $LD_PRELOAD && export LD_PRELOAD=libproxychains4.so

if type dig 1>/dev/null 2>&1 ; then
dig       $1 @$DNS_SERVER +tcp | awk '/A.?[0-9]+\.[0-9]+\.[0-9]/{print $5;}'
elif type drill 1>/dev/null 2>&1 ; then
drill -t4 $1 @$DNS_SERVER      | awk '/A.+[0-9]+\.[0-9]+\.[0-9]/{print $5;}'
else
echo "error: neither dig nor drill found" >&2
fi
