3 # Check for required packages
4 if ! [ -x "$(command -v gnunet-namestore)" ]; then
5 echo 'bind/named is not installed' >&2
9 # Check if gnunet is running
10 gnunet-arm -I 2&>1 /dev/null
12 if [ 0 -ne $ret ]; then
13 echo 'gnunet services are not running'
18 # Check if identity exists and delets and readds it to get rid of entries in zone
19 gnunet-identity -d | grep randomtestingid 2>&1 /dev/null
22 if [ 0 -ne $ret ]; then
23 gnunet-identity -D randomtestingid
24 gnunet-identity -C randomtestingid
27 function minimize_ttl {
30 # parse each element and update ttl to smallest one
33 currttl=$(echo -n "$i" | cut -d' ' -f1)
34 if [ "$currttl" -lt "$ttl" ]
43 function get_record_type {
45 typ=$(echo -n "${arr[0]}" | cut -d' ' -f2)
51 val=$(echo -n "${arr[0]}" | cut -d' ' -f4-)
59 typ=$(get_record_type "${records[@]}")
60 for i in "${records[@]}"
65 gnunet-namestore -z randomtestingid -n "$label" "$recordstring" 2>&1 /dev/null
66 if [ 0 -ne $ret ]; then
67 echo "failed to add record $label: $recordstring"
69 gnunet-gns -t "$typ" -u foo2.randomtestingid 2>&1 /dev/null
70 if [ 0 -ne $ret ]; then
71 echo "record $label could not be found"
77 echo "Testing adding of single A record with -R"
78 testing test1 "${arr[@]}"
80 echo "Testing adding of multiple A records with -R"
81 declare -a arr=('1200 A n 127.0.0.1' '2400 A n 127.0.0.2')
82 testing test2 "${arr[@]}"
84 echo "Testing adding of multiple different records with -R"
85 declare -a arr=('1200 A n 127.0.0.1' '2400 AAAA n 2002::')
86 testing test3 "${arr[@]}"
88 echo "Testing adding of single GNS2DNS record with -R"
89 declare -a arr=('86400 GNS2DNS n gnu.org@127.0.0.1')
90 testing test4 "${arr[@]}"
92 echo "Testing adding of single GNS2DNS shadow record with -R"
93 declare -a arr=('86409 GNS2DNS s gnu.org@127.0.0.250')
94 testing test5 "${arr[@]}"
96 echo "Testing adding of multiple GNS2DNS record with -R"
97 declare -a arr=('1 GNS2DNS n gnunet.org@127.0.0.1' '3600 GNS2DNS s gnunet.org@127.0.0.2')
98 testing test6 "${arr[@]}"
99 val=$(gnunet-gns -t GNS2DNS -u test6.randomtestingid)
100 if [[ $val == *"127.0.0.1"* ]]; then
103 echo "Sleeping to let record expire"
105 val=$(gnunet-gns -t GNS2DNS -u test6.randomtestingid)
106 if [[ $val == *"127.0.0.2"* ]]; then
110 echo "Testing adding MX record with -R"
111 declare -a arr=('3600 MX n 10,mail')
112 testing test7 "${arr[@]}"
114 echo "Testing adding TXT record with -R"
115 declare -a arr=('3600 TXT n Pretty_Unicorns')
116 testing test8 "${arr[@]}"
118 echo "Testing adding TXT record with -R"
119 declare -a arr=('3600 SRV n _autodiscover_old._tcp.bfh.ch.')
120 testing test8 "${arr[@]}"
123 gnunet-identity -D randomtestingid