summaryrefslogblamecommitdiffstats
path: root/modules/net.inc
blob: e7c9dfc91671d7e909736f18fbc7b88aa2d0b1df (plain) (tree)
1
2
3
4
5
6
7
8
9








                                                                                                                                                                                                            
#!/bin/ash

net_resolve_v4() {
	if command -v dig &> /dev/null; then
		printf "%s " $( busybox timeout -t 2 dig +short "$1" | grep -E '^[0-9.]+$' )
	elif command -v nslookup &> /dev/null; then
		printf "%s " $( LC_ALL=C busybox timeout -t 2 nslookup "$1" 2>/dev/null | grep -A 4 '^Name:' | grep -E '^Address\s*[0-9]*: ' | awk -F': ' '{print $2}' | grep -oE '^[0-9]+\.[0-9.]+(\s|$)' )
	fi
}