1# #-- padding.pre--# 2# source the master var file when it's there 3[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4# use .tpkg.var.test for in test variable passing 5[ -f .tpkg.var.test ] && source .tpkg.var.test 6 7PRE="../.." 8. ../common.sh 9if grep "define USE_DNSTAP 1" $PRE/config.h; then echo test enabled; else skip_test "test skipped"; fi 10 11get_random_port 5 12UNBOUND_PORT=$RND_PORT 13UPSTREAM_PORT=$(($RND_PORT + 1)) 14FWD_PORT=$(($RND_PORT + 2)) 15CONTROL_PORT=$(($RND_PORT + 3)) 16CONTROL_PORT2=$(($RND_PORT + 4)) 17echo "UNBOUND_PORT=$UNBOUND_PORT" >> .tpkg.var.test 18echo "UPSTREAM_PORT=$UPSTREAM_PORT" >> .tpkg.var.test 19echo "FWD_PORT=$FWD_PORT" >> .tpkg.var.test 20echo "CONTROL_PORT=$CONTROL_PORT" >> .tpkg.var.test 21echo "CONTROL_PORT2=$CONTROL_PORT2" >> .tpkg.var.test 22 23# start ldns-testnd 24get_ldns_testns 25$LDNS_TESTNS -p $FWD_PORT padding.testns >fwd.log 2>&1 & 26FWD_PID=$! 27echo "FWD_PID=$FWD_PID" >> .tpkg.var.test 28 29# start the dnstap log server 30# the -vvvv flag prints protocol and connection information from the 31# unbound-dnstap-socket server. 32# the -l flag prints the DNS info in the DNSTAP packet in multiline output. 33# stderr is the '-vvvv' server logs and errors. 34# stdout is the one-line packet logs (or with -l, multiline). 35$PRE/unbound-dnstap-socket -u dnstap.socket -l -vvvv 2>tap.errlog >tap.log & 36if test $? -ne 0; then 37 echo "could not start unbound-dnstap-socket server" 38 exit 1 39fi 40DNSTAP_SOCKET_PID=$! 41echo "DNSTAP_SOCKET_PID=$DNSTAP_SOCKET_PID" >> .tpkg.var.test 42# wait for the server to go up and make the dnstap.socket file 43wait_server_up "tap.errlog" "creating unix socket" 44if test ! -S dnstap.socket; then 45 echo "the dnstap.socket file does not exist!" 46fi 47 48# make config file 49sed -e 's/@PORT\@/'$UNBOUND_PORT'/' -e 's/@TOPORT\@/'$UPSTREAM_PORT'/' -e 's/@CONTROL_PORT\@/'$CONTROL_PORT'/' < padding.conf > ub.conf 50# start unbound in the background 51$PRE/unbound -d -c ub.conf >unbound.log 2>&1 & 52#$PRE/unbound -d -c ub.conf 2>&1 | tee unbound.log & 53UNBOUND_PID=$! 54echo "UNBOUND_PID=$UNBOUND_PID" >> .tpkg.var.test 55 56# make upstream config file 57sed -e 's/@PORT\@/'$UPSTREAM_PORT'/' -e 's/@TOPORT\@/'$FWD_PORT'/' -e 's/@CONTROL_PORT2\@/'$CONTROL_PORT2'/' < padding.conf2 > ub2.conf 58# start upstream unbound in the background 59$PRE/unbound -d -c ub2.conf >unbound2.log 2>&1 & 60#$PRE/unbound -d -c ub2.conf 2>&1 | tee unbound2.log & 61UPSTREAM_PID=$! 62echo "UPSTREAM_PID=$UPSTREAM_PID" >> .tpkg.var.test 63 64wait_ldns_testns_up fwd.log 65wait_unbound_up unbound.log 66wait_unbound_up unbound2.log 67 68cat .tpkg.var.test 69 70