aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gns/Makefile.am1
-rw-r--r--src/gns/gnunet-service-gns_resolver.c27
-rwxr-xr-xsrc/gns/test_gns_gns2dns_zkey_lookup.sh114
3 files changed, 130 insertions, 12 deletions
diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am
index 764590589..9f0e0bbb6 100644
--- a/src/gns/Makefile.am
+++ b/src/gns/Makefile.am
@@ -282,6 +282,7 @@ check_SCRIPTS = \
282 test_gns_caa_lookup.sh\ 282 test_gns_caa_lookup.sh\
283 test_gns_mx_lookup.sh \ 283 test_gns_mx_lookup.sh \
284 test_gns_gns2dns_lookup.sh \ 284 test_gns_gns2dns_lookup.sh \
285 test_gns_gns2dns_zkey_lookup.sh \
285 test_gns_gns2dns_cname_lookup.sh \ 286 test_gns_gns2dns_cname_lookup.sh \
286 test_gns_dht_lookup.sh\ 287 test_gns_dht_lookup.sh\
287 test_gns_delegated_lookup.sh \ 288 test_gns_delegated_lookup.sh \
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 9792aff58..8639a239b 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -1766,8 +1766,8 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh,
1766 continue; 1766 continue;
1767 } 1767 }
1768 tld = GNS_get_tld (ip); 1768 tld = GNS_get_tld (ip);
1769 if (0 != strcmp (tld, 1769 if ((0 != strcmp (tld, "+")) &&
1770 "+")) 1770 (GNUNET_OK != GNUNET_GNSRECORD_zkey_to_pkey (tld, &zone)))
1771 { 1771 {
1772 /* 'ip' is a DNS name */ 1772 /* 'ip' is a DNS name */
1773 gp = GNUNET_new (struct Gns2DnsPending); 1773 gp = GNUNET_new (struct Gns2DnsPending);
@@ -1790,16 +1790,19 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh,
1790 ac->authority_info.dns_authority.gp_tail, 1790 ac->authority_info.dns_authority.gp_tail,
1791 gp); 1791 gp);
1792 gp->rh = GNUNET_new (struct GNS_ResolverHandle); 1792 gp->rh = GNUNET_new (struct GNS_ResolverHandle);
1793 ip = translate_dot_plus (rh, 1793 if (0 == strcmp (tld, "+"))
1794 ip);
1795 tld = GNS_get_tld (ip);
1796 if (GNUNET_OK !=
1797 GNUNET_GNSRECORD_zkey_to_pkey (tld,
1798 &zone))
1799 { 1794 {
1800 GNUNET_break_op (0); 1795 ip = translate_dot_plus (rh,
1801 GNUNET_free (ip); 1796 ip);
1802 continue; 1797 tld = GNS_get_tld (ip);
1798 if (GNUNET_OK !=
1799 GNUNET_GNSRECORD_zkey_to_pkey (tld,
1800 &zone))
1801 {
1802 GNUNET_break_op (0);
1803 GNUNET_free (ip);
1804 continue;
1805 }
1803 } 1806 }
1804 gp->rh->authority_zone = zone; 1807 gp->rh->authority_zone = zone;
1805 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1808 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1845,7 +1848,7 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh,
1845 if (IDNA_SUCCESS != idna_to_ascii_8z (tmp, &ac->label, IDNA_ALLOW_UNASSIGNED)) 1848 if (IDNA_SUCCESS != idna_to_ascii_8z (tmp, &ac->label, IDNA_ALLOW_UNASSIGNED))
1846 { 1849 {
1847 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1850 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1848 _("Name `%s' cannot be converted to IDNA."), tmp); 1851 _ ("Name `%s' cannot be converted to IDNA."), tmp);
1849 return GNUNET_SYSERR; 1852 return GNUNET_SYSERR;
1850 } 1853 }
1851 GNUNET_free (tmp); 1854 GNUNET_free (tmp);
diff --git a/src/gns/test_gns_gns2dns_zkey_lookup.sh b/src/gns/test_gns_gns2dns_zkey_lookup.sh
new file mode 100755
index 000000000..5c2cddd3c
--- /dev/null
+++ b/src/gns/test_gns_gns2dns_zkey_lookup.sh
@@ -0,0 +1,114 @@
1#!/bin/sh
2trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT
3
4LOCATION=$(which gnunet-config)
5if [ -z $LOCATION ]
6then
7 LOCATION="gnunet-config"
8fi
9$LOCATION --version 1> /dev/null
10if test $? != 0
11then
12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
13 exit 77
14fi
15
16rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
17# IP address of 'docs.gnunet.org'
18TEST_IP_ALT2="147.87.255.218"
19# IP address of 'www.gnunet.org'
20TEST_IP="131.159.74.67"
21# IPv6 address of 'gnunet.org'
22TEST_IP6="2001:4ca0:2001:42:225:90ff:fe6b:d60"
23# permissive DNS resolver we will use for the test
24TEST_IP_GNS2DNS="8.8.8.8"
25
26# main label used during resolution
27TEST_RECORD_NAME="homepage"
28
29if ! nslookup gnunet.org $TEST_IP_GNS2DNS > /dev/null 2>&1
30then
31 echo "Cannot reach DNS, skipping test"
32 exit 77
33fi
34
35# helper record for pointing to the DNS resolver
36TEST_RESOLVER_LABEL="resolver"
37
38MY_EGO="myego"
39# various names we will use for resolution
40TEST_DOMAIN="www.${TEST_RECORD_NAME}.$MY_EGO"
41TEST_DOMAIN_ALT="${TEST_RECORD_NAME}.$MY_EGO"
42TEST_DOMAIN_ALT2="docs.${TEST_RECORD_NAME}.$MY_EGO"
43
44which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 15"
45
46
47gnunet-arm -s -c test_gns_lookup.conf
48
49OUT=`$DO_TIMEOUT gnunet-resolver -c test_gns_lookup.conf gnunet.org`
50echo $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; }
51echo $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; }
52
53
54
55gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
56MY_EGO_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep ${MY_EGO} | awk '{print $3}')
57# GNS2DNS record value: delegate to DNS domain 'gnunet.org'
58# using the TEST_RESOLVER_LABEL DNS server for resolution
59TEST_RECORD_GNS2DNS="gnunet.org@${TEST_RESOLVER_LABEL}.${MY_EGO_PKEY}"
60
61# set IP address for DNS resolver for resolving in gnunet.org domain
62gnunet-namestore -p -z $MY_EGO -a -n $TEST_RESOLVER_LABEL -t A -V $TEST_IP_GNS2DNS -e never -c test_gns_lookup.conf
63# map '$TEST_RECORD_NAME.$MY_EGO' to 'gnunet.org' in DNS
64gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS -e never -c test_gns_lookup.conf
65
66# lookup 'www.gnunet.org', IPv4
67RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t A -c test_gns_lookup.conf`
68# lookup 'www.gnunet.org', IPv6
69RES_IP6=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t AAAA -c test_gns_lookup.conf`
70# lookup 'gnunet.org', IPv4
71RES_IP_ALT=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_ALT -t A -c test_gns_lookup.conf`
72# lookup 'docs.gnunet.org', IPv4
73RES_IP_ALT2=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_ALT2 -t A -c test_gns_lookup.conf`
74
75# clean up
76gnunet-namestore -z $MY_EGO -d -n $TEST_RESOLVER_LABEL -t A -V $TEST_IP_GNS2DNS -e never -c test_gns_lookup.conf
77gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS -e never -c test_gns_lookup.conf
78gnunet-identity -D $MY_EGO -c test_gns_lookup.conf
79gnunet-arm -e -c test_gns_lookup.conf
80rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
81
82ret=0
83if echo "$RES_IP" | grep "$TEST_IP" > /dev/null
84then
85 echo "PASS: Resolved $TEST_DOMAIN to $RES_IP."
86else
87 echo "Failed to resolve to proper IP for $TEST_DOMAIN, got $RES_IP, wanted $TEST_IP."
88 ret=1
89fi
90
91if [ "$RES_IP6" = "$TEST_IP6" ]
92then
93 echo "PASS: Resolved $TEST_DOMAIN to $RES_IP6."
94else
95 echo "Failed to resolve to proper IP for $TEST_DOMAIN, got $RES_IP6, wanted $TEST_IP6."
96 ret=1
97fi
98
99if echo "$RES_IP_ALT" | grep "$TEST_IP" > /dev/null
100then
101 echo "PASS: Resolved $TEST_DOMAIN_ALT to $RES_IP_ALT."
102else
103 echo "Failed to resolve to proper IP for $TEST_DOMAIN_ALT, got $RES_IP_ALT, wanted $TEST_IP."
104 ret=1
105fi
106
107if echo "$RES_IP_ALT2" | grep "$TEST_IP_ALT2" > /dev/null
108then
109 echo "PASS: Resolved $TEST_DOMAIN_ALT2 to $RES_IP_ALT2."
110else
111 echo "Failed to resolve to proper IP for $TEST_DOMAIN_ALT2, got $RES_IP_ALT2, wanted $TEST_IP_ALT2."
112 ret=1
113fi
114exit $ret