1# #-- ipset.test --# 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 8PRE="../.." 9 10# Make all the queries. They need to succeed by the way. 11echo "> dig www.example.net." 12dig @127.0.0.1 -p $UNBOUND_PORT www.example.net. | tee outfile 13echo "> check answer" 14if grep "1.1.1.1" outfile; then 15 echo "OK" 16else 17 echo "> cat logfiles" 18 cat fwd.log 19 cat unbound.log 20 echo "Not OK" 21 exit 1 22fi 23echo "> check ipset" 24if grep "ipset: add 1.1.1.1 to atotallymadeupnamefor4 for www.example.net." unbound.log; then 25 echo "ipset OK" 26else 27 echo "> cat logfiles" 28 cat fwd.log 29 cat unbound.log 30 echo "Not OK" 31 exit 1 32fi 33 34echo "> dig www.example.net. AAAA" 35dig @127.0.0.1 -p $UNBOUND_PORT www.example.net. AAAA | tee outfile 36echo "> check answer" 37if grep "::1" outfile; then 38 echo "OK" 39else 40 echo "> cat logfiles" 41 cat fwd.log 42 cat unbound.log 43 echo "Not OK" 44 exit 1 45fi 46echo "> check ipset" 47if grep "ipset: add ::1 to atotallymadeupnamefor6 for www.example.net." unbound.log; then 48 echo "ipset OK" 49else 50 echo "> cat logfiles" 51 cat fwd.log 52 cat unbound.log 53 echo "Not OK" 54 exit 1 55fi 56 57echo "> dig cname.example.net." 58dig @127.0.0.1 -p $UNBOUND_PORT cname.example.net. | tee outfile 59echo "> check answer" 60if grep "2.2.2.2" outfile; then 61 echo "OK" 62else 63 echo "> cat logfiles" 64 cat fwd.log 65 cat unbound.log 66 echo "Not OK" 67 exit 1 68fi 69echo "> check ipset" 70if grep "ipset: add 2.2.2.2 to atotallymadeupnamefor4 for target.example.net." unbound.log; then 71 echo "ipset OK" 72else 73 echo "> cat logfiles" 74 cat fwd.log 75 cat unbound.log 76 echo "Not OK" 77 exit 1 78fi 79 80echo "> dig cname.example.net. AAAA" 81dig @127.0.0.1 -p $UNBOUND_PORT cname.example.net. AAAA | tee outfile 82echo "> check answer" 83if grep "::2" outfile; then 84 echo "OK" 85else 86 echo "> cat logfiles" 87 cat fwd.log 88 cat unbound.log 89 echo "Not OK" 90 exit 1 91fi 92echo "> check ipset" 93if grep "ipset: add ::2 to atotallymadeupnamefor6 for target.example.net." unbound.log; then 94 echo "ipset OK" 95else 96 echo "> cat logfiles" 97 cat fwd.log 98 cat unbound.log 99 echo "Not OK" 100 exit 1 101fi 102 103echo "> dig outsidecname.example.net." 104dig @127.0.0.1 -p $UNBOUND_PORT outsidecname.example.net. | tee outfile 105echo "> check answer" 106if grep "3.3.3.3" outfile; then 107 echo "OK" 108else 109 echo "> cat logfiles" 110 cat fwd.log 111 cat unbound.log 112 echo "Not OK" 113 exit 1 114fi 115echo "> check ipset" 116if grep "ipset: add 3.3.3.3 to atotallymadeupnamefor4 for target.example.com." unbound.log; then 117 echo "ipset OK" 118else 119 echo "> cat logfiles" 120 cat fwd.log 121 cat unbound.log 122 echo "Not OK" 123 exit 1 124fi 125 126echo "> dig outsidecname.example.net. AAAA" 127dig @127.0.0.1 -p $UNBOUND_PORT outsidecname.example.net. AAAA | tee outfile 128echo "> check answer" 129if grep "::3" outfile; then 130 echo "OK" 131else 132 echo "> cat logfiles" 133 cat fwd.log 134 cat unbound.log 135 echo "Not OK" 136 exit 1 137fi 138echo "> check ipset" 139if grep "ipset: add ::3 to atotallymadeupnamefor6 for target.example.com." unbound.log; then 140 echo "ipset OK" 141else 142 echo "> cat logfiles" 143 cat fwd.log 144 cat unbound.log 145 echo "Not OK" 146 exit 1 147fi 148 149echo "> dig lookslikeexample.net. AAAA" 150dig @127.0.0.1 -p $UNBOUND_PORT lookslikeexample.net. AAAA | tee outfile 151echo "> check answer" 152if grep "::4" outfile; then 153 echo "OK" 154else 155 echo "> cat logfiles" 156 cat fwd.log 157 cat unbound.log 158 echo "Not OK" 159 exit 1 160fi 161echo "> check ipset" 162if grep "ipset: add ::4 to atotallymadeupnamefor6 for lookslikeexample.net." unbound.log; then 163 echo "> cat logfiles" 164 cat fwd.log 165 cat unbound.log 166 echo "Not OK" 167 exit 1 168else 169 echo "ipset OK" 170fi 171 172echo "> cat logfiles" 173cat tap.log 174cat tap.errlog 175cat fwd.log 176echo "> OK" 177exit 0 178