1echo There we go... 2 3# #-- padding.test --# 4# source the master var file when it's there 5[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 6# use .tpkg.var.test for in test variable passing 7[ -f .tpkg.var.test ] && source .tpkg.var.test 8 9PRE="../.." 10. ../common.sh 11if grep "define USE_DNSTAP 1" $PRE/config.h; then echo test enabled; else echo test skipped; exit 0; fi 12 13echo "> query www.example.com. A" 14dig @127.0.0.1 -p $UNBOUND_PORT www.example.com. | tee outfile 15echo "> check answer" 16if grep "10.20.30.40" outfile; then 17 echo "OK" 18else 19 echo "> cat logfiles" 20 cat tap.log 21 cat tap.errlog 22 cat fwd.log 23 cat unbound2.log 24 cat unbound.log 25 echo "Not OK" 26 exit 1 27fi 28 29echo "> wait for log to happen on timer" 30sleep 3 31echo "> check tap.log for dnstap info" 32# see if it logged the information in tap.log 33# wait for a moment for filesystem to catch up. 34if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi 35if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi 36if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi 37if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi 38if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi 39if grep "www.example.com" tap.log >/dev/null; then :; else sleep 10; fi 40if grep "www.example.com" tap.log; then echo "yes it is in tap.log"; 41else 42 echo "information not in tap.log" 43 echo "failed" 44 echo "> cat logfiles" 45 cat tap.log 46 cat tap.errlog 47 cat fwd.log 48 cat unbound.log 49 echo "Not OK" 50 exit 1 51fi 52 53echo "> query txt.example.com. TXT" 54dig @127.0.0.1 -p $UNBOUND_PORT txt.example.com. TXT | tee outfile 55echo "> check answer" 56if grep "Lorem ipsum" outfile; then 57 echo "OK" 58else 59 echo "> cat logfiles" 60 cat tap.log 61 cat tap.errlog 62 cat fwd.log 63 cat unbound2.log 64 cat unbound.log 65 echo "Not OK" 66 exit 1 67fi 68echo "> check tap.log for dnstap info" 69# see if it logged the information in tap.log 70# wait for a moment for filesystem to catch up. 71if grep "txt.example.com" tap.log >/dev/null; then :; else sleep 1; fi 72if grep "txt.example.com" tap.log >/dev/null; then :; else sleep 1; fi 73if grep "txt.example.com" tap.log >/dev/null; then :; else sleep 1; fi 74if grep "txt.example.com" tap.log >/dev/null; then :; else sleep 1; fi 75if grep "txt.example.com" tap.log >/dev/null; then :; else sleep 1; fi 76if grep "txt.example.com" tap.log >/dev/null; then :; else sleep 10; fi 77if grep "txt.example.com" tap.log; then echo "yes it is in tap.log"; 78else 79 echo "information not in tap.log" 80 echo "failed" 81 echo "> cat logfiles" 82 cat tap.log 83 cat tap.errlog 84 cat fwd.log 85 cat unbound.log 86 echo "Not OK" 87 exit 1 88fi 89 90echo "> flush cache entries." 91$PRE/unbound-control -c ub.conf flush_type www.example.com A 92$PRE/unbound-control -c ub.conf flush_type txt.example.com TXT 93echo "> disable padding of responses." 94$PRE/unbound-control -c ub2.conf set_option pad-responses: no 95echo "> query www.example.com. A" 96dig @127.0.0.1 -p $UNBOUND_PORT www.example.com. A | tee outfile 97echo "> query txt.example.com. TXT" 98dig @127.0.0.1 -p $UNBOUND_PORT txt.example.com. TXT | tee outfile 99echo "> flush cache entries." 100$PRE/unbound-control -c ub.conf flush_type www.example.com A 101$PRE/unbound-control -c ub.conf flush_type txt.example.com TXT 102echo "> enable padding of responses." 103$PRE/unbound-control -c ub2.conf set_option pad-responses: yes 104echo "> set pad responses block size to 64" 105$PRE/unbound-control -c ub2.conf set_option pad-responses-block-size: 64 106echo "> disable padding of queries." 107$PRE/unbound-control -c ub.conf set_option pad-queries: no 108echo "> query www.example.com. A" 109dig @127.0.0.1 -p $UNBOUND_PORT www.example.com. A | tee outfile 110echo "> query txt.example.com. TXT" 111dig @127.0.0.1 -p $UNBOUND_PORT txt.example.com. TXT | tee outfile 112echo "> flush cache entries." 113$PRE/unbound-control -c ub.conf flush_type www.example.com A 114$PRE/unbound-control -c ub.conf flush_type txt.example.com TXT 115echo "> enable padding of queries." 116$PRE/unbound-control -c ub.conf set_option pad-queries: yes 117echo "> set pad queries block size to 48" 118$PRE/unbound-control -c ub.conf set_option pad-queries-block-size: 48 119echo "> query www.example.com. A" 120dig @127.0.0.1 -p $UNBOUND_PORT www.example.com. A | tee outfile 121echo "> query txt.example.com. TXT" 122dig @127.0.0.1 -p $UNBOUND_PORT txt.example.com. TXT | tee outfile 123echo "> flush cache entries." 124$PRE/unbound-control -c ub.conf flush_type www.example.com A 125$PRE/unbound-control -c ub.conf flush_type txt.example.com TXT 126echo "> set pad responses block size to 512" 127$PRE/unbound-control -c ub2.conf set_option pad-responses-block-size: 512 128echo "> query www.example.com. A" 129dig @127.0.0.1 -p $UNBOUND_PORT www.example.com. A | tee outfile 130echo "> query fin.example.com. TXT" 131dig @127.0.0.1 -p $UNBOUND_PORT fin.example.com. TXT | tee outfile 132echo "> check tap.log for dnstap info" 133# see if it logged the information in tap.log 134# wait for a moment for filesystem to catch up. 135if grep "fini" tap.log >/dev/null; then :; else sleep 1; fi 136if grep "fini" tap.log >/dev/null; then :; else sleep 1; fi 137if grep "fini" tap.log >/dev/null; then :; else sleep 1; fi 138if grep "fini" tap.log >/dev/null; then :; else sleep 1; fi 139if grep "fini" tap.log >/dev/null; then :; else sleep 1; fi 140if grep "fini" tap.log >/dev/null; then :; else sleep 10; fi 141if grep "fini" tap.log; then echo "yes it is in tap.log"; 142else 143 echo "information not in tap.log" 144 echo "failed" 145 echo "> cat logfiles" 146 cat tap.log 147 cat tap.errlog 148 cat fwd.log 149 cat unbound.log 150 echo "Not OK" 151 exit 1 152fi 153 154grep '^;; MSG SIZE rcvd: ' tap.log > message.sizes 155 156if diff message.sizes padding.msgsizes 157then 158 echo "OK - Message sizes matched expected sizes" 159 exit 0 160else 161 echo "unexpected message sizes" 162 echo "failed" 163 echo "> cat logfiles" 164 cat tap.log 165 cat tap.errlog 166 cat fwd.log 167 cat unbound.log 168 echo "Not OK" 169 exit 1 170fi 171