diff options
-rw-r--r-- | src/gns/Makefile.am | 4 | ||||
-rwxr-xr-x | src/gns/test_gns_cname_lookup.sh | 4 | ||||
-rwxr-xr-x | src/gns/test_gns_gns2dns_cname_lookup.sh | 2 | ||||
-rw-r--r-- | src/gns/test_gns_lookup.conf | 2 | ||||
-rwxr-xr-x | src/gns/test_plugin_rest_gns.sh | 67 | ||||
-rw-r--r-- | src/util/gnunet-service-resolver.c | 10 |
6 files changed, 59 insertions, 30 deletions
diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am index 4a152a6df..6cc09c098 100644 --- a/src/gns/Makefile.am +++ b/src/gns/Makefile.am | |||
@@ -268,6 +268,10 @@ check_SCRIPTS += \ | |||
268 | test_proxy.sh | 268 | test_proxy.sh |
269 | endif | 269 | endif |
270 | endif | 270 | endif |
271 | if HAVE_JSON | ||
272 | check_SCRIPTS += \ | ||
273 | test_plugin_rest_gns.sh | ||
274 | endif | ||
271 | endif | 275 | endif |
272 | 276 | ||
273 | 277 | ||
diff --git a/src/gns/test_gns_cname_lookup.sh b/src/gns/test_gns_cname_lookup.sh index d168e4acb..f71346127 100755 --- a/src/gns/test_gns_cname_lookup.sh +++ b/src/gns/test_gns_cname_lookup.sh | |||
@@ -45,7 +45,7 @@ gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME_PLUS -t CNAME -V $TEST_RE | |||
45 | gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_CNAME_SERVER -t A -V $TEST_IP_PLUS -e never -c test_gns_lookup.conf | 45 | gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_CNAME_SERVER -t A -V $TEST_IP_PLUS -e never -c test_gns_lookup.conf |
46 | RES_CNAME=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t A -c test_gns_lookup.conf` | 46 | RES_CNAME=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t A -c test_gns_lookup.conf` |
47 | RES_CNAME_RAW=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t CNAME -c test_gns_lookup.conf` | 47 | RES_CNAME_RAW=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t CNAME -c test_gns_lookup.conf` |
48 | RES_CNAME_DNS=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_DNS -t A -c test_gns_lookup.conf` | 48 | RES_CNAME_DNS=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_DNS -t A -c test_gns_lookup.conf | grep $TEST_IP_DNS` |
49 | echo NOW | 49 | echo NOW |
50 | gnunet-gns --raw -u $TEST_DOMAIN_DNS -t A -c test_gns_lookup.conf | 50 | gnunet-gns --raw -u $TEST_DOMAIN_DNS -t A -c test_gns_lookup.conf |
51 | echo WON | 51 | echo WON |
@@ -76,7 +76,7 @@ else | |||
76 | exit 1 | 76 | exit 1 |
77 | fi | 77 | fi |
78 | 78 | ||
79 | if [ "$RES_CNAME_DNS" = "$TEST_IP_DNS" ] | 79 | if echo "$RES_CNAME_DNS" | grep "$TEST_IP_DNS" > /dev/null |
80 | then | 80 | then |
81 | echo "PASS: IP resolution from DNS" | 81 | echo "PASS: IP resolution from DNS" |
82 | exit 0 | 82 | exit 0 |
diff --git a/src/gns/test_gns_gns2dns_cname_lookup.sh b/src/gns/test_gns_gns2dns_cname_lookup.sh index 87d684515..71e48a2bd 100755 --- a/src/gns/test_gns_gns2dns_cname_lookup.sh +++ b/src/gns/test_gns_gns2dns_cname_lookup.sh | |||
@@ -85,7 +85,7 @@ else | |||
85 | ret=1 | 85 | ret=1 |
86 | fi | 86 | fi |
87 | 87 | ||
88 | if [ "$RES_IP6" = "$TEST_IP6" ] | 88 | if echo "$RES_IP6" | grep "$TEST_IP6" > /dev/null |
89 | then | 89 | then |
90 | echo "PASS: Resolved $TEST_DOMAIN to $RES_IP6." | 90 | echo "PASS: Resolved $TEST_DOMAIN to $RES_IP6." |
91 | else | 91 | else |
diff --git a/src/gns/test_gns_lookup.conf b/src/gns/test_gns_lookup.conf index 2b874f80d..130d190e7 100644 --- a/src/gns/test_gns_lookup.conf +++ b/src/gns/test_gns_lookup.conf | |||
@@ -1,7 +1,7 @@ | |||
1 | @INLINE@ test_gns_defaults.conf | 1 | @INLINE@ test_gns_defaults.conf |
2 | 2 | ||
3 | [namecache] | 3 | [namecache] |
4 | DISABLE = YES | 4 | DISABLE = NO |
5 | 5 | ||
6 | [PATHS] | 6 | [PATHS] |
7 | GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-gns-peer-1/ | 7 | GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-gns-peer-1/ |
diff --git a/src/gns/test_plugin_rest_gns.sh b/src/gns/test_plugin_rest_gns.sh index ec495a04b..09f155e01 100755 --- a/src/gns/test_plugin_rest_gns.sh +++ b/src/gns/test_plugin_rest_gns.sh | |||
@@ -1,7 +1,20 @@ | |||
1 | #!/usr/bin/bash | 1 | #!/bin/sh |
2 | 2 | # This file is in the public domain. | |
3 | #First, start gnunet-arm and the rest-service. | 3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT |
4 | #Exit 0 means success, exit 1 means failed test | 4 | |
5 | LOCATION=$(which gnunet-config) | ||
6 | if [ -z $LOCATION ] | ||
7 | then | ||
8 | LOCATION="gnunet-config" | ||
9 | fi | ||
10 | $LOCATION --version 1> /dev/null | ||
11 | if test $? != 0 | ||
12 | then | ||
13 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
14 | exit 77 | ||
15 | fi | ||
16 | |||
17 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
5 | 18 | ||
6 | gns_link="http://localhost:7776/gns" | 19 | gns_link="http://localhost:7776/gns" |
7 | wrong_link="http://localhost:7776/gnsandmore" | 20 | wrong_link="http://localhost:7776/gnsandmore" |
@@ -9,42 +22,50 @@ wrong_link="http://localhost:7776/gnsandmore" | |||
9 | curl_get () { | 22 | curl_get () { |
10 | #$1 is link | 23 | #$1 is link |
11 | #$2 is grep | 24 | #$2 is grep |
12 | cache="$(curl -v "$1" 2>&1 | grep "$2")" | 25 | cache="$(gnurl -v "$1" 2>&1 | grep "$2")" |
13 | #echo $cache | 26 | echo "$cache" |
14 | if [ "" == "$cache" ] | 27 | if [ "" == "$cache" ] |
15 | then | 28 | then |
29 | gnunet-identity -D "$TEST_TLD" -c test_gns_lookup.conf > /dev/null 2>&1 | ||
30 | gnunet-arm -e -c test_gns_lookup.conf | ||
16 | exit 1 | 31 | exit 1 |
17 | fi | 32 | fi |
18 | } | 33 | } |
34 | TEST_TLD="testtld" | ||
19 | 35 | ||
20 | gnunet-identity -D "test_plugin_rest_gns" > /dev/null 2>&1 | 36 | gnunet-arm -s -c test_gns_lookup.conf |
37 | gnunet-arm -I | ||
38 | gnunet-identity -D "$TEST_TLD" -c test_gns_lookup.conf > /dev/null 2>&1 | ||
21 | 39 | ||
22 | curl_get "$gns_link/www.test_plugin_rest_gns" "error" | 40 | curl_get "$gns_link/www.$TEST_TLD" "error" |
23 | 41 | ||
24 | gnunet-identity -C "test_plugin_rest_gns" | 42 | gnunet-identity -C "$TEST_TLD" -c test_gns_lookup.conf |
43 | sleep 0.5 | ||
44 | curl_get "$gns_link/www.$TEST_TLD" "\[\]" | ||
25 | 45 | ||
26 | curl_get "$gns_link/www.test_plugin_rest_gns" "\[\]" | 46 | gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1.1.1.1 -t A -c test_gns_lookup.conf |
27 | 47 | ||
28 | gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1.1.1.1 -t A | 48 | curl_get "$gns_link/www.$TEST_TLD" "1.1.1.1" |
29 | 49 | ||
30 | curl_get "$gns_link/www.test_plugin_rest_gns" "1.1.1.1" | 50 | gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1::1 -t AAAA -c test_gns_lookup.conf |
31 | 51 | ||
32 | gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1::1 -t AAAA | 52 | curl_get "$gns_link/www.$TEST_TLD" "1::1.*1.1.1.1" |
33 | 53 | ||
34 | curl_get "$gns_link/www.test_plugin_rest_gns" "1::1.*1.1.1.1" | 54 | gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1.1.1.2 -t A -c test_gns_lookup.conf |
35 | 55 | ||
36 | gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1.1.1.2 -t A | 56 | curl_get "$gns_link/www.$TEST_TLD" "1.1.1.2.*1::1.*1.1.1.1" |
57 | curl_get "$gns_link/www.$TEST_TLD?record_type=A" "1.1.1.2.*1.1.1.1" | ||
58 | curl_get "$gns_link/www.$TEST_TLD?record_type=AAAA" "1::1" | ||
59 | curl_get "$gns_link/www.$TEST_TLD?record_type=WRONG_TYPE" "1.1.1.2.*1::1.*1.1.1.1" | ||
37 | 60 | ||
38 | curl_get "$gns_link/www.test_plugin_rest_gns" "1.1.1.2.*1::1.*1.1.1.1" | 61 | gnunet-namestore -z "$TEST_TLD" -p -a -n www1 -e 1d -V 1.1.1.1 -t A -c test_gns_lookup.conf |
39 | curl_get "$gns_link/www.test_plugin_rest_gns?record_type=A" "1.1.1.2.*1.1.1.1" | 62 | curl_get "$gns_link/www1.$TEST_TLD" "1.1.1.1" |
40 | curl_get "$gns_link/www.test_plugin_rest_gns?record_type=AAAA" "1::1" | ||
41 | curl_get "$gns_link/www.test_plugin_rest_gns?record_type=WRONG_TYPE" "1.1.1.2.*1::1.*1.1.1.1" | ||
42 | 63 | ||
43 | gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www1 -e 1d -V 1.1.1.1 -t A | 64 | gnunet-namestore -z "$TEST_TLD" -d -n www1 -c test_gns_lookup.conf |
44 | curl_get "$gns_link/www1.test_plugin_rest_gns" "1.1.1.1" | 65 | gnunet-namestore -z "$TEST_TLD" -d -n www -c test_gns_lookup.conf |
45 | 66 | ||
46 | gnunet-identity -D "test_plugin_rest_gns" > /dev/null 2>&1 | 67 | gnunet-identity -D "$TEST_TLD" -c test_gns_lookup.conf > /dev/null 2>&1 |
47 | 68 | ||
48 | curl_get "$gns_link/www1.test_plugin_rest_gns" "error" | 69 | curl_get "$gns_link/www1.$TEST_TLD" "error" |
49 | 70 | ||
50 | exit 0 | 71 | exit 0 |
diff --git a/src/util/gnunet-service-resolver.c b/src/util/gnunet-service-resolver.c index 23ba39fee..d7d456fba 100644 --- a/src/util/gnunet-service-resolver.c +++ b/src/util/gnunet-service-resolver.c | |||
@@ -642,9 +642,9 @@ try_cache (const char *hostname, | |||
642 | const struct GNUNET_DNSPARSER_Record *record = rle->record; | 642 | const struct GNUNET_DNSPARSER_Record *record = rle->record; |
643 | 643 | ||
644 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 644 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
645 | "Found cache entry for '%s', record type '%u'\n", | 645 | "Checking cache entry for '%s', record is for '%s'\n", |
646 | hostname, | 646 | hostname, |
647 | record_type); | 647 | record->name); |
648 | if ((GNUNET_DNSPARSER_TYPE_CNAME == record->type) && | 648 | if ((GNUNET_DNSPARSER_TYPE_CNAME == record->type) && |
649 | (GNUNET_DNSPARSER_TYPE_CNAME != record_type) && (GNUNET_NO == found)) | 649 | (GNUNET_DNSPARSER_TYPE_CNAME != record_type) && (GNUNET_NO == found)) |
650 | { | 650 | { |
@@ -653,7 +653,8 @@ try_cache (const char *hostname, | |||
653 | process_get (hostname, record_type, client_request_id, client); | 653 | process_get (hostname, record_type, client_request_id, client); |
654 | return GNUNET_YES; /* counts as a cache "hit" */ | 654 | return GNUNET_YES; /* counts as a cache "hit" */ |
655 | } | 655 | } |
656 | found |= send_reply (rle->record, record_type, client_request_id, client); | 656 | if (0 == strcmp (record->name, hostname)) |
657 | found |= send_reply (rle->record, record_type, client_request_id, client); | ||
657 | } | 658 | } |
658 | if (GNUNET_NO == found) | 659 | if (GNUNET_NO == found) |
659 | return GNUNET_NO; /* had records, but none matched! */ | 660 | return GNUNET_NO; /* had records, but none matched! */ |
@@ -723,6 +724,9 @@ cache_answers (const char *name, | |||
723 | { | 724 | { |
724 | rc = GNUNET_new (struct ResolveCache); | 725 | rc = GNUNET_new (struct ResolveCache); |
725 | rc->hostname = GNUNET_strdup (name); | 726 | rc->hostname = GNUNET_strdup (name); |
727 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
728 | "Caching record for name %s under %s\n", | ||
729 | record->name, name); | ||
726 | GNUNET_CONTAINER_DLL_insert (cache_head, cache_tail, rc); | 730 | GNUNET_CONTAINER_DLL_insert (cache_head, cache_tail, rc); |
727 | cache_size++; | 731 | cache_size++; |
728 | } | 732 | } |