summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2019-11-30 21:05:25 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-11-30 21:05:25 +0100
commitd817f861e6da2da5759a4b55117a8d8d47a91a87 (patch)
treeeba5c332ebe7bb28832fd60e50ec06473bc5ab18
parent69dda189455dee811675bfb946a3a7e53f787194 (diff)
add support for zkey CNAMEs #5978
-rw-r--r--src/gns/gnunet-service-gns_resolver.c43
-rwxr-xr-xsrc/gns/test_gns_cname_lookup.sh23
2 files changed, 58 insertions, 8 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 8639a239b..4b2641818 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -1232,13 +1232,14 @@ handle_gns_cname_result (struct GNS_ResolverHandle *rh,
{
size_t nlen;
char *res;
+ const char *tld;
struct AuthorityChain *ac;
int af;
+ struct GNUNET_CRYPTO_EcdsaPublicKey zone;
nlen = strlen (cname);
- if ((nlen > 2) &&
- (0 == strcmp (".+",
- &cname[nlen - 2])))
+ tld = GNS_get_tld (cname);
+ if (0 == strcmp ("+", tld))
{
/* CNAME resolution continues relative to current domain */
if (0 == rh->name_resolution_pos)
@@ -1272,6 +1273,42 @@ handle_gns_cname_result (struct GNS_ResolverHandle *rh,
rh);
return;
}
+ if (GNUNET_OK == GNUNET_GNSRECORD_zkey_to_pkey (tld, &zone))
+ {
+ /* CNAME resolution continues relative to current domain */
+ if (0 == rh->name_resolution_pos)
+ {
+ GNUNET_asprintf (&res,
+ "%.*s",
+ strlen (cname) - (strlen (tld) + 1),
+ cname);
+ }
+ else
+ {
+ GNUNET_asprintf (&res,
+ "%.*s.%.*s",
+ (int) rh->name_resolution_pos,
+ rh->name,
+ (int) strlen (cname) - (strlen(tld)+1),
+ cname);
+ }
+ rh->name_resolution_pos = strlen (res);
+ GNUNET_free (rh->name);
+ rh->name = res;
+ ac = GNUNET_new (struct AuthorityChain);
+ ac->rh = rh;
+ ac->gns_authority = GNUNET_YES;
+ ac->authority_info.gns_authority = zone;
+ ac->label = resolver_lookup_get_next_label (rh);
+ /* add AC to tail */
+ GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head,
+ rh->ac_tail,
+ ac);
+ rh->task_id = GNUNET_SCHEDULER_add_now (&recursive_resolution,
+ rh);
+ return;
+ }
+
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Got CNAME `%s' from GNS for `%s'\n",
cname,
diff --git a/src/gns/test_gns_cname_lookup.sh b/src/gns/test_gns_cname_lookup.sh
index f71346127..748198074 100755
--- a/src/gns/test_gns_cname_lookup.sh
+++ b/src/gns/test_gns_cname_lookup.sh
@@ -32,26 +32,31 @@ TEST_RECORD_CNAME_PLUS="server.+"
TEST_RECORD_CNAME_DNS="gnunet.org"
TEST_RECORD_NAME_SERVER="server"
TEST_RECORD_NAME_PLUS="www"
+TEST_RECORD_NAME_ZKEY="www2"
TEST_RECORD_NAME_DNS="www3"
MY_EGO="myego"
TEST_DOMAIN_PLUS="www.$MY_EGO"
+TEST_DOMAIN_ZKEY="www2.$MY_EGO"
TEST_DOMAIN_DNS="www3.$MY_EGO"
which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 15"
gnunet-arm -s -c test_gns_lookup.conf
gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
+MY_EGO_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep ${MY_EGO} | awk '{print $3}')
+TEST_RECORD_CNAME_ZKEY="server.${MY_EGO_PKEY}"
gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME_DNS -t CNAME -V $TEST_RECORD_CNAME_DNS -e never -c test_gns_lookup.conf
gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME_PLUS -t CNAME -V $TEST_RECORD_CNAME_PLUS -e never -c test_gns_lookup.conf
+gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME_ZKEY -t CNAME -V $TEST_RECORD_CNAME_ZKEY -e never -c test_gns_lookup.conf
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
RES_CNAME=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t A -c test_gns_lookup.conf`
RES_CNAME_RAW=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t CNAME -c test_gns_lookup.conf`
+RES_CNAME_ZKEY=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_ZKEY -t A -c test_gns_lookup.conf`
RES_CNAME_DNS=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_DNS -t A -c test_gns_lookup.conf | grep $TEST_IP_DNS`
-echo NOW
-gnunet-gns --raw -u $TEST_DOMAIN_DNS -t A -c test_gns_lookup.conf
-echo WON
+
TESTEGOZONE=`gnunet-identity -c test_gns_lookup.conf -d | awk '{print $3}'`
gnunet-namestore -p -z $MY_EGO -d -n $TEST_RECORD_NAME_DNS -t CNAME -V $TEST_RECORD_CNAME_DNS -e never -c test_gns_lookup.conf
gnunet-namestore -p -z $MY_EGO -d -n $TEST_RECORD_NAME_PLUS -t CNAME -V $TEST_RECORD_CNAME_PLUS -e never -c test_gns_lookup.conf
+gnunet-namestore -p -z $MY_EGO -d -n $TEST_RECORD_NAME_ZKEY -t CNAME -V $TEST_RECORD_CNAME_ZKEY -e never -c test_gns_lookup.conf
gnunet-namestore -p -z $MY_EGO -d -n $TEST_RECORD_CNAME_SERVER -t A -V $TEST_IP_PLUS -e never -c test_gns_lookup.conf
gnunet-identity -D $MY_EGO -c test_gns_lookup.conf
gnunet-arm -e -c test_gns_lookup.conf
@@ -70,9 +75,17 @@ fi
if [ "$RES_CNAME" = "$TEST_IP_PLUS" ]
then
- echo "PASS: IP resolution from GNS"
+ echo "PASS: IP resolution from GNS (.+)"
+else
+ echo "FAIL: IP resolution from GNS (.+), got $RES_CNAME, expected $TEST_IP_PLUS."
+ exit 1
+fi
+
+if [ "$RES_CNAME_ZKEY" = "$TEST_IP_PLUS" ]
+then
+ echo "PASS: IP resolution from GNS (.zkey)"
else
- echo "FAIL: IP resolution from GNS, got $RES_CNAME, expected $TEST_IP_PLUS."
+ echo "FAIL: IP resolution from GNS (.zkey), got $RES_CNAME, expected $TEST_IP_PLUS."
exit 1
fi