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