From 1bba6bc1221a64d97f593fc673b947ab5a7dfc54 Mon Sep 17 00:00:00 2001 From: rexxnor Date: Mon, 3 Feb 2020 18:26:49 +0100 Subject: [PATCH] added a test for DHT lookup between peers --- src/gns/test_gns_lookup_peer1.conf | 68 ++++++++++++++++++++++ src/gns/test_gns_lookup_peer2.conf | 64 ++++++++++++++++++++ src/gns/test_gns_multiple_record_lookup.sh | 68 ++++++++++++++++++++++ 3 files changed, 200 insertions(+) create mode 100644 src/gns/test_gns_lookup_peer1.conf create mode 100644 src/gns/test_gns_lookup_peer2.conf create mode 100755 src/gns/test_gns_multiple_record_lookup.sh diff --git a/src/gns/test_gns_lookup_peer1.conf b/src/gns/test_gns_lookup_peer1.conf new file mode 100644 index 000000000..3b034f8d5 --- /dev/null +++ b/src/gns/test_gns_lookup_peer1.conf @@ -0,0 +1,68 @@ +@INLINE@ test_gns_defaults.conf + +[namecache] +DISABLE = YES + +[PATHS] +GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-gns-peer-1/ + +[dht] +START_ON_DEMAND = YES +IMMEDIATE_START = YES + +[gns] +# PREFIX = valgrind --leak-check=full --track-origins=yes +START_ON_DEMAND = YES +AUTO_IMPORT_PKEY = YES +MAX_PARALLEL_BACKGROUND_QUERIES = 10 +DEFAULT_LOOKUP_TIMEOUT = 15 s +RECORD_PUT_INTERVAL = 1 h +ZONE_PUBLISH_TIME_WINDOW = 1 h +DNS_ROOT=PD67SGHF3E0447TU9HADIVU9OM7V4QHTOG0EBU69TFRI2LG63DR0 + +[namestore] +IMMEDIATE_START = YES +#PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=/tmp/ns_log + +[revocation] +WORKBITS = 1 + +[dhtcache] +QUOTA = 1 MB +DATABASE = heap + +[topology] +TARGET-CONNECTION-COUNT = 16 +AUTOCONNECT = YES +FRIENDS-ONLY = NO +MINIMUM-FRIENDS = 0 + +[ats] +WAN_QUOTA_IN = 1 GB +WAN_QUOTA_OUT = 1 GB + +[transport] +plugins = tcp +NEIGHBOUR_LIMIT = 50 +PORT = 2091 + +[transport-tcp] +TIMEOUT = 300 s + +[nat] +DISABLEV6 = YES +BINDTO = 127.0.0.1 +ENABLE_UPNP = NO +BEHIND_NAT = NO +ALLOW_NAT = NO +INTERNAL_ADDRESS = 127.0.0.1 +EXTERNAL_ADDRESS = 127.0.0.1 + +[dns2gns] +BINARY = gnunet-dns2gns +START_ON_DEMAND = YES +IMMEDIATE_START = YES +RUN_PER_USER = YES +BIND_TO = 127.0.0.1 +BIND_TO6 = ::1 +OPTIONS = -d 1.1.1.1 -p 12000 diff --git a/src/gns/test_gns_lookup_peer2.conf b/src/gns/test_gns_lookup_peer2.conf new file mode 100644 index 000000000..d64fdcda3 --- /dev/null +++ b/src/gns/test_gns_lookup_peer2.conf @@ -0,0 +1,64 @@ +@INLINE@ test_gns_defaults.conf + +[namecache] +DISABLE = YES + +[PATHS] +GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-gns-peer-2/ + +[dht] +START_ON_DEMAND = YES +IMMEDIATE_START = YES + +[identity] +START_ON_DEMAND = YES +IMMEDIATE_START = YES + +[gns] +# PREFIX = valgrind --leak-check=full --track-origins=yes +IMMEDIATE_START = YES +START_ON_DEMAND = YES +AUTO_IMPORT_PKEY = YES +MAX_PARALLEL_BACKGROUND_QUERIES = 10 +DEFAULT_LOOKUP_TIMEOUT = 15 s +RECORD_PUT_INTERVAL = 1 h +ZONE_PUBLISH_TIME_WINDOW = 1 h +DNS_ROOT=PD67SGHF3E0447TU9HADIVU9OM7V4QHTOG0EBU69TFRI2LG63DR0 + +[namestore] +IMMEDIATE_START = YES +#PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=/tmp/ns_log + +[revocation] +WORKBITS = 1 + +[dhtcache] +QUOTA = 1 MB +DATABASE = heap + +[topology] +TARGET-CONNECTION-COUNT = 16 +AUTOCONNECT = YES +FRIENDS-ONLY = NO +MINIMUM-FRIENDS = 0 + +[ats] +WAN_QUOTA_IN = 1 GB +WAN_QUOTA_OUT = 1 GB + +[transport] +plugins = tcp +NEIGHBOUR_LIMIT = 50 +PORT = 2092 + +[transport-tcp] +TIMEOUT = 300 s + +[nat] +DISABLEV6 = YES +BINDTO = 127.0.0.1 +ENABLE_UPNP = NO +BEHIND_NAT = NO +ALLOW_NAT = NO +INTERNAL_ADDRESS = 127.0.0.1 +EXTERNAL_ADDRESS = 127.0.0.1 diff --git a/src/gns/test_gns_multiple_record_lookup.sh b/src/gns/test_gns_multiple_record_lookup.sh new file mode 100755 index 000000000..fbd9a6b13 --- /dev/null +++ b/src/gns/test_gns_multiple_record_lookup.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# This file is in the public domain. +trap "gnunet-arm -e -c test_gns_lookup_peer1.conf" INT +trap "gnunet-arm -e -c test_gns_lookup_peer2.conf" INT +which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5" + +LOCATION=$(which gnunet-config) +if [ -z $LOCATION ] +then + LOCATION="gnunet-config" +fi +$LOCATION --version 1> /dev/null +if test $? != 0 +then + echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" + exit 77 +fi + +rm -rf `gnunet-config -c test_gns_lookup_peer1.conf -f -s paths -o GNUNET_TEST_HOME` +rm -rf `gnunet-config -c test_gns_lookup_peer2.conf -f -s paths -o GNUNET_TEST_HOME` +MY_EGO="localego" +OTHER_EGO="remoteego" + +TEST_IP="127.0.0.1" +TEST_IPV6="dead::beef" +LABEL="fnord" + +gnunet-arm -s -c test_gns_lookup_peer2.conf +PKEY=`$DO_TIMEOUT gnunet-identity -V -C $OTHER_EGO -c test_gns_lookup_peer2.conf` +gnunet-namestore -p -z $OTHER_EGO -a -n $LABEL -t A -V $TEST_IP -e 3600s -c test_gns_lookup_peer2.conf +gnunet-namestore -p -z $OTHER_EGO -a -n $LABEL -t AAAA -V $TEST_IPV6 -e 3600s -c test_gns_lookup_peer2.conf +gnunet-namestore -D -z $OTHER_EGO -n $LABEL +gnunet-arm -e -c test_gns_lookup_peer2.conf + +echo "Second peer" +gnunet-arm -s -c test_gns_lookup_peer1.conf +echo "Second peer started" +RESP=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$PKEY -t ANY -c test_gns_lookup_peer1.conf` +RESP1=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$PKEY -t A -c test_gns_lookup_peer1.conf` +RESP2=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$PKEY -t AAAA -c test_gns_lookup_peer1.conf` +gnunet-arm -e -c test_gns_lookup_peer1.conf + +rm -rf `gnunet-config -c test_gns_lookup_peer1.conf -f -s paths -o GNUNET_TEST_HOME` +rm -rf `gnunet-config -c test_gns_lookup_peer2.conf -f -s paths -o GNUNET_TEST_HOME` + +RESPONSES=($(echo $RESP | tr "\n" " " )) + +if [ "$RESP1" == "$TEST_IP" ] +then + echo "PASS: A record resolution from DHT via separate peer" +else + echo "FAIL: A record resolution from DHT via separate peer, got $RESP1, expected $TEST_IP" + exit 1 +fi +if [ "$RESP2" == "$TEST_IPV6" ] +then + echo "PASS: AAAA record resolution from DHT via separate peer" +else + echo "FAIL: AAAA record resolution from DHT via separate peer, got $RESP2, expected $TEST_IPV6" + exit 1 +fi +if [[ "${RESPONSES[0]} ${RESPONSES[1]}" == "$TEST_IPV6 $TEST_IP" ]] || [[ "${RESPONSES[0]} ${RESPONSES[1]}" == "$TEST_IP $TEST_IPV6" ]] +then + echo "PASS: ANY record resolution from DHT via separate peer" +else + echo "FAIL: ANY record resolution from DHT via separate peer, got $RESP, expected $TEST_IPV6 $TEST_IP or $TEST_IP $TEST_IPV6" + exit 1 +fi -- 2.25.1