]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - testdata/dnstap_reconnect.tdir/dnstap_reconnect.pre
Vendor import of Unbound 1.11.0.
[FreeBSD/FreeBSD.git] / testdata / dnstap_reconnect.tdir / dnstap_reconnect.pre
1 # #-- dnstap_reconnect.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
7 . ../common.sh
8
9 PRE="../.."
10 if grep "define USE_DNSTAP 1" $PRE/config.h; then echo test enabled; else echo test skipped; exit 0; fi
11
12 get_random_port 3
13 UNBOUND_PORT=$RND_PORT
14 FWD_PORT=$(($RND_PORT + 1))
15 CONTROL_PORT=$(($RND_PORT + 2))
16 echo "UNBOUND_PORT=$UNBOUND_PORT" >> .tpkg.var.test
17 echo "FWD_PORT=$FWD_PORT" >> .tpkg.var.test
18 echo "CONTROL_PORT=$CONTROL_PORT" >> .tpkg.var.test
19
20 # start forwarder
21 get_ldns_testns
22 $LDNS_TESTNS -p $FWD_PORT dnstap_reconnect.testns >fwd.log 2>&1 &
23 FWD_PID=$!
24 echo "FWD_PID=$FWD_PID" >> .tpkg.var.test
25
26 # start the dnstap log server
27 # the -vvvv flag prints protocol and connection information from the
28 # unbound-dnstap-socket server.
29 # the -l flag prints the DNS info in the DNSTAP packet in multiline output.
30 # stderr is the '-vvvv' server logs and errors.
31 # stdout is the one-line packet logs (or with -l, multiline).
32 $PRE/unbound-dnstap-socket -u dnstap.socket -l -vvvv 2>tap.errlog >tap.log &
33 if test $? -ne 0; then
34         echo "could not start unbound-dnstap-socket server"
35         exit 1
36 fi
37 DNSTAP_SOCKET_PID=$!
38 echo "DNSTAP_SOCKET_PID=$DNSTAP_SOCKET_PID" >> .tpkg.var.test
39 # wait for the server to go up and make the dnstap.socket file
40 wait_server_up "tap.errlog" "creating unix socket"
41 if test ! -S dnstap.socket; then 
42         echo "the dnstap.socket file does not exist!"
43 fi
44
45 # make config file
46 sed -e 's/@PORT\@/'$UNBOUND_PORT'/' -e 's/@TOPORT\@/'$FWD_PORT'/' -e 's/@CONTROL_PORT\@/'$CONTROL_PORT'/' < dnstap_reconnect.conf > ub.conf
47 # start unbound in the background
48 $PRE/unbound -d -c ub.conf >unbound.log 2>&1 &
49 UNBOUND_PID=$!
50 echo "UNBOUND_PID=$UNBOUND_PID" >> .tpkg.var.test
51
52 cat .tpkg.var.test
53 wait_ldns_testns_up fwd.log
54 wait_unbound_up unbound.log
55