2 # This file is in the public domain.
3 trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT
5 LOCATION=$(which gnunet-config)
8 LOCATION="gnunet-config"
10 $LOCATION --version 1> /dev/null
13 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
17 rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
18 # IP address of 'www.gnunet.org'
19 TEST_IP="131.159.74.67"
20 # IPv6 address of 'gnunet.org'
21 TEST_IP6="2001:4ca0:2001:42:225:90ff:fe6b:d60"
23 # main label used during resolution
24 TEST_RECORD_NAME="homepage"
28 if ! nslookup gnunet.org a.$XNS > /dev/null 2>&1
30 echo "Cannot reach DNS, skipping test"
34 # helper record for pointing to the DNS resolver
35 TEST_RESOLVER_LABEL="resolver"
36 # GNS2DNS record value: delegate to DNS domain 'gnunet.org'
37 # using the TEST_RESOLVER_LABEL DNS server for resolution
38 TEST_RECORD_GNS2DNS1="gnunet.org@a.$XNS"
39 TEST_RECORD_GNS2DNS2="gnunet.org@b.$XNS"
40 TEST_RECORD_GNS2DNS3="gnunet.org@c.$XNS"
43 # various names we will use for resolution
44 TEST_DOMAIN="www.${TEST_RECORD_NAME}.$MY_EGO"
46 which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 15"
48 gnunet-arm -s -c test_gns_lookup.conf
49 OUT=`$DO_TIMEOUT gnunet-resolver -c test_gns_lookup.conf gnunet.org`
50 echo $OUT | grep $TEST_IP - > /dev/null || { gnunet-arm -e -c test_gns_lookup.conf ; echo "IPv4 for gnunet.org not found ($OUT), skipping test"; exit 77; }
51 echo $OUT | grep $TEST_IP6 - > /dev/null || { gnunet-arm -e -c test_gns_lookup.conf ; echo "IPv6 for gnunet.org not found ($OUT), skipping test"; exit 77; }
54 gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
56 # set IP address for DNS resolver for resolving in gnunet.org domain
57 # map '$TEST_RECORD_NAME.$MY_EGO' to 'gnunet.org' in DNS
58 gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS1 -e never -c test_gns_lookup.conf
59 gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS2 -e never -c test_gns_lookup.conf
60 gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS3 -e never -c test_gns_lookup.conf
66 # lookup 'www.gnunet.org', IPv4
67 RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t A -c test_gns_lookup.conf`
68 # lookup 'www.gnunet.org', IPv6
69 RES_IP6=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t AAAA -c test_gns_lookup.conf`
72 gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS1 -e never -c test_gns_lookup.conf
73 gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS2 -e never -c test_gns_lookup.conf
74 gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS3 -e never -c test_gns_lookup.conf
75 gnunet-identity -D $MY_EGO -c test_gns_lookup.conf
76 gnunet-arm -e -c test_gns_lookup.conf
77 rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
80 if [ "$RES_IP" = "$TEST_IP" ]
82 echo "PASS: Resolved $TEST_DOMAIN to $RES_IP."
84 echo "Failed to resolve to proper IP for $TEST_DOMAIN, got $RES_IP, wanted $TEST_IP."
88 if [ "$RES_IP6" = "$TEST_IP6" ]
90 echo "PASS: Resolved $TEST_DOMAIN to $RES_IP6."
92 echo "Failed to resolve to proper IP for $TEST_DOMAIN, got $RES_IP6, wanted $TEST_IP6."