1# #-- ratelimit.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 9get_random_port 2 10UNBOUND_PORT=$RND_PORT 11STUB_PORT=$(($RND_PORT + 1)) 12CONTROL_PORT=$(($RND_PORT + 2)) 13echo "UNBOUND_PORT=$UNBOUND_PORT" >> .tpkg.var.test 14echo "STUB_PORT=$STUB_PORT" >> .tpkg.var.test 15echo "CONTROL_PORT=$CONTROL_PORT" >> .tpkg.var.test 16 17# start ldns-testns 18get_ldns_testns 19$LDNS_TESTNS -v -p $STUB_PORT ratelimit.testns >stub.log 2>&1 & 20STUB_PID=$! 21echo "STUB_PID=$STUB_PID" >> .tpkg.var.test 22 23# make config file 24sed -e 's/@PORT\@/'$UNBOUND_PORT'/' -e 's/@TOPORT\@/'$STUB_PORT'/' -e 's/@CONTROL_PORT\@/'$CONTROL_PORT'/' < ratelimit.conf > ub.conf 25# start unbound in the background 26$PRE/unbound -d -c ub.conf >unbound.log 2>&1 & 27UNBOUND_PID=$! 28echo "UNBOUND_PID=$UNBOUND_PID" >> .tpkg.var.test 29 30wait_ldns_testns_up stub.log 31wait_unbound_up unbound.log 32 33cat .tpkg.var.test 34