diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-11-30 20:27:51 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-11-30 20:27:51 +0100 |
commit | 02fcbc17951c0a14357607ad133a8e842d6f463c (patch) | |
tree | fc8ef95957cef9bfb1ff6de94e667c32668e2d1c /src | |
parent | eb8770c02ac468d947c8286ebc7ebd877560431d (diff) | |
download | gnunet-02fcbc17951c0a14357607ad133a8e842d6f463c.tar.gz gnunet-02fcbc17951c0a14357607ad133a8e842d6f463c.zip |
add support for zkey TLDs in GNS2DNS records
Diffstat (limited to 'src')
-rw-r--r-- | src/gns/Makefile.am | 1 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 27 | ||||
-rwxr-xr-x | src/gns/test_gns_gns2dns_zkey_lookup.sh | 114 |
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 | ||
2 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT | ||
3 | |||
4 | LOCATION=$(which gnunet-config) | ||
5 | if [ -z $LOCATION ] | ||
6 | then | ||
7 | LOCATION="gnunet-config" | ||
8 | fi | ||
9 | $LOCATION --version 1> /dev/null | ||
10 | if test $? != 0 | ||
11 | then | ||
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
17 | # IP address of 'docs.gnunet.org' | ||
18 | TEST_IP_ALT2="147.87.255.218" | ||
19 | # IP address of 'www.gnunet.org' | ||
20 | TEST_IP="131.159.74.67" | ||
21 | # IPv6 address of 'gnunet.org' | ||
22 | TEST_IP6="2001:4ca0:2001:42:225:90ff:fe6b:d60" | ||
23 | # permissive DNS resolver we will use for the test | ||
24 | TEST_IP_GNS2DNS="8.8.8.8" | ||
25 | |||
26 | # main label used during resolution | ||
27 | TEST_RECORD_NAME="homepage" | ||
28 | |||
29 | if ! nslookup gnunet.org $TEST_IP_GNS2DNS > /dev/null 2>&1 | ||
30 | then | ||
31 | echo "Cannot reach DNS, skipping test" | ||
32 | exit 77 | ||
33 | fi | ||
34 | |||
35 | # helper record for pointing to the DNS resolver | ||
36 | TEST_RESOLVER_LABEL="resolver" | ||
37 | |||
38 | MY_EGO="myego" | ||
39 | # various names we will use for resolution | ||
40 | TEST_DOMAIN="www.${TEST_RECORD_NAME}.$MY_EGO" | ||
41 | TEST_DOMAIN_ALT="${TEST_RECORD_NAME}.$MY_EGO" | ||
42 | TEST_DOMAIN_ALT2="docs.${TEST_RECORD_NAME}.$MY_EGO" | ||
43 | |||
44 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 15" | ||
45 | |||
46 | |||
47 | gnunet-arm -s -c test_gns_lookup.conf | ||
48 | |||
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; } | ||
52 | |||
53 | |||
54 | |||
55 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
56 | MY_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 | ||
59 | TEST_RECORD_GNS2DNS="gnunet.org@${TEST_RESOLVER_LABEL}.${MY_EGO_PKEY}" | ||
60 | |||
61 | # set IP address for DNS resolver for resolving in gnunet.org domain | ||
62 | gnunet-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 | ||
64 | gnunet-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 | ||
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` | ||
70 | # lookup 'gnunet.org', IPv4 | ||
71 | RES_IP_ALT=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_ALT -t A -c test_gns_lookup.conf` | ||
72 | # lookup 'docs.gnunet.org', IPv4 | ||
73 | RES_IP_ALT2=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_ALT2 -t A -c test_gns_lookup.conf` | ||
74 | |||
75 | # clean up | ||
76 | gnunet-namestore -z $MY_EGO -d -n $TEST_RESOLVER_LABEL -t A -V $TEST_IP_GNS2DNS -e never -c test_gns_lookup.conf | ||
77 | gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS -e never -c test_gns_lookup.conf | ||
78 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
79 | gnunet-arm -e -c test_gns_lookup.conf | ||
80 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
81 | |||
82 | ret=0 | ||
83 | if echo "$RES_IP" | grep "$TEST_IP" > /dev/null | ||
84 | then | ||
85 | echo "PASS: Resolved $TEST_DOMAIN to $RES_IP." | ||
86 | else | ||
87 | echo "Failed to resolve to proper IP for $TEST_DOMAIN, got $RES_IP, wanted $TEST_IP." | ||
88 | ret=1 | ||
89 | fi | ||
90 | |||
91 | if [ "$RES_IP6" = "$TEST_IP6" ] | ||
92 | then | ||
93 | echo "PASS: Resolved $TEST_DOMAIN to $RES_IP6." | ||
94 | else | ||
95 | echo "Failed to resolve to proper IP for $TEST_DOMAIN, got $RES_IP6, wanted $TEST_IP6." | ||
96 | ret=1 | ||
97 | fi | ||
98 | |||
99 | if echo "$RES_IP_ALT" | grep "$TEST_IP" > /dev/null | ||
100 | then | ||
101 | echo "PASS: Resolved $TEST_DOMAIN_ALT to $RES_IP_ALT." | ||
102 | else | ||
103 | echo "Failed to resolve to proper IP for $TEST_DOMAIN_ALT, got $RES_IP_ALT, wanted $TEST_IP." | ||
104 | ret=1 | ||
105 | fi | ||
106 | |||
107 | if echo "$RES_IP_ALT2" | grep "$TEST_IP_ALT2" > /dev/null | ||
108 | then | ||
109 | echo "PASS: Resolved $TEST_DOMAIN_ALT2 to $RES_IP_ALT2." | ||
110 | else | ||
111 | echo "Failed to resolve to proper IP for $TEST_DOMAIN_ALT2, got $RES_IP_ALT2, wanted $TEST_IP_ALT2." | ||
112 | ret=1 | ||
113 | fi | ||
114 | exit $ret | ||