# #-- fwd_zero.test --#
# source the master var file when it's there
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
# use .tpkg.var.test for in test variable passing
[ -f .tpkg.var.test ] && source .tpkg.var.test

PRE="../.."

OPT="-i"
if nc -h 2>&1 | grep -E -- "-w (timeout|secs)" >/dev/null; then
        OPT="-w"
fi

# send query with qname but not qtype , qclass (malformed query)
echo "> nc www.example.com. (malformed)"
echo "b4380100000100000000000003777777076578616d706c6503636f6d00" | xxd -r -p | nc -un $OPT 2 127.0.0.1 $UNBOUND_PORT 2>/dev/null | xxd | tee outfile

# now test that server is still up
echo "> dig www.example.com."
dig @localhost -p $UNBOUND_PORT www.example.com. | tee outfile
echo "> cat logfiles"
cat fwd.log 
cat unbound.log
echo "> check answer"
if grep "10.20.30.40" outfile; then
	echo "OK"
else
	echo "Not OK"
	exit 1
fi

exit 0
