aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2019-10-11 14:48:02 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-10-11 14:48:02 +0200
commit559daabee673134f03d76f16d25c1e0ef23b4fdc (patch)
treeeed15cd757cdf6d968ff9d0390837a1ba6f7269e
parent3b80c8d9daddaeaf033d0b0d3f6cda842a939c8d (diff)
downloadgnunet-559daabee673134f03d76f16d25c1e0ef23b4fdc.tar.gz
gnunet-559daabee673134f03d76f16d25c1e0ef23b4fdc.zip
fix rest; uncrustify
-rw-r--r--src/gns/Makefile.am4
-rwxr-xr-xsrc/gns/test_gns_cname_lookup.sh4
-rwxr-xr-xsrc/gns/test_gns_gns2dns_cname_lookup.sh2
-rw-r--r--src/gns/test_gns_lookup.conf2
-rwxr-xr-xsrc/gns/test_plugin_rest_gns.sh67
-rw-r--r--src/util/gnunet-service-resolver.c10
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
269endif 269endif
270endif 270endif
271if HAVE_JSON
272check_SCRIPTS += \
273 test_plugin_rest_gns.sh
274endif
271endif 275endif
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
45gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_CNAME_SERVER -t A -V $TEST_IP_PLUS -e never -c test_gns_lookup.conf 45gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_CNAME_SERVER -t A -V $TEST_IP_PLUS -e never -c test_gns_lookup.conf
46RES_CNAME=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t A -c test_gns_lookup.conf` 46RES_CNAME=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t A -c test_gns_lookup.conf`
47RES_CNAME_RAW=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t CNAME -c test_gns_lookup.conf` 47RES_CNAME_RAW=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t CNAME -c test_gns_lookup.conf`
48RES_CNAME_DNS=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_DNS -t A -c test_gns_lookup.conf` 48RES_CNAME_DNS=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_DNS -t A -c test_gns_lookup.conf | grep $TEST_IP_DNS`
49echo NOW 49echo NOW
50gnunet-gns --raw -u $TEST_DOMAIN_DNS -t A -c test_gns_lookup.conf 50gnunet-gns --raw -u $TEST_DOMAIN_DNS -t A -c test_gns_lookup.conf
51echo WON 51echo WON
@@ -76,7 +76,7 @@ else
76 exit 1 76 exit 1
77fi 77fi
78 78
79if [ "$RES_CNAME_DNS" = "$TEST_IP_DNS" ] 79if echo "$RES_CNAME_DNS" | grep "$TEST_IP_DNS" > /dev/null
80then 80then
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
86fi 86fi
87 87
88if [ "$RES_IP6" = "$TEST_IP6" ] 88if echo "$RES_IP6" | grep "$TEST_IP6" > /dev/null
89then 89then
90 echo "PASS: Resolved $TEST_DOMAIN to $RES_IP6." 90 echo "PASS: Resolved $TEST_DOMAIN to $RES_IP6."
91else 91else
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]
4DISABLE = YES 4DISABLE = NO
5 5
6[PATHS] 6[PATHS]
7GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-gns-peer-1/ 7GNUNET_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. 3trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT
4#Exit 0 means success, exit 1 means failed test 4
5LOCATION=$(which gnunet-config)
6if [ -z $LOCATION ]
7then
8 LOCATION="gnunet-config"
9fi
10$LOCATION --version 1> /dev/null
11if test $? != 0
12then
13 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
14 exit 77
15fi
16
17rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
5 18
6gns_link="http://localhost:7776/gns" 19gns_link="http://localhost:7776/gns"
7wrong_link="http://localhost:7776/gnsandmore" 20wrong_link="http://localhost:7776/gnsandmore"
@@ -9,42 +22,50 @@ wrong_link="http://localhost:7776/gnsandmore"
9curl_get () { 22curl_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}
34TEST_TLD="testtld"
19 35
20gnunet-identity -D "test_plugin_rest_gns" > /dev/null 2>&1 36gnunet-arm -s -c test_gns_lookup.conf
37gnunet-arm -I
38gnunet-identity -D "$TEST_TLD" -c test_gns_lookup.conf > /dev/null 2>&1
21 39
22curl_get "$gns_link/www.test_plugin_rest_gns" "error" 40curl_get "$gns_link/www.$TEST_TLD" "error"
23 41
24gnunet-identity -C "test_plugin_rest_gns" 42gnunet-identity -C "$TEST_TLD" -c test_gns_lookup.conf
43sleep 0.5
44curl_get "$gns_link/www.$TEST_TLD" "\[\]"
25 45
26curl_get "$gns_link/www.test_plugin_rest_gns" "\[\]" 46gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1.1.1.1 -t A -c test_gns_lookup.conf
27 47
28gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1.1.1.1 -t A 48curl_get "$gns_link/www.$TEST_TLD" "1.1.1.1"
29 49
30curl_get "$gns_link/www.test_plugin_rest_gns" "1.1.1.1" 50gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1::1 -t AAAA -c test_gns_lookup.conf
31 51
32gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1::1 -t AAAA 52curl_get "$gns_link/www.$TEST_TLD" "1::1.*1.1.1.1"
33 53
34curl_get "$gns_link/www.test_plugin_rest_gns" "1::1.*1.1.1.1" 54gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1.1.1.2 -t A -c test_gns_lookup.conf
35 55
36gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1.1.1.2 -t A 56curl_get "$gns_link/www.$TEST_TLD" "1.1.1.2.*1::1.*1.1.1.1"
57curl_get "$gns_link/www.$TEST_TLD?record_type=A" "1.1.1.2.*1.1.1.1"
58curl_get "$gns_link/www.$TEST_TLD?record_type=AAAA" "1::1"
59curl_get "$gns_link/www.$TEST_TLD?record_type=WRONG_TYPE" "1.1.1.2.*1::1.*1.1.1.1"
37 60
38curl_get "$gns_link/www.test_plugin_rest_gns" "1.1.1.2.*1::1.*1.1.1.1" 61gnunet-namestore -z "$TEST_TLD" -p -a -n www1 -e 1d -V 1.1.1.1 -t A -c test_gns_lookup.conf
39curl_get "$gns_link/www.test_plugin_rest_gns?record_type=A" "1.1.1.2.*1.1.1.1" 62curl_get "$gns_link/www1.$TEST_TLD" "1.1.1.1"
40curl_get "$gns_link/www.test_plugin_rest_gns?record_type=AAAA" "1::1"
41curl_get "$gns_link/www.test_plugin_rest_gns?record_type=WRONG_TYPE" "1.1.1.2.*1::1.*1.1.1.1"
42 63
43gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www1 -e 1d -V 1.1.1.1 -t A 64gnunet-namestore -z "$TEST_TLD" -d -n www1 -c test_gns_lookup.conf
44curl_get "$gns_link/www1.test_plugin_rest_gns" "1.1.1.1" 65gnunet-namestore -z "$TEST_TLD" -d -n www -c test_gns_lookup.conf
45 66
46gnunet-identity -D "test_plugin_rest_gns" > /dev/null 2>&1 67gnunet-identity -D "$TEST_TLD" -c test_gns_lookup.conf > /dev/null 2>&1
47 68
48curl_get "$gns_link/www1.test_plugin_rest_gns" "error" 69curl_get "$gns_link/www1.$TEST_TLD" "error"
49 70
50exit 0 71exit 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 }