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