aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/man/gnunet-gns.119
-rw-r--r--doc/man/gnunet-namestore.13
-rw-r--r--src/gns/gns.conf.in6
-rw-r--r--src/gns/gnunet-gns.c253
-rw-r--r--src/gns/gnunet-service-gns.c161
-rw-r--r--src/gns/gnunet-service-gns.h16
-rw-r--r--src/gns/gnunet-service-gns_interceptor.c22
-rw-r--r--src/gns/gnunet-service-gns_interceptor.h6
-rw-r--r--src/gns/gnunet-service-gns_resolver.c337
-rw-r--r--src/gns/gnunet-service-gns_resolver.h21
-rwxr-xr-xsrc/gns/test_gns_cname_lookup.sh39
-rwxr-xr-xsrc/gns/test_gns_delegated_lookup.sh22
-rwxr-xr-xsrc/gns/test_gns_dht_lookup.sh22
-rwxr-xr-xsrc/gns/test_gns_gns2dns_lookup.sh36
-rwxr-xr-xsrc/gns/test_gns_ipv6_lookup.sh11
-rwxr-xr-xsrc/gns/test_gns_lookup.sh12
-rwxr-xr-xsrc/gns/test_gns_mx_lookup.sh19
-rwxr-xr-xsrc/gns/test_gns_plus_lookup.sh9
-rwxr-xr-xsrc/gns/test_gns_quickupdate.sh34
-rwxr-xr-xsrc/gns/test_gns_rel_expiration.sh25
-rwxr-xr-xsrc/gns/test_gns_revocation.sh24
-rwxr-xr-xsrc/gns/test_gns_soa_lookup.sh13
-rwxr-xr-xsrc/gns/test_gns_txt_lookup.sh12
-rwxr-xr-xsrc/gns/test_gns_zkey_lookup.sh2
-rw-r--r--src/gnsrecord/gnsrecord_misc.c31
-rw-r--r--src/include/gnunet_gns_service.h3
-rw-r--r--src/namecache/gnunet-service-namecache.c10
-rw-r--r--src/namecache/plugin_namecache_flat.c6
-rw-r--r--src/namestore/gnunet-namestore.c8
-rw-r--r--src/namestore/gnunet-service-namestore.c17
-rw-r--r--src/namestore/plugin_rest_namestore.c3
31 files changed, 640 insertions, 562 deletions
diff --git a/doc/man/gnunet-gns.1 b/doc/man/gnunet-gns.1
index 5fabc14f3..a6f27479a 100644
--- a/doc/man/gnunet-gns.1
+++ b/doc/man/gnunet-gns.1
@@ -1,7 +1,7 @@
1.TH GNUNET\-GNS 1 "Aug 23, 2013" "GNUnet" 1.TH GNUNET\-GNS 1 "Mar 23, 2018" "GNUnet"
2 2
3.SH NAME 3.SH NAME
4gnunet\-gns \- Access to GNUnet Name Service 4gnunet\-gns \- Access to GNU Name System
5 5
6.SH SYNOPSIS 6.SH SYNOPSIS
7.B gnunet\-gns 7.B gnunet\-gns
@@ -9,7 +9,7 @@ gnunet\-gns \- Access to GNUnet Name Service
9.br 9.br
10 10
11.SH DESCRIPTION 11.SH DESCRIPTION
12\fBgnunet\-gns\fP can be used to lookup and process GNUnet Name Service names. 12\fBgnunet\-gns\fP can be used to lookup and process GNU Name Service names.
13 13
14.SH OPTIONS 14.SH OPTIONS
15.B 15.B
@@ -30,10 +30,7 @@ Use LOGLEVEL for logging. Valid values are DEBUG, INFO, WARNING and ERROR.
30.B 30.B
31.IP "\-u NAME, \-\-lookup=NAME" 31.IP "\-u NAME, \-\-lookup=NAME"
32Name to lookup. 32Name to lookup.
33Resolve the specified name using the GNUnet Name System. 33Resolve the specified name using the GNU Name System.
34.B
35.IP "\-p PKEY, \-\-public-key=PKEY"
36Public key of the zone to perform the lookup in. This option should be used if the lookup is to be performed against a zone not controlled by this peer (alternatively, you could pass a ".zkey" for the name).
37.B 34.B
38.IP "\-T DELAY, \-\-timeout=DELAY" 35.IP "\-T DELAY, \-\-timeout=DELAY"
39Set the timeout to DELAY. By default, gnunet\-gns will continue to try to resolve the name until there is a definitive answer or until the user aborts with CTRL\-C. 36Set the timeout to DELAY. By default, gnunet\-gns will continue to try to resolve the name until there is a definitive answer or until the user aborts with CTRL\-C.
@@ -44,13 +41,15 @@ Supported TYPE's are: A, AAAA, CNAME, NS, PKEY, PSEU, TLSA, SRV, SOA, MX, LEHO,
44 41
45Defaults to "A". 42Defaults to "A".
46.B 43.B
47.IP "\-z NAME, \-\-zone=NAME"
48Name of the ego of the zone to lookup the record in. The public key associated with the ego will be used for the zone.
49.B
50.IP "\-v, \-\-version" 44.IP "\-v, \-\-version"
51Print GNUnet version number. 45Print GNUnet version number.
52.B 46.B
53 47
48.SH RETURN VALUE
49
50gnunet\-gns will return 0 on success, 1 on internal failures, 2 on launch failures,
513 if the given name is not configured to use GNS, and 4 on timeout.
52
54 53
55.SH BUGS 54.SH BUGS
56Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <gnunet\-developers@gnu.org> 55Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <gnunet\-developers@gnu.org>
diff --git a/doc/man/gnunet-namestore.1 b/doc/man/gnunet-namestore.1
index daed19116..1811031ad 100644
--- a/doc/man/gnunet-namestore.1
+++ b/doc/man/gnunet-namestore.1
@@ -1,7 +1,7 @@
1.TH GNUNET\-NAMESTORE 1 "Apr 15, 2014" "GNUnet" 1.TH GNUNET\-NAMESTORE 1 "Apr 15, 2014" "GNUnet"
2 2
3.SH NAME 3.SH NAME
4gnunet\-namestore \- manipulate GNUnet zones 4gnunet\-namestore \- manipulate GNU Name System (GNS) zone data
5 5
6.SH SYNOPSIS 6.SH SYNOPSIS
7.B gnunet\-namestore 7.B gnunet\-namestore
@@ -74,4 +74,3 @@ Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic
74 74
75.SH "SEE ALSO" 75.SH "SEE ALSO"
76\fBgnunet\-gns\fP(1), \fBgnunet\-namestore\-gtk\fP(1) 76\fBgnunet\-gns\fP(1), \fBgnunet\-namestore\-gtk\fP(1)
77
diff --git a/src/gns/gns.conf.in b/src/gns/gns.conf.in
index b85b1e04c..6b764904f 100644
--- a/src/gns/gns.conf.in
+++ b/src/gns/gns.conf.in
@@ -16,6 +16,12 @@ UNIX_MATCH_GID = YES
16# How many queries is GNS allowed to perform in the background at the same time? 16# How many queries is GNS allowed to perform in the background at the same time?
17MAX_PARALLEL_BACKGROUND_QUERIES = 1000 17MAX_PARALLEL_BACKGROUND_QUERIES = 1000
18 18
19# Should we use the DNS interception mechanism? If set to YES
20# we will ask gnunet-service-dns to pass DNS queries to us. Otherwise,
21# we only answer GNS queries via the API (which itself may be
22# called via NSS or other mechanisms).
23INTERCEPT_DNS = YES
24
19# Using caching or always ask DHT 25# Using caching or always ask DHT
20# USE_CACHE = YES 26# USE_CACHE = YES
21 27
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c
index c0de0f30c..202e02a50 100644
--- a/src/gns/gnunet-gns.c
+++ b/src/gns/gnunet-gns.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2012-2013, 2017 GNUnet e.V. 3 Copyright (C) 2012-2013, 2017-2018 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -56,16 +56,6 @@ static char *lookup_name;
56static char *lookup_type; 56static char *lookup_type;
57 57
58/** 58/**
59 * Identity of the zone to use for the lookup (-z option)
60 */
61static char *zone_ego_name;
62
63/**
64 * Public key of the zone to use for the lookup (-p option)
65 */
66static char *public_key;
67
68/**
69 * Set to GNUNET_GNS_LO_LOCAL_MASTER if we are looking up in the master zone. 59 * Set to GNUNET_GNS_LO_LOCAL_MASTER if we are looking up in the master zone.
70 */ 60 */
71static enum GNUNET_GNS_LocalOptions local_options; 61static enum GNUNET_GNS_LocalOptions local_options;
@@ -105,6 +95,15 @@ static struct GNUNET_IDENTITY_Operation *id_op;
105 */ 95 */
106static struct GNUNET_SCHEDULER_Task *tt; 96static struct GNUNET_SCHEDULER_Task *tt;
107 97
98/**
99 * Global return value.
100 * 0 on success (default),
101 * 1 on internal failures, 2 on launch failure,
102 * 3 if the name is not a GNS-supported TLD,
103 * 4 on timeout
104 */
105static int global_ret;
106
108 107
109/** 108/**
110 * Task run on shutdown. Cleans up everything. 109 * Task run on shutdown. Cleans up everything.
@@ -157,6 +156,7 @@ do_timeout (void *cls)
157{ 156{
158 tt = NULL; 157 tt = NULL;
159 GNUNET_SCHEDULER_shutdown (); 158 GNUNET_SCHEDULER_shutdown ();
159 global_ret = 4;
160} 160}
161 161
162 162
@@ -173,7 +173,6 @@ process_lookup_result (void *cls,
173 const struct GNUNET_GNSRECORD_Data *rd) 173 const struct GNUNET_GNSRECORD_Data *rd)
174{ 174{
175 const char *name = cls; 175 const char *name = cls;
176 uint32_t i;
177 const char *typename; 176 const char *typename;
178 char* string_val; 177 char* string_val;
179 178
@@ -186,7 +185,7 @@ process_lookup_result (void *cls,
186 printf ("%s:\n", 185 printf ("%s:\n",
187 name); 186 name);
188 } 187 }
189 for (i=0; i<rd_count; i++) 188 for (uint32_t i=0; i<rd_count; i++)
190 { 189 {
191 if ( (rd[i].record_type != rtype) && 190 if ( (rd[i].record_type != rtype) &&
192 (GNUNET_GNSRECORD_TYPE_ANY != rtype) ) 191 (GNUNET_GNSRECORD_TYPE_ANY != rtype) )
@@ -272,62 +271,58 @@ identity_zone_cb (void *cls,
272 el = NULL; 271 el = NULL;
273 if (NULL == ego) 272 if (NULL == ego)
274 { 273 {
275 fprintf (stderr, 274 global_ret = 3; /* Not a GNS TLD */
276 _("Ego for `%s' not found, cannot perform lookup.\n"),
277 zone_ego_name);
278 GNUNET_SCHEDULER_shutdown (); 275 GNUNET_SCHEDULER_shutdown ();
279 } 276 }
280 else 277 else
281 { 278 {
282 GNUNET_IDENTITY_ego_get_public_key (ego, &pkey); 279 GNUNET_IDENTITY_ego_get_public_key (ego,
280 &pkey);
283 lookup_with_public_key (&pkey); 281 lookup_with_public_key (&pkey);
284 } 282 }
285 GNUNET_free_non_null (zone_ego_name);
286 zone_ego_name = NULL;
287} 283}
288 284
289 285
290/** 286/**
291 * Method called to with the ego we are to use for the lookup, 287 * Obtain the TLD of the given @a name.
292 * when the ego is the one for the default master zone.
293 * 288 *
294 * @param cls closure (NULL, unused) 289 * @param name a name
295 * @param ego ego handle, NULL if not found 290 * @return the part of @a name after the last ".",
296 * @param ctx context for application to store data for this ego 291 * or @a name if @a name does not contain a "."
297 * (during the lifetime of this process, initially NULL)
298 * @param name name assigned by the user for this ego,
299 * NULL if the user just deleted the ego and it
300 * must thus no longer be used
301 */ 292 */
302static void 293static const char *
303identity_master_cb (void *cls, 294get_tld (const char *name)
304 struct GNUNET_IDENTITY_Ego *ego,
305 void **ctx,
306 const char *name)
307{ 295{
308 struct GNUNET_CRYPTO_EcdsaPublicKey pkey; 296 const char *tld;
309 const char *dot;
310 297
311 id_op = NULL; 298 tld = strrchr (name,
312 if (NULL == ego) 299 (unsigned char) '.');
313 { 300 if (NULL == tld)
314 fprintf (stderr, 301 tld = name;
315 _("Ego for `gns-master' not found, cannot perform lookup. Did you run gnunet-gns-import.sh?\n")); 302 else
316 GNUNET_SCHEDULER_shutdown (); 303 tld++; /* skip the '.' */
317 return; 304 return tld;
318 } 305}
319 GNUNET_IDENTITY_ego_get_public_key (ego, &pkey);
320 /* main name is our own master zone, do no look for that in the DHT */
321 local_options = GNUNET_GNS_LO_LOCAL_MASTER;
322 306
323 /* if the name is of the form 'label.gnu', never go to the DHT */ 307
324 dot = NULL; 308/**
325 if (NULL != lookup_name) 309 * Eat the TLD of the given @a name.
326 dot = strchr (lookup_name, '.'); 310 *
327 if ( (NULL != dot) && 311 * @param name a name
328 (0 == strcasecmp (dot, ".gnu")) ) 312 */
329 local_options = GNUNET_GNS_LO_NO_DHT; 313static void
330 lookup_with_public_key (&pkey); 314eat_tld (char *name)
315{
316 char *tld;
317
318 GNUNET_assert (0 < strlen (name));
319 tld = strrchr (name,
320 (unsigned char) '.');
321 if (NULL == tld)
322 strcpy (name,
323 GNUNET_GNS_MASTERZONE_STR);
324 else
325 *tld = '\0';
331} 326}
332 327
333 328
@@ -346,6 +341,9 @@ run (void *cls,
346 const struct GNUNET_CONFIGURATION_Handle *c) 341 const struct GNUNET_CONFIGURATION_Handle *c)
347{ 342{
348 struct GNUNET_CRYPTO_EcdsaPublicKey pkey; 343 struct GNUNET_CRYPTO_EcdsaPublicKey pkey;
344 const char *tld;
345 char *dot_tld;
346 char *zonestr;
349 347
350 cfg = c; 348 cfg = c;
351 gns = GNUNET_GNS_connect (cfg); 349 gns = GNUNET_GNS_connect (cfg);
@@ -360,52 +358,64 @@ run (void *cls,
360 NULL); 358 NULL);
361 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, 359 GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
362 NULL); 360 NULL);
363 identity = GNUNET_IDENTITY_connect (cfg, 361 /* start with trivial case: TLD is zkey */
364 NULL, 362 tld = get_tld (lookup_name);
365 NULL); 363 if (GNUNET_OK ==
366 if (NULL != public_key) 364 GNUNET_CRYPTO_ecdsa_public_key_from_string (tld,
365 strlen (tld),
366 &pkey))
367 {
368 eat_tld (lookup_name);
369 lookup_with_public_key (&pkey);
370 return;
371 }
372
373 /* second case: TLD is mapped in our configuration file */
374 GNUNET_asprintf (&dot_tld,
375 ".%s",
376 tld);
377 if (GNUNET_OK ==
378 GNUNET_CONFIGURATION_get_value_string (cfg,
379 "gns",
380 dot_tld,
381 &zonestr))
367 { 382 {
368 if (GNUNET_OK != 383 if (GNUNET_OK !=
369 GNUNET_CRYPTO_ecdsa_public_key_from_string (public_key, 384 GNUNET_CRYPTO_ecdsa_public_key_from_string (zonestr,
370 strlen (public_key), 385 strlen (zonestr),
371 &pkey)) 386 &pkey))
372 { 387 {
373 fprintf (stderr, 388 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
374 _("Public key `%s' is not well-formed\n"), 389 "gns",
375 public_key); 390 dot_tld,
391 _("Expected a base32-encoded public zone key\n"));
392 GNUNET_free (zonestr);
393 GNUNET_free (dot_tld);
376 GNUNET_SCHEDULER_shutdown (); 394 GNUNET_SCHEDULER_shutdown ();
377 return; 395 return;
378 } 396 }
397 GNUNET_free (dot_tld);
398 GNUNET_free (zonestr);
399 eat_tld (lookup_name);
379 lookup_with_public_key (&pkey); 400 lookup_with_public_key (&pkey);
380 return; 401 return;
381 } 402 }
382 if (NULL != zone_ego_name) 403 GNUNET_free (dot_tld);
383 { 404
384 el = GNUNET_IDENTITY_ego_lookup (cfg, 405 /* Final case: TLD matches one of our egos */
385 zone_ego_name, 406 eat_tld (lookup_name);
386 &identity_zone_cb, 407
387 NULL); 408 /* if the name is of the form 'label.gnu', never go to the DHT */
388 return; 409 if (NULL == strchr (lookup_name,
389 } 410 (unsigned char) '.'))
390 if ( (NULL != lookup_name) && 411 local_options = GNUNET_GNS_LO_NO_DHT;
391 (strlen (lookup_name) > 4) && 412 identity = GNUNET_IDENTITY_connect (cfg,
392 (0 == strcmp (".zkey", 413 NULL,
393 &lookup_name[strlen (lookup_name) - 4])) ) 414 NULL);
394 { 415 el = GNUNET_IDENTITY_ego_lookup (cfg,
395 /* no zone required, use 'anonymous' zone */ 416 tld,
396 GNUNET_CRYPTO_ecdsa_key_get_public (GNUNET_CRYPTO_ecdsa_key_get_anonymous (), 417 &identity_zone_cb,
397 &pkey); 418 NULL);
398 lookup_with_public_key (&pkey);
399 }
400 else
401 {
402 GNUNET_break (NULL == id_op);
403 id_op = GNUNET_IDENTITY_get (identity,
404 "gns-master",
405 &identity_master_cb,
406 NULL);
407 GNUNET_assert (NULL != id_op);
408 }
409} 419}
410 420
411 421
@@ -421,63 +431,48 @@ main (int argc,
421 char *const *argv) 431 char *const *argv)
422{ 432{
423 struct GNUNET_GETOPT_CommandLineOption options[] = { 433 struct GNUNET_GETOPT_CommandLineOption options[] = {
424 434 GNUNET_GETOPT_option_mandatory
425 GNUNET_GETOPT_option_string ('u', 435 (GNUNET_GETOPT_option_string ('u',
426 "lookup", 436 "lookup",
427 "NAME", 437 "NAME",
428 gettext_noop ("Lookup a record for the given name"), 438 gettext_noop ("Lookup a record for the given name"),
429 &lookup_name), 439 &lookup_name)),
430
431 GNUNET_GETOPT_option_string ('t', 440 GNUNET_GETOPT_option_string ('t',
432 "type", 441 "type",
433 "TYPE", 442 "TYPE",
434 gettext_noop ("Specify the type of the record to lookup"), 443 gettext_noop ("Specify the type of the record to lookup"),
435 &lookup_type), 444 &lookup_type),
436
437 GNUNET_GETOPT_option_relative_time ('T', 445 GNUNET_GETOPT_option_relative_time ('T',
438 "timeout", 446 "timeout",
439 "DELAY", 447 "DELAY",
440 gettext_noop ("Specify timeout for the lookup"), 448 gettext_noop ("Specify timeout for the lookup"),
441 &timeout), 449 &timeout),
442
443 GNUNET_GETOPT_option_flag ('r', 450 GNUNET_GETOPT_option_flag ('r',
444 "raw", 451 "raw",
445 gettext_noop ("No unneeded output"), 452 gettext_noop ("No unneeded output"),
446 &raw), 453 &raw),
447
448 GNUNET_GETOPT_option_string ('p',
449 "public-key",
450 "PKEY",
451 gettext_noop ("Specify the public key of the zone to lookup the record in"),
452 &public_key),
453
454 GNUNET_GETOPT_option_string ('z',
455 "zone",
456 "NAME",
457 gettext_noop ("Specify the name of the ego of the zone to lookup the record in"),
458 &zone_ego_name),
459
460 GNUNET_GETOPT_OPTION_END 454 GNUNET_GETOPT_OPTION_END
461 }; 455 };
462 int ret; 456 int ret;
463 457
464 timeout = GNUNET_TIME_UNIT_FOREVER_REL; 458 timeout = GNUNET_TIME_UNIT_FOREVER_REL;
465 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, 459 if (GNUNET_OK !=
466 &argc, &argv)) 460 GNUNET_STRINGS_get_utf8_args (argc, argv,
461 &argc, &argv))
467 return 2; 462 return 2;
468 463
469 GNUNET_log_setup ("gnunet-gns", 464 GNUNET_log_setup ("gnunet-gns",
470 "WARNING", 465 "WARNING",
471 NULL); 466 NULL);
472 ret = 467 ret = GNUNET_PROGRAM_run (argc, argv,
473 (GNUNET_OK == 468 "gnunet-gns",
474 GNUNET_PROGRAM_run (argc, argv, 469 _("GNUnet GNS resolver tool"),
475 "gnunet-gns", 470 options,
476 _("GNUnet GNS resolver tool"), 471 &run, NULL);
477 options,
478 &run, NULL)) ? 0 : 1;
479 GNUNET_free ((void*) argv); 472 GNUNET_free ((void*) argv);
480 return ret; 473 if (GNUNET_OK != ret)
474 return 1;
475 return global_ret;
481} 476}
482 477
483/* end of gnunet-gns.c */ 478/* end of gnunet-gns.c */
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index 69f1ca640..90cd47e1d 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2011-2013 GNUnet e.V. 3 Copyright (C) 2011-2018 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -29,7 +29,7 @@
29#include "gnunet_dnsparser_lib.h" 29#include "gnunet_dnsparser_lib.h"
30#include "gnunet_dht_service.h" 30#include "gnunet_dht_service.h"
31#include "gnunet_namecache_service.h" 31#include "gnunet_namecache_service.h"
32#include "gnunet_identity_service.h" 32#include "gnunet_gnsrecord_lib.h"
33#include "gnunet_gns_service.h" 33#include "gnunet_gns_service.h"
34#include "gnunet_statistics_service.h" 34#include "gnunet_statistics_service.h"
35#include "gns.h" 35#include "gns.h"
@@ -44,7 +44,7 @@
44struct GnsClient; 44struct GnsClient;
45 45
46/** 46/**
47 * Handle to a lookup operation from api 47 * Handle to a lookup operation from client via API.
48 */ 48 */
49struct ClientLookupHandle 49struct ClientLookupHandle
50{ 50{
@@ -76,6 +76,10 @@ struct ClientLookupHandle
76 76
77}; 77};
78 78
79
80/**
81 * Information we track per connected client.
82 */
79struct GnsClient 83struct GnsClient
80{ 84{
81 /** 85 /**
@@ -122,7 +126,7 @@ struct GNS_TopLevelDomain
122 /** 126 /**
123 * Public key associated with the @a tld. 127 * Public key associated with the @a tld.
124 */ 128 */
125 struct GNUNET_CRYPTO_EddsaPublicKey pkey; 129 struct GNUNET_CRYPTO_EcdsaPublicKey pkey;
126 130
127 /** 131 /**
128 * Top-level domain as a string, including leading ".". 132 * Top-level domain as a string, including leading ".".
@@ -143,17 +147,6 @@ static struct GNUNET_DHT_Handle *dht_handle;
143static struct GNUNET_NAMECACHE_Handle *namecache_handle; 147static struct GNUNET_NAMECACHE_Handle *namecache_handle;
144 148
145/** 149/**
146 * Our handle to the identity service
147 */
148static struct GNUNET_IDENTITY_Handle *identity_handle;
149
150/**
151 * Our handle to the identity operation to find the master zone
152 * for intercepted queries.
153 */
154static struct GNUNET_IDENTITY_Operation *identity_op;
155
156/**
157 * #GNUNET_YES if ipv6 is supported 150 * #GNUNET_YES if ipv6 is supported
158 */ 151 */
159static int v6_enabled; 152static int v6_enabled;
@@ -188,7 +181,7 @@ static struct GNS_TopLevelDomain *tld_tail;
188 */ 181 */
189int 182int
190GNS_find_tld (const char *tld_str, 183GNS_find_tld (const char *tld_str,
191 struct GNUNET_CRYPTO_EddsaPublicKey *pkey) 184 struct GNUNET_CRYPTO_EcdsaPublicKey *pkey)
192{ 185{
193 if ('\0' == *tld_str) 186 if ('\0' == *tld_str)
194 return GNUNET_NO; 187 return GNUNET_NO;
@@ -204,16 +197,36 @@ GNS_find_tld (const char *tld_str,
204 } 197 }
205 } 198 }
206 if (GNUNET_OK == 199 if (GNUNET_OK ==
207 GNUNET_STRINGS_string_to_data (tld_str + 1, 200 GNUNET_GNSRECORD_zkey_to_pkey (tld_str + 1,
208 strlen (tld_str + 1), 201 pkey))
209 pkey,
210 sizeof (*pkey)))
211 return GNUNET_YES; /* TLD string *was* the public key */ 202 return GNUNET_YES; /* TLD string *was* the public key */
212 return GNUNET_NO; 203 return GNUNET_NO;
213} 204}
214 205
215 206
216/** 207/**
208 * Obtain the TLD of the given @a name.
209 *
210 * @param name a name
211 * @return the part of @a name after the last ".",
212 * or @a name if @a name does not contain a "."
213 */
214const char *
215GNS_get_tld (const char *name)
216{
217 const char *tld;
218
219 tld = strrchr (name,
220 (unsigned char) '.');
221 if (NULL == tld)
222 tld = name;
223 else
224 tld++; /* skip the '.' */
225 return tld;
226}
227
228
229/**
217 * Task run during shutdown. 230 * Task run during shutdown.
218 * 231 *
219 * @param cls unused 232 * @param cls unused
@@ -227,16 +240,6 @@ shutdown_task (void *cls)
227 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 240 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
228 "Shutting down!\n"); 241 "Shutting down!\n");
229 GNS_interceptor_done (); 242 GNS_interceptor_done ();
230 if (NULL != identity_op)
231 {
232 GNUNET_IDENTITY_cancel (identity_op);
233 identity_op = NULL;
234 }
235 if (NULL != identity_handle)
236 {
237 GNUNET_IDENTITY_disconnect (identity_handle);
238 identity_handle = NULL;
239 }
240 GNS_resolver_done (); 243 GNS_resolver_done ();
241 if (NULL != statistics) 244 if (NULL != statistics)
242 { 245 {
@@ -416,7 +419,8 @@ handle_lookup (void *cls,
416 419
417 GNUNET_SERVICE_client_continue (gc->client); 420 GNUNET_SERVICE_client_continue (gc->client);
418 utf_in = (const char *) &sh_msg[1]; 421 utf_in = (const char *) &sh_msg[1];
419 GNUNET_STRINGS_utf8_tolower (utf_in, nameptr); 422 GNUNET_STRINGS_utf8_tolower (utf_in,
423 nameptr);
420 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 424 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
421 "Received LOOKUP `%s' message\n", 425 "Received LOOKUP `%s' message\n",
422 name); 426 name);
@@ -432,7 +436,9 @@ handle_lookup (void *cls,
432 { 436 {
433 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 437 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
434 "LOOKUP: Query for A record but AF_INET not supported!"); 438 "LOOKUP: Query for A record but AF_INET not supported!");
435 send_lookup_response (clh, 0, NULL); 439 send_lookup_response (clh,
440 0,
441 NULL);
436 return; 442 return;
437 } 443 }
438 if ( (GNUNET_DNSPARSER_TYPE_AAAA == ntohl (sh_msg->type)) && 444 if ( (GNUNET_DNSPARSER_TYPE_AAAA == ntohl (sh_msg->type)) &&
@@ -440,7 +446,9 @@ handle_lookup (void *cls,
440 { 446 {
441 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 447 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
442 "LOOKUP: Query for AAAA record but AF_INET6 not supported!"); 448 "LOOKUP: Query for AAAA record but AF_INET6 not supported!");
443 send_lookup_response (clh, 0, NULL); 449 send_lookup_response (clh,
450 0,
451 NULL);
444 return; 452 return;
445 } 453 }
446 clh->lookup = GNS_resolver_lookup (&sh_msg->zone, 454 clh->lookup = GNS_resolver_lookup (&sh_msg->zone,
@@ -455,57 +463,6 @@ handle_lookup (void *cls,
455 463
456 464
457/** 465/**
458 * Method called to inform about the ego to be used for the master zone
459 * for DNS interceptions.
460 *
461 * This function is only called ONCE, and 'NULL' being passed in
462 * @a ego does indicate that interception is not configured.
463 * If @a ego is non-NULL, we should start to intercept DNS queries
464 * and resolve ".gnu" queries using the given ego as the master zone.
465 *
466 * @param cls closure, our `const struct GNUNET_CONFIGURATION_Handle *c`
467 * @param ego ego handle
468 * @param ctx context for application to store data for this ego
469 * (during the lifetime of this process, initially NULL)
470 * @param name name assigned by the user for this ego,
471 * NULL if the user just deleted the ego and it
472 * must thus no longer be used
473 */
474static void
475identity_intercept_cb (void *cls,
476 struct GNUNET_IDENTITY_Ego *ego,
477 void **ctx,
478 const char *name)
479{
480 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
481 struct GNUNET_CRYPTO_EcdsaPublicKey dns_root;
482
483 identity_op = NULL;
484 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
485 "Looking for gns-intercept ego\n");
486 if (NULL == ego)
487 {
488 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
489 _("No ego configured for `%s`\n"),
490 "gns-intercept");
491
492 return;
493 }
494 GNUNET_IDENTITY_ego_get_public_key (ego,
495 &dns_root);
496 if (GNUNET_SYSERR ==
497 GNS_interceptor_init (&dns_root,
498 cfg))
499 {
500 GNUNET_break (0);
501 GNUNET_SCHEDULER_add_now (&shutdown_task,
502 NULL);
503 return;
504 }
505}
506
507
508/**
509 * Reads the configuration and populates TLDs 466 * Reads the configuration and populates TLDs
510 * 467 *
511 * @param cls unused 468 * @param cls unused
@@ -519,7 +476,7 @@ read_service_conf (void *cls,
519 const char *option, 476 const char *option,
520 const char *value) 477 const char *value)
521{ 478{
522 struct GNUNET_CRYPTO_EddsaPublicKey pk; 479 struct GNUNET_CRYPTO_EcdsaPublicKey pk;
523 struct GNS_TopLevelDomain *tld; 480 struct GNS_TopLevelDomain *tld;
524 481
525 if (option[0] != '.') 482 if (option[0] != '.')
@@ -545,7 +502,6 @@ read_service_conf (void *cls,
545} 502}
546 503
547 504
548
549/** 505/**
550 * Process GNS requests. 506 * Process GNS requests.
551 * 507 *
@@ -594,29 +550,24 @@ run (void *cls,
594 NULL); 550 NULL);
595 return; 551 return;
596 } 552 }
597
598 identity_handle = GNUNET_IDENTITY_connect (c,
599 NULL,
600 NULL);
601 if (NULL == identity_handle)
602 {
603 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
604 "Could not connect to identity service!\n");
605 }
606 else
607 {
608 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
609 "Looking for gns-intercept ego\n");
610 identity_op = GNUNET_IDENTITY_get (identity_handle,
611 "gns-intercept",
612 &identity_intercept_cb,
613 (void *) c);
614 }
615 GNS_resolver_init (namecache_handle, 553 GNS_resolver_init (namecache_handle,
616 dht_handle, 554 dht_handle,
617 c, 555 c,
618 max_parallel_bg_queries); 556 max_parallel_bg_queries);
619 statistics = GNUNET_STATISTICS_create ("gns", c); 557 if ( (GNUNET_YES ==
558 GNUNET_CONFIGURATION_get_value_yesno (c,
559 "gns",
560 "INTERCEPT_DNS")) &&
561 (GNUNET_SYSERR ==
562 GNS_interceptor_init (c)) )
563 {
564 GNUNET_break (0);
565 GNUNET_SCHEDULER_add_now (&shutdown_task,
566 NULL);
567 return;
568 }
569 statistics = GNUNET_STATISTICS_create ("gns",
570 c);
620 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, 571 GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
621 NULL); 572 NULL);
622} 573}
diff --git a/src/gns/gnunet-service-gns.h b/src/gns/gnunet-service-gns.h
index 3662c945d..439bad881 100644
--- a/src/gns/gnunet-service-gns.h
+++ b/src/gns/gnunet-service-gns.h
@@ -23,10 +23,10 @@
23 * @author Martin Schanzenbach 23 * @author Martin Schanzenbach
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
27#ifndef GNUNET_SERVICE_GNS_H 26#ifndef GNUNET_SERVICE_GNS_H
28#define GNUNET_SERVICE_GNS_H 27#define GNUNET_SERVICE_GNS_H
29 28
29
30/** 30/**
31 * Find GNS zone belonging to TLD @a tld. 31 * Find GNS zone belonging to TLD @a tld.
32 * 32 *
@@ -36,6 +36,18 @@
36 */ 36 */
37int 37int
38GNS_find_tld (const char *tld_str, 38GNS_find_tld (const char *tld_str,
39 struct GNUNET_CRYPTO_EddsaPublicKey *pkey); 39 struct GNUNET_CRYPTO_EcdsaPublicKey *pkey);
40
41
42/**
43 * Obtain the TLD of the given @a name.
44 *
45 * @param name a name
46 * @return the part of @a name after the last ".",
47 * or @a name if @a name does not contain a "."
48 */
49const char *
50GNS_get_tld (const char *name);
51
40 52
41#endif 53#endif
diff --git a/src/gns/gnunet-service-gns_interceptor.c b/src/gns/gnunet-service-gns_interceptor.c
index 71aa08dc5..0425e9500 100644
--- a/src/gns/gnunet-service-gns_interceptor.c
+++ b/src/gns/gnunet-service-gns_interceptor.c
@@ -27,6 +27,7 @@
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_dns_service.h" 28#include "gnunet_dns_service.h"
29#include "gnunet_dnsparser_lib.h" 29#include "gnunet_dnsparser_lib.h"
30#include "gnunet-service-gns.h"
30#include "gnunet-service-gns_resolver.h" 31#include "gnunet-service-gns_resolver.h"
31#include "gnunet-service-gns_interceptor.h" 32#include "gnunet-service-gns_interceptor.h"
32#include "gns.h" 33#include "gns.h"
@@ -73,11 +74,6 @@ struct InterceptLookupHandle
73static struct GNUNET_DNS_Handle *dns_handle; 74static struct GNUNET_DNS_Handle *dns_handle;
74 75
75/** 76/**
76 * Key of the zone we start lookups in.
77 */
78static struct GNUNET_CRYPTO_EcdsaPublicKey zone;
79
80/**
81 * Head of the DLL. 77 * Head of the DLL.
82 */ 78 */
83static struct InterceptLookupHandle *ilh_head; 79static struct InterceptLookupHandle *ilh_head;
@@ -298,6 +294,7 @@ handle_dns_request (void *cls,
298{ 294{
299 struct GNUNET_DNSPARSER_Packet *p; 295 struct GNUNET_DNSPARSER_Packet *p;
300 struct InterceptLookupHandle *ilh; 296 struct InterceptLookupHandle *ilh;
297 struct GNUNET_CRYPTO_EcdsaPublicKey zone;
301 298
302 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 299 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
303 "Hijacked a DNS request. Processing.\n"); 300 "Hijacked a DNS request. Processing.\n");
@@ -321,9 +318,9 @@ handle_dns_request (void *cls,
321 } 318 }
322 319
323 /* Check for GNS TLDs. */ 320 /* Check for GNS TLDs. */
324 if ( (GNUNET_YES == is_gnu_tld (p->queries[0].name)) || 321 if (GNUNET_YES ==
325 (GNUNET_YES == is_zkey_tld (p->queries[0].name)) || 322 GNS_find_tld (GNS_get_tld (p->queries[0].name),
326 (0 == strcmp (p->queries[0].name, GNUNET_GNS_TLD)) ) 323 &zone))
327 { 324 {
328 /* Start resolution in GNS */ 325 /* Start resolution in GNS */
329 ilh = GNUNET_new (struct InterceptLookupHandle); 326 ilh = GNUNET_new (struct InterceptLookupHandle);
@@ -351,17 +348,14 @@ handle_dns_request (void *cls,
351/** 348/**
352 * Initialized the interceptor 349 * Initialized the interceptor
353 * 350 *
354 * @param gnu_zone the zone to work in
355 * @param c the configuration 351 * @param c the configuration
356 * @return #GNUNET_OK on success 352 * @return #GNUNET_OK on success
357 */ 353 */
358int 354int
359GNS_interceptor_init (const struct GNUNET_CRYPTO_EcdsaPublicKey *gnu_zone, 355GNS_interceptor_init (const struct GNUNET_CONFIGURATION_Handle *c)
360 const struct GNUNET_CONFIGURATION_Handle *c)
361{ 356{
362 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 357 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
363 "DNS hijacking enabled. Connecting to DNS service.\n"); 358 "DNS hijacking enabled. Connecting to DNS service.\n");
364 zone = *gnu_zone;
365 dns_handle = GNUNET_DNS_connect (c, 359 dns_handle = GNUNET_DNS_connect (c,
366 GNUNET_DNS_FLAG_PRE_RESOLUTION, 360 GNUNET_DNS_FLAG_PRE_RESOLUTION,
367 &handle_dns_request, 361 &handle_dns_request,
@@ -386,7 +380,9 @@ GNS_interceptor_done ()
386 380
387 while (NULL != (ilh = ilh_head)) 381 while (NULL != (ilh = ilh_head))
388 { 382 {
389 GNUNET_CONTAINER_DLL_remove (ilh_head, ilh_tail, ilh); 383 GNUNET_CONTAINER_DLL_remove (ilh_head,
384 ilh_tail,
385 ilh);
390 GNS_resolver_lookup_cancel (ilh->lookup); 386 GNS_resolver_lookup_cancel (ilh->lookup);
391 GNUNET_DNS_request_drop (ilh->request_handle); 387 GNUNET_DNS_request_drop (ilh->request_handle);
392 GNUNET_DNSPARSER_free_packet (ilh->packet); 388 GNUNET_DNSPARSER_free_packet (ilh->packet);
diff --git a/src/gns/gnunet-service-gns_interceptor.h b/src/gns/gnunet-service-gns_interceptor.h
index 73d349854..ff54b7b6e 100644
--- a/src/gns/gnunet-service-gns_interceptor.h
+++ b/src/gns/gnunet-service-gns_interceptor.h
@@ -31,13 +31,11 @@
31/** 31/**
32 * Initialize DNS interceptor 32 * Initialize DNS interceptor
33 * 33 *
34 * @param gnu_zone the zone we start lookups in
35 * @param c the configuration 34 * @param c the configuration
36 * @return GNUNET_YES on success GNUNET_SYSERR on error 35 * @return #GNUNET_YES on success #GNUNET_SYSERR on error
37 */ 36 */
38int 37int
39GNS_interceptor_init (const struct GNUNET_CRYPTO_EcdsaPublicKey *gnu_zone, 38GNS_interceptor_init (const struct GNUNET_CONFIGURATION_Handle *c);
40 const struct GNUNET_CONFIGURATION_Handle *c);
41 39
42/** 40/**
43 * Stops the interceptor 41 * Stops the interceptor
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 533c0cada..ef191bbb3 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -37,6 +37,7 @@
37#include "gnunet_tun_lib.h" 37#include "gnunet_tun_lib.h"
38#include "gnunet_gns_service.h" 38#include "gnunet_gns_service.h"
39#include "gns.h" 39#include "gns.h"
40#include "gnunet-service-gns.h"
40#include "gnunet-service-gns_resolver.h" 41#include "gnunet-service-gns_resolver.h"
41#include "gnunet_vpn_service.h" 42#include "gnunet_vpn_service.h"
42 43
@@ -237,6 +238,10 @@ struct Gns2DnsContext
237 */ 238 */
238 struct GNS_ResolverHandle *rh; 239 struct GNS_ResolverHandle *rh;
239 240
241 /**
242 * Handle for DNS resolution of the DNS nameserver.
243 */
244 struct GNUNET_RESOLVER_RequestHandle *dns_rh;
240}; 245};
241 246
242 247
@@ -473,7 +478,7 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
473 * even though they consist of multiple labels. 478 * even though they consist of multiple labels.
474 * 479 *
475 * Examples: 480 * Examples:
476 * a.b.gnu = not canonical 481 * a.b.gnu = not canonical
477 * a = canonical 482 * a = canonical
478 * _foo._srv = canonical 483 * _foo._srv = canonical
479 * _f.bar = not canonical 484 * _f.bar = not canonical
@@ -481,18 +486,20 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
481 * @param name the name to test 486 * @param name the name to test
482 * @return #GNUNET_YES if canonical 487 * @return #GNUNET_YES if canonical
483 */ 488 */
484static int 489/* dead, but keep for now */ int
485is_canonical (const char *name) 490is_canonical (const char *name)
486{ 491{
487 const char *pos; 492 const char *pos;
488 const char *dot; 493 const char *dot;
489 494
490 if (NULL == strchr (name, '.')) 495 if (NULL == strchr (name,
496 (unsigned char) '.'))
491 return GNUNET_YES; 497 return GNUNET_YES;
492 if ('_' != name[0]) 498 if ('_' != name[0])
493 return GNUNET_NO; 499 return GNUNET_NO;
494 pos = &name[1]; 500 pos = &name[1];
495 while (NULL != (dot = strchr (pos, '.'))) 501 while (NULL != (dot = strchr (pos,
502 (unsigned char) '.')))
496 if ('_' != dot[1]) 503 if ('_' != dot[1])
497 return GNUNET_NO; 504 return GNUNET_NO;
498 else 505 else
@@ -857,11 +864,31 @@ dns_result_parser (void *cls,
857 (GNUNET_DNSPARSER_TYPE_CNAME == p->answers[0].type) && 864 (GNUNET_DNSPARSER_TYPE_CNAME == p->answers[0].type) &&
858 (GNUNET_DNSPARSER_TYPE_CNAME != rh->record_type) ) 865 (GNUNET_DNSPARSER_TYPE_CNAME != rh->record_type) )
859 { 866 {
867 int af;
868
860 GNUNET_free (rh->name); 869 GNUNET_free (rh->name);
861 rh->name = GNUNET_strdup (p->answers[0].data.hostname); 870 rh->name = GNUNET_strdup (p->answers[0].data.hostname);
862 rh->name_resolution_pos = strlen (rh->name); 871 rh->name_resolution_pos = strlen (rh->name);
863 rh->task_id = GNUNET_SCHEDULER_add_now (&start_resolver_lookup, 872 switch (rh->record_type)
864 rh); 873 {
874 case GNUNET_DNSPARSER_TYPE_A:
875 af = AF_INET;
876 break;
877 case GNUNET_DNSPARSER_TYPE_AAAA:
878 af = AF_INET6;
879 break;
880 default:
881 af = AF_UNSPEC;
882 break;
883 }
884 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
885 "Doing standard DNS lookup for `%s'\n",
886 rh->name);
887 rh->std_resolve = GNUNET_RESOLVER_ip_get (rh->name,
888 af,
889 DNS_LOOKUP_TIMEOUT,
890 &handle_dns_result,
891 rh);
865 GNUNET_DNSPARSER_free_packet (p); 892 GNUNET_DNSPARSER_free_packet (p);
866 return; 893 return;
867 } 894 }
@@ -944,9 +971,9 @@ dns_result_parser (void *cls,
944 buf_start = buf_off; 971 buf_start = buf_off;
945 if (GNUNET_OK != 972 if (GNUNET_OK !=
946 GNUNET_DNSPARSER_builder_add_soa (buf, 973 GNUNET_DNSPARSER_builder_add_soa (buf,
947 sizeof (buf), 974 sizeof (buf),
948 &buf_off, 975 &buf_off,
949 rec->data.soa)) 976 rec->data.soa))
950 { 977 {
951 GNUNET_break (0); 978 GNUNET_break (0);
952 skip++; 979 skip++;
@@ -997,7 +1024,9 @@ dns_result_parser (void *cls,
997 "Returning DNS response for `%s' with %u answers\n", 1024 "Returning DNS response for `%s' with %u answers\n",
998 rh->ac_tail->label, 1025 rh->ac_tail->label,
999 (unsigned int) p->num_answers); 1026 (unsigned int) p->num_answers);
1000 rh->proc (rh->proc_cls, rd_count - skip, rd); 1027 rh->proc (rh->proc_cls,
1028 rd_count - skip,
1029 rd);
1001 GNS_resolver_lookup_cancel (rh); 1030 GNS_resolver_lookup_cancel (rh);
1002 } 1031 }
1003 GNUNET_DNSPARSER_free_packet (p); 1032 GNUNET_DNSPARSER_free_packet (p);
@@ -1100,6 +1129,7 @@ handle_gns_cname_result (struct GNS_ResolverHandle *rh,
1100 size_t nlen; 1129 size_t nlen;
1101 char *res; 1130 char *res;
1102 struct AuthorityChain *ac; 1131 struct AuthorityChain *ac;
1132 int af;
1103 1133
1104 nlen = strlen (cname); 1134 nlen = strlen (cname);
1105 if ( (nlen > 2) && 1135 if ( (nlen > 2) &&
@@ -1139,12 +1169,30 @@ handle_gns_cname_result (struct GNS_ResolverHandle *rh,
1139 rh); 1169 rh);
1140 return; 1170 return;
1141 } 1171 }
1142 /* name is absolute, start from the beginning */ 1172 /* name is absolute, go to DNS */
1143 GNUNET_free (rh->name); 1173 GNUNET_free (rh->name);
1144 rh->name = GNUNET_strdup (cname); 1174 rh->name = GNUNET_strdup (cname);
1145 rh->name_resolution_pos = strlen (rh->name); 1175 rh->name_resolution_pos = strlen (rh->name);
1146 rh->task_id = GNUNET_SCHEDULER_add_now (&start_resolver_lookup, 1176 switch (rh->record_type)
1147 rh); 1177 {
1178 case GNUNET_DNSPARSER_TYPE_A:
1179 af = AF_INET;
1180 break;
1181 case GNUNET_DNSPARSER_TYPE_AAAA:
1182 af = AF_INET6;
1183 break;
1184 default:
1185 af = AF_UNSPEC;
1186 break;
1187 }
1188 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1189 "Doing standard DNS lookup for `%s'\n",
1190 rh->name);
1191 rh->std_resolve = GNUNET_RESOLVER_ip_get (rh->name,
1192 af,
1193 DNS_LOOKUP_TIMEOUT,
1194 &handle_dns_result,
1195 rh);
1148} 1196}
1149 1197
1150 1198
@@ -1247,7 +1295,6 @@ handle_gns2dns_result (void *cls,
1247{ 1295{
1248 struct GNS_ResolverHandle *rh = cls; 1296 struct GNS_ResolverHandle *rh = cls;
1249 struct AuthorityChain *ac; 1297 struct AuthorityChain *ac;
1250 unsigned int j;
1251 struct sockaddr *sa; 1298 struct sockaddr *sa;
1252 struct sockaddr_in v4; 1299 struct sockaddr_in v4;
1253 struct sockaddr_in6 v6; 1300 struct sockaddr_in6 v6;
@@ -1258,13 +1305,16 @@ handle_gns2dns_result (void *cls,
1258 "Received %u results for IP address of DNS server for GNS2DNS transition\n", 1305 "Received %u results for IP address of DNS server for GNS2DNS transition\n",
1259 rd_count); 1306 rd_count);
1260 /* enable cleanup of 'rh' handle that comes next... */ 1307 /* enable cleanup of 'rh' handle that comes next... */
1261 GNUNET_CONTAINER_DLL_insert (rlh_head, 1308 if (NULL != rh->g2dc->rh)
1262 rlh_tail, 1309 {
1263 rh->g2dc->rh); 1310 GNUNET_CONTAINER_DLL_insert (rlh_head,
1264 rh->g2dc->rh = NULL; 1311 rlh_tail,
1312 rh->g2dc->rh);
1313 rh->g2dc->rh = NULL;
1314 }
1265 sa = NULL; 1315 sa = NULL;
1266 sa_len = 0; 1316 sa_len = 0;
1267 for (j=0;j<rd_count;j++) 1317 for (unsigned int j=0;j<rd_count;j++)
1268 { 1318 {
1269 switch (rd[j].record_type) 1319 switch (rd[j].record_type)
1270 { 1320 {
@@ -1348,7 +1398,8 @@ handle_gns2dns_result (void *cls,
1348 rh->g2dc = NULL; 1398 rh->g2dc = NULL;
1349 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1399 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1350 "Will continue resolution using DNS server `%s' to resolve `%s'\n", 1400 "Will continue resolution using DNS server `%s' to resolve `%s'\n",
1351 GNUNET_a2s (sa, sa_len), 1401 GNUNET_a2s (sa,
1402 sa_len),
1352 ac->label); 1403 ac->label);
1353 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head, 1404 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head,
1354 rh->ac_tail, 1405 rh->ac_tail,
@@ -1369,6 +1420,69 @@ handle_gns2dns_result (void *cls,
1369 1420
1370 1421
1371/** 1422/**
1423 * Function called by the resolver for each address obtained from DNS.
1424 *
1425 * @param cls closure, a `struct Gns2DnsContext *`
1426 * @param addr one of the addresses of the host, NULL for the last address
1427 * @param addrlen length of @a addr
1428 */
1429static void
1430handle_gns2dns_ip (void *cls,
1431 const struct sockaddr *addr,
1432 socklen_t addrlen)
1433{
1434 struct Gns2DnsContext *g2dc = cls;
1435 struct GNUNET_GNSRECORD_Data rd;
1436
1437 if (NULL == addr)
1438 {
1439 /* DNS resolution failed */
1440 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1441 "Failed to use DNS to resolve name of DNS resolver\n");
1442 g2dc->rh->g2dc = NULL;
1443 fail_resolution (g2dc->rh);
1444 GNUNET_free (g2dc);
1445 }
1446 switch (addr->sa_family)
1447 {
1448 case AF_INET:
1449 {
1450 const struct sockaddr_in *v4 = (const struct sockaddr_in *) addr;
1451
1452 GNUNET_assert (sizeof (*v4) == addrlen);
1453 rd.data = v4;
1454 rd.data_size = sizeof (*v4);
1455 rd.expiration_time = UINT64_MAX;
1456 rd.record_type = GNUNET_DNSPARSER_TYPE_A;
1457 rd.flags = 0;
1458 break;
1459 }
1460 case AF_INET6:
1461 {
1462 const struct sockaddr_in6 *v6 = (const struct sockaddr_in6 *) addr;
1463
1464 GNUNET_assert (sizeof (*v6) == addrlen);
1465 rd.data = v6;
1466 rd.data_size = sizeof (v6);
1467 rd.expiration_time = UINT64_MAX;
1468 rd.record_type = GNUNET_DNSPARSER_TYPE_AAAA;
1469 rd.flags = 0;
1470 break;
1471 }
1472 default:
1473 return;
1474 }
1475 GNUNET_RESOLVER_request_cancel (g2dc->dns_rh);
1476 g2dc->dns_rh = NULL;
1477 handle_gns2dns_result (g2dc->rh,
1478 1,
1479 &rd);
1480
1481}
1482
1483
1484
1485/**
1372 * Process a records that were decrypted from a block. 1486 * Process a records that were decrypted from a block.
1373 * 1487 *
1374 * @param cls closure with the `struct GNS_ResolverHandle` 1488 * @param cls closure with the `struct GNS_ResolverHandle`
@@ -1513,7 +1627,7 @@ handle_gns_resolution_result (void *cls,
1513 rd_new[rd_off] = rd[i]; 1627 rd_new[rd_off] = rd[i];
1514 /* Check if the embedded name(s) end in "+", and if so, 1628 /* Check if the embedded name(s) end in "+", and if so,
1515 replace the "+" with the zone at "ac_tail", changing the name 1629 replace the "+" with the zone at "ac_tail", changing the name
1516 to a ".zkey". The name is allocated on the 'scratch' array, 1630 to a ".ZONEKEY". The name is allocated on the 'scratch' array,
1517 so we can free it afterwards. */ 1631 so we can free it afterwards. */
1518 switch (rd[i].record_type) 1632 switch (rd[i].record_type)
1519 { 1633 {
@@ -1760,7 +1874,9 @@ handle_gns_resolution_result (void *cls,
1760 "Returning GNS response for `%s' with %u answers\n", 1874 "Returning GNS response for `%s' with %u answers\n",
1761 rh->ac_tail->label, 1875 rh->ac_tail->label,
1762 rd_off); 1876 rd_off);
1763 rh->proc (rh->proc_cls, rd_off, rd_new); 1877 rh->proc (rh->proc_cls,
1878 rd_off,
1879 rd_new);
1764 GNS_resolver_lookup_cancel (rh); 1880 GNS_resolver_lookup_cancel (rh);
1765 return; 1881 return;
1766 } 1882 }
@@ -1804,6 +1920,10 @@ handle_gns_resolution_result (void *cls,
1804 struct Gns2DnsContext *g2dc; 1920 struct Gns2DnsContext *g2dc;
1805 char *ip; 1921 char *ip;
1806 char *ns; 1922 char *ns;
1923 const char *tld;
1924 struct GNUNET_CRYPTO_EcdsaPublicKey zone;
1925 struct in_addr v4;
1926 struct in6_addr v6;
1807 1927
1808 off = 0; 1928 off = 0;
1809 ns = GNUNET_DNSPARSER_parse_name (rd[i].data, 1929 ns = GNUNET_DNSPARSER_parse_name (rd[i].data,
@@ -1819,29 +1939,96 @@ handle_gns_resolution_result (void *cls,
1819 GNUNET_break_op (0); 1939 GNUNET_break_op (0);
1820 GNUNET_free_non_null (ns); 1940 GNUNET_free_non_null (ns);
1821 GNUNET_free_non_null (ip); 1941 GNUNET_free_non_null (ip);
1822 rh->proc (rh->proc_cls, 0, NULL); 1942 fail_resolution (rh);
1823 GNS_resolver_lookup_cancel (rh);
1824 return; 1943 return;
1825 } 1944 }
1826 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1827 "Resolving `%s' to determine IP address of DNS server for GNS2DNS transition\n",
1828 ip);
1829 /* resolve 'ip' to determine the IP(s) of the DNS 1945 /* resolve 'ip' to determine the IP(s) of the DNS
1830 resolver to use */ 1946 resolver to use for lookup of 'ns' */
1831 g2dc = GNUNET_new (struct Gns2DnsContext); 1947 g2dc = GNUNET_new (struct Gns2DnsContext);
1832 g2dc->ns = ns; 1948 g2dc->ns = ns;
1949 rh->g2dc = g2dc;
1950
1951 /* check if 'ip' is already an IPv4/IPv6 address */
1952 if (1 == inet_pton (AF_INET,
1953 ip,
1954 &v4))
1955 {
1956 /* name is IPv4 address, pretend it's an A record */
1957 struct GNUNET_GNSRECORD_Data rd;
1958
1959 GNUNET_free (ip);
1960 rd.data = &v4;
1961 rd.data_size = sizeof (v4);
1962 rd.expiration_time = UINT64_MAX;
1963 rd.record_type = GNUNET_DNSPARSER_TYPE_A;
1964 rd.flags = 0;
1965 handle_gns2dns_result (rh,
1966 1,
1967 &rd);
1968 return;
1969 }
1970 if (1 == inet_pton (AF_INET6,
1971 ip,
1972 &v6))
1973 {
1974 /* name is IPv6 address, pretend it's an AAAA record */
1975 struct GNUNET_GNSRECORD_Data rd;
1976
1977 GNUNET_free (ip);
1978 rd.data = &v6;
1979 rd.data_size = sizeof (v6);
1980 rd.expiration_time = UINT64_MAX;
1981 rd.record_type = GNUNET_DNSPARSER_TYPE_AAAA;
1982 rd.flags = 0;
1983 handle_gns2dns_result (rh,
1984 1,
1985 &rd);
1986 return;
1987 }
1833 1988
1989 tld = GNS_get_tld (ip);
1990 if (0 != strcmp (tld,
1991 "+"))
1992 {
1993 /* 'ip' is a DNS name */
1994 g2dc->dns_rh = GNUNET_RESOLVER_ip_get (ip,
1995 AF_UNSPEC,
1996 GNUNET_TIME_UNIT_FOREVER_REL,
1997 &handle_gns2dns_ip,
1998 g2dc);
1999 GNUNET_free (ip);
2000 return;
2001 }
2002
2003 /* 'ip' should be a GNS name */
1834 g2dc->rh = GNUNET_new (struct GNS_ResolverHandle); 2004 g2dc->rh = GNUNET_new (struct GNS_ResolverHandle);
1835 g2dc->rh->authority_zone = rh->ac_tail->authority_info.gns_authority; 2005
1836 ip = translate_dot_plus (rh, ip); 2006 ip = translate_dot_plus (rh,
2007 ip);
2008 tld = GNS_get_tld (ip);
2009 if (GNUNET_OK !=
2010 GNUNET_GNSRECORD_zkey_to_pkey (tld,
2011 &zone))
2012 {
2013 GNUNET_break_op (0);
2014 GNUNET_free_non_null (ns);
2015 GNUNET_free_non_null (ip);
2016 GNUNET_free (g2dc);
2017 fail_resolution (rh);
2018 return;
2019 }
2020 g2dc->rh->authority_zone = zone;
2021 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2022 "Resolving `%s' to determine IP address of DNS server for GNS2DNS transition for `%s'\n",
2023 ip,
2024 ns);
1837 g2dc->rh->name = ip; 2025 g2dc->rh->name = ip;
1838 g2dc->rh->name_resolution_pos = strlen (ip); 2026 g2dc->rh->name_resolution_pos = strlen (ip) - strlen (tld) - 1;
1839 g2dc->rh->proc = &handle_gns2dns_result; 2027 g2dc->rh->proc = &handle_gns2dns_result;
1840 g2dc->rh->proc_cls = rh; 2028 g2dc->rh->proc_cls = rh;
1841 g2dc->rh->record_type = GNUNET_GNSRECORD_TYPE_ANY; 2029 g2dc->rh->record_type = GNUNET_GNSRECORD_TYPE_ANY;
1842 g2dc->rh->options = GNUNET_GNS_LO_DEFAULT; 2030 g2dc->rh->options = GNUNET_GNS_LO_DEFAULT;
1843 g2dc->rh->loop_limiter = rh->loop_limiter + 1; 2031 g2dc->rh->loop_limiter = rh->loop_limiter + 1;
1844 rh->g2dc = g2dc;
1845 g2dc->rh->task_id 2032 g2dc->rh->task_id
1846 = GNUNET_SCHEDULER_add_now (&start_resolver_lookup, 2033 = GNUNET_SCHEDULER_add_now (&start_resolver_lookup,
1847 g2dc->rh); 2034 g2dc->rh);
@@ -2259,7 +2446,6 @@ start_resolver_lookup (void *cls)
2259{ 2446{
2260 struct GNS_ResolverHandle *rh = cls; 2447 struct GNS_ResolverHandle *rh = cls;
2261 struct AuthorityChain *ac; 2448 struct AuthorityChain *ac;
2262 char *y;
2263 struct in_addr v4; 2449 struct in_addr v4;
2264 struct in6_addr v6; 2450 struct in6_addr v6;
2265 2451
@@ -2296,66 +2482,14 @@ start_resolver_lookup (void *cls)
2296 GNS_resolver_lookup_cancel (rh); 2482 GNS_resolver_lookup_cancel (rh);
2297 return; 2483 return;
2298 } 2484 }
2299 if ( ( (GNUNET_YES == is_canonical (rh->name)) &&
2300 (0 != strcmp (GNUNET_GNS_TLD, rh->name)) ) ||
2301 ( (GNUNET_YES != is_gnu_tld (rh->name)) &&
2302 (GNUNET_YES != is_zkey_tld (rh->name)) ) )
2303 {
2304 /* use standard DNS lookup */
2305 int af;
2306 2485
2307 switch (rh->record_type)
2308 {
2309 case GNUNET_DNSPARSER_TYPE_A:
2310 af = AF_INET;
2311 break;
2312 case GNUNET_DNSPARSER_TYPE_AAAA:
2313 af = AF_INET6;
2314 break;
2315 default:
2316 af = AF_UNSPEC;
2317 break;
2318 }
2319 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2320 "Doing standard DNS lookup for `%s'\n",
2321 rh->name);
2322 rh->std_resolve = GNUNET_RESOLVER_ip_get (rh->name,
2323 af,
2324 DNS_LOOKUP_TIMEOUT,
2325 &handle_dns_result,
2326 rh);
2327 return;
2328 }
2329 if (is_zkey_tld (rh->name))
2330 {
2331 /* Name ends with ".zkey", try to replace authority zone with zkey
2332 authority */
2333 GNUNET_free (resolver_lookup_get_next_label (rh)); /* will return "zkey" */
2334 y = resolver_lookup_get_next_label (rh); /* will return 'y' coordinate */
2335 if ( (NULL == y) ||
2336 (GNUNET_OK !=
2337 GNUNET_CRYPTO_ecdsa_public_key_from_string (y,
2338 strlen (y),
2339 &rh->authority_zone)) )
2340 {
2341 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2342 _("Hostname `%s' is not well-formed, resolution fails\n"),
2343 rh->name);
2344 rh->task_id = GNUNET_SCHEDULER_add_now (&fail_resolution, rh);
2345 }
2346 GNUNET_free_non_null (y);
2347 }
2348 else
2349 {
2350 /* Name ends with ".gnu", eat ".gnu" and continue with resolution */
2351 GNUNET_free (resolver_lookup_get_next_label (rh));
2352 }
2353 ac = GNUNET_new (struct AuthorityChain); 2486 ac = GNUNET_new (struct AuthorityChain);
2354 ac->rh = rh; 2487 ac->rh = rh;
2355 ac->label = resolver_lookup_get_next_label (rh); 2488 ac->label = resolver_lookup_get_next_label (rh);
2356 ac->suggested_shortening_label = NULL; 2489 ac->suggested_shortening_label = NULL;
2357 if (NULL == ac->label) 2490 if (NULL == ac->label)
2358 /* name was just "gnu", so we default to label '+' */ 2491 /* name was just the "TLD", so we default to label
2492 #GNUNET_GNS_MASTERZONE_STR */
2359 ac->label = GNUNET_strdup (GNUNET_GNS_MASTERZONE_STR); 2493 ac->label = GNUNET_strdup (GNUNET_GNS_MASTERZONE_STR);
2360 ac->gns_authority = GNUNET_YES; 2494 ac->gns_authority = GNUNET_YES;
2361 ac->authority_info.gns_authority = rh->authority_zone; 2495 ac->authority_info.gns_authority = rh->authority_zone;
@@ -2446,6 +2580,11 @@ GNS_resolver_lookup_cancel (struct GNS_ResolverHandle *rh)
2446 GNS_resolver_lookup_cancel (rh->g2dc->rh); 2580 GNS_resolver_lookup_cancel (rh->g2dc->rh);
2447 rh->g2dc->rh = NULL; 2581 rh->g2dc->rh = NULL;
2448 } 2582 }
2583 if (NULL != rh->g2dc->dns_rh)
2584 {
2585 GNUNET_RESOLVER_request_cancel (rh->g2dc->dns_rh);
2586 rh->g2dc->rh = NULL;
2587 }
2449 GNUNET_free (rh->g2dc->ns); 2588 GNUNET_free (rh->g2dc->ns);
2450 GNUNET_free (rh->g2dc); 2589 GNUNET_free (rh->g2dc);
2451 rh->g2dc = NULL; 2590 rh->g2dc = NULL;
@@ -2588,28 +2727,4 @@ GNS_resolver_done ()
2588} 2727}
2589 2728
2590 2729
2591/* *************** common helper functions (do not really belong here) *********** */
2592
2593/**
2594 * Checks if @a name ends in ".TLD"
2595 *
2596 * @param name the name to check
2597 * @param tld the TLD to check for
2598 * @return #GNUNET_YES or #GNUNET_NO
2599 */
2600int
2601is_tld (const char* name,
2602 const char* tld)
2603{
2604 size_t offset = 0;
2605
2606 if (strlen (name) <= strlen (tld))
2607 return GNUNET_NO;
2608 offset = strlen (name) - strlen (tld);
2609 if (0 != strcmp (name + offset, tld))
2610 return GNUNET_NO;
2611 return GNUNET_YES;
2612}
2613
2614
2615/* end of gnunet-service-gns_resolver.c */ 2730/* end of gnunet-service-gns_resolver.c */
diff --git a/src/gns/gnunet-service-gns_resolver.h b/src/gns/gnunet-service-gns_resolver.h
index c71d3983d..06ecc51ce 100644
--- a/src/gns/gnunet-service-gns_resolver.h
+++ b/src/gns/gnunet-service-gns_resolver.h
@@ -100,25 +100,4 @@ GNS_resolver_lookup (const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
100void 100void
101GNS_resolver_lookup_cancel (struct GNS_ResolverHandle *rh); 101GNS_resolver_lookup_cancel (struct GNS_ResolverHandle *rh);
102 102
103
104/**
105 * Generic function to check for TLDs. Checks if "name" ends in ".tld"
106 *
107 * @param name the name to check
108 * @param tld the tld to check
109 * @return #GNUNET_YES or #GNUNET_NO
110 */
111int
112is_tld (const char *name,
113 const char *tld);
114
115
116
117/**
118 * Checks for gnu/zkey
119 */
120#define is_gnu_tld(name) is_tld(name, GNUNET_GNS_TLD)
121#define is_zkey_tld(name) is_tld(name, GNUNET_GNS_TLD_ZKEY)
122
123
124#endif 103#endif
diff --git a/src/gns/test_gns_cname_lookup.sh b/src/gns/test_gns_cname_lookup.sh
index 789c7f30b..d9627850f 100755
--- a/src/gns/test_gns_cname_lookup.sh
+++ b/src/gns/test_gns_cname_lookup.sh
@@ -24,8 +24,6 @@ fi
24 24
25rm -rf /tmp/test-gnunet-gns-peer-1/ 25rm -rf /tmp/test-gnunet-gns-peer-1/
26 26
27TEST_DOMAIN_PLUS="www.gnu"
28TEST_DOMAIN_DNS="www3.gnu"
29TEST_IP_PLUS="127.0.0.1" 27TEST_IP_PLUS="127.0.0.1"
30TEST_IP_DNS="131.159.74.67" 28TEST_IP_DNS="131.159.74.67"
31TEST_RECORD_CNAME_SERVER="server" 29TEST_RECORD_CNAME_SERVER="server"
@@ -34,35 +32,38 @@ TEST_RECORD_CNAME_DNS="gnunet.org"
34TEST_RECORD_NAME_SERVER="server" 32TEST_RECORD_NAME_SERVER="server"
35TEST_RECORD_NAME_PLUS="www" 33TEST_RECORD_NAME_PLUS="www"
36TEST_RECORD_NAME_DNS="www3" 34TEST_RECORD_NAME_DNS="www3"
35MY_EGO="myego"
36TEST_DOMAIN_PLUS="www.$MY_EGO"
37TEST_DOMAIN_DNS="www3.$MY_EGO"
37which timeout &> /dev/null && DO_TIMEOUT="timeout 15" 38which timeout &> /dev/null && DO_TIMEOUT="timeout 15"
38 39
39gnunet-arm -s -c test_gns_lookup.conf 40gnunet-arm -s -c test_gns_lookup.conf
40gnunet-identity -C testego -c test_gns_lookup.conf 41gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
41gnunet-namestore -p -z testego -a -n $TEST_RECORD_NAME_DNS -t CNAME -V $TEST_RECORD_CNAME_DNS -e never -c test_gns_lookup.conf 42gnunet-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
42gnunet-namestore -p -z testego -a -n $TEST_RECORD_NAME_PLUS -t CNAME -V $TEST_RECORD_CNAME_PLUS -e never -c test_gns_lookup.conf 43gnunet-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
43gnunet-namestore -p -z testego -a -n $TEST_RECORD_CNAME_SERVER -t A -V $TEST_IP_PLUS -e never -c test_gns_lookup.conf 44gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_CNAME_SERVER -t A -V $TEST_IP_PLUS -e never -c test_gns_lookup.conf
44RES_CNAME=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_DOMAIN_PLUS -t A -c test_gns_lookup.conf` 45RES_CNAME=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t A -c test_gns_lookup.conf`
45RES_CNAME_RAW=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_DOMAIN_PLUS -t CNAME -c test_gns_lookup.conf` 46RES_CNAME_RAW=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t CNAME -c test_gns_lookup.conf`
46RES_CNAME_DNS=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_DOMAIN_DNS -t A -c test_gns_lookup.conf` 47RES_CNAME_DNS=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_DNS -t A -c test_gns_lookup.conf`
47TESTEGOZONE=`gnunet-identity -c test_gns_lookup.conf -d | awk '{print $3}'` 48TESTEGOZONE=`gnunet-identity -c test_gns_lookup.conf -d | awk '{print $3}'`
48gnunet-namestore -p -z testego -d -n $TEST_RECORD_NAME_DNS -t CNAME -V $TEST_RECORD_CNAME_DNS -e never -c test_gns_lookup.conf 49gnunet-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
49gnunet-namestore -p -z testego -d -n $TEST_RECORD_NAME_PLUS -t CNAME -V $TEST_RECORD_CNAME_PLUS -e never -c test_gns_lookup.conf 50gnunet-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
50gnunet-namestore -p -z testego -d -n $TEST_RECORD_CNAME_SERVER -t A -V $TEST_IP_PLUS -e never -c test_gns_lookup.conf 51gnunet-namestore -p -z $MY_EGO -d -n $TEST_RECORD_CNAME_SERVER -t A -V $TEST_IP_PLUS -e never -c test_gns_lookup.conf
51gnunet-identity -D testego -c test_gns_lookup.conf 52gnunet-identity -D $MY_EGO -c test_gns_lookup.conf
52gnunet-arm -e -c test_gns_lookup.conf 53gnunet-arm -e -c test_gns_lookup.conf
53rm -rf /tmp/test-gnunet-gns-peer-1/ 54rm -rf /tmp/test-gnunet-gns-peer-1/
54 55
55if [ "$RES_CNAME_RAW" == "server.$TESTEGOZONE.zkey" ] 56if [ "$RES_CNAME_RAW" == "server.$TESTEGOZONE" ]
56then 57then
57 echo "PASS: CNAME resulution from GNS" 58 echo "PASS: CNAME resolution from GNS"
58else 59else
59 echo "FAIL: CNAME resolution from GNS, got $RES_CNAME_RAW, expected server.$TESTEGOZONE.zkey." 60 echo "FAIL: CNAME resolution from GNS, got $RES_CNAME_RAW, expected server.$TESTEGOZONE."
60 exit 1 61 exit 1
61fi 62fi
62 63
63if [ "$RES_CNAME" == "$TEST_IP_PLUS" ] 64if [ "$RES_CNAME" == "$TEST_IP_PLUS" ]
64then 65then
65 echo "PASS: IP resulution from GNS" 66 echo "PASS: IP resolution from GNS"
66else 67else
67 echo "FAIL: IP resolution from GNS, got $RES_CNAME, expected $TEST_IP_PLUS." 68 echo "FAIL: IP resolution from GNS, got $RES_CNAME, expected $TEST_IP_PLUS."
68 exit 1 69 exit 1
@@ -70,9 +71,9 @@ fi
70 71
71if [ "$RES_CNAME_DNS" == "$TEST_IP_DNS" ] 72if [ "$RES_CNAME_DNS" == "$TEST_IP_DNS" ]
72then 73then
73 echo "PASS: IP resulution from DNS" 74 echo "PASS: IP resolution from DNS"
74 exit 0 75 exit 0
75else 76else
76 echo "FAIL: IP resulution from DNS, got $RES_IP, expected $TEST_IP_DNS." 77 echo "FAIL: IP resolution from DNS, got $RES_IP, expected $TEST_IP_DNS."
77 exit 1 78 exit 1
78fi 79fi
diff --git a/src/gns/test_gns_delegated_lookup.sh b/src/gns/test_gns_delegated_lookup.sh
index 3826d3e32..edda688ff 100755
--- a/src/gns/test_gns_delegated_lookup.sh
+++ b/src/gns/test_gns_delegated_lookup.sh
@@ -10,22 +10,26 @@ fi
10$LOCATION --version 1> /dev/null 10$LOCATION --version 1> /dev/null
11if test $? != 0 11if test $? != 0
12then 12then
13 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" 13 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
14 exit 77 14 exit 77
15fi 15fi
16 16
17rm -rf /tmp/test-gnunet-gns-peer-1/ 17rm -rf /tmp/test-gnunet-gns-peer-1/
18MY_EGO="myego"
19OTHER_EGO="delegatedego"
20FINAL_LABEL="www"
21DELEGATION_LABEL="b"
18 22
19TEST_IP="127.0.0.1" 23TEST_IP="127.0.0.1"
20gnunet-arm -s -c test_gns_lookup.conf 24gnunet-arm -s -c test_gns_lookup.conf
21gnunet-identity -C delegatedego -c test_gns_lookup.conf 25gnunet-identity -C $OTHER_EGO -c test_gns_lookup.conf
22DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}') 26DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep $OTHER_EGO | awk '{print $3}')
23gnunet-identity -C testego -c test_gns_lookup.conf 27gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
24gnunet-namestore -p -z testego -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf 28gnunet-namestore -p -z $MY_EGO -a -n $DELEGATION_LABEL -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf
25gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf 29gnunet-namestore -p -z $OTHER_EGO -a -n $FINAL_LABEL -t A -V $TEST_IP -e never -c test_gns_lookup.conf
26RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.b.gnu -t A -c test_gns_lookup.conf` 30RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u $FINAL_LABEL.$DELEGATION_LABEL.$MY_EGO -t A -c test_gns_lookup.conf`
27gnunet-namestore -z testego -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf 31gnunet-namestore -z $MY_EGO -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf
28gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf 32gnunet-namestore -z $OTHER_EGO -d -n $FINAL_LABEL -t A -V $TEST_IP -e never -c test_gns_lookup.conf
29gnunet-arm -e -c test_gns_lookup.conf 33gnunet-arm -e -c test_gns_lookup.conf
30 34
31rm -rf /tmp/test-gnunet-gns-peer-1/ 35rm -rf /tmp/test-gnunet-gns-peer-1/
diff --git a/src/gns/test_gns_dht_lookup.sh b/src/gns/test_gns_dht_lookup.sh
index a6e4acc77..365c77339 100755
--- a/src/gns/test_gns_dht_lookup.sh
+++ b/src/gns/test_gns_dht_lookup.sh
@@ -10,22 +10,26 @@ fi
10$LOCATION --version 1> /dev/null 10$LOCATION --version 1> /dev/null
11if test $? != 0 11if test $? != 0
12then 12then
13 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" 13 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
14 exit 77 14 exit 77
15fi 15fi
16 16
17TEST_IP="127.0.0.1" 17TEST_IP="127.0.0.1"
18MY_EGO="myego"
19OTHER_EGO="delegatedego"
20
21
18gnunet-arm -s -c test_gns_lookup.conf 22gnunet-arm -s -c test_gns_lookup.conf
19gnunet-identity -C delegatedego -c test_gns_lookup.conf 23gnunet-identity -C $OTHER_EGO -c test_gns_lookup.conf
20DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}') 24DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep $OTHER_EGO | awk '{print $3}')
21gnunet-identity -C testego -c test_gns_lookup.conf 25gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
22gnunet-namestore -p -z testego -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf 26gnunet-namestore -p -z $MY_EGO -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf
23gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf 27gnunet-namestore -p -z $OTHER_EGO -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf
24gnunet-arm -i gns -c test_gns_lookup.conf 28gnunet-arm -i gns -c test_gns_lookup.conf
25sleep 0.5 29sleep 0.5
26gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf 30gnunet-namestore -z $OTHER_EGO -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf
27RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.b.gnu -t A -c test_gns_lookup.conf` 31RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.b.$MY_EGO -t A -c test_gns_lookup.conf`
28gnunet-namestore -z testego -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf 32gnunet-namestore -z $MY_EGO -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf
29gnunet-arm -e -c test_gns_lookup.conf 33gnunet-arm -e -c test_gns_lookup.conf
30rm -rf /tmp/test-gnunet-gns-peer-1/ 34rm -rf /tmp/test-gnunet-gns-peer-1/
31 35
diff --git a/src/gns/test_gns_gns2dns_lookup.sh b/src/gns/test_gns_gns2dns_lookup.sh
index f7299a57d..921d9594d 100755
--- a/src/gns/test_gns_gns2dns_lookup.sh
+++ b/src/gns/test_gns_gns2dns_lookup.sh
@@ -25,10 +25,6 @@ TEST_IP_GNS2DNS="8.8.8.8"
25 25
26# main label used during resolution 26# main label used during resolution
27TEST_RECORD_NAME="homepage" 27TEST_RECORD_NAME="homepage"
28# various names we will use for resolution
29TEST_DOMAIN="www.${TEST_RECORD_NAME}.gnu"
30TEST_DOMAIN_ALT="${TEST_RECORD_NAME}.gnu"
31TEST_DOMAIN_ALT2="uk.${TEST_RECORD_NAME}.gnu"
32 28
33if ! nslookup gnunet.org $TEST_IP_GNS2DNS &> /dev/null 29if ! nslookup gnunet.org $TEST_IP_GNS2DNS &> /dev/null
34then 30then
@@ -42,29 +38,39 @@ TEST_RESOLVER_LABEL="resolver"
42# using the TEST_RESOLVER_LABEL DNS server for resolution 38# using the TEST_RESOLVER_LABEL DNS server for resolution
43TEST_RECORD_GNS2DNS="gnunet.org@${TEST_RESOLVER_LABEL}.+" 39TEST_RECORD_GNS2DNS="gnunet.org@${TEST_RESOLVER_LABEL}.+"
44 40
41MY_EGO="myego"
42# various names we will use for resolution
43TEST_DOMAIN="www.${TEST_RECORD_NAME}.$MY_EGO"
44TEST_DOMAIN_ALT="${TEST_RECORD_NAME}.$MY_EGO"
45TEST_DOMAIN_ALT2="uk.${TEST_RECORD_NAME}.$MY_EGO"
46
47
45gnunet-arm -s -c test_gns_lookup.conf 48gnunet-arm -s -c test_gns_lookup.conf
46gnunet-identity -C testego -c test_gns_lookup.conf 49gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
47 50
48# set IP address for DNS resolver for resolving in gnunet.org domain 51# set IP address for DNS resolver for resolving in gnunet.org domain
49gnunet-namestore -p -z testego -a -n $TEST_RESOLVER_LABEL -t A -V $TEST_IP_GNS2DNS -e never -c test_gns_lookup.conf 52gnunet-namestore -p -z $MY_EGO -a -n $TEST_RESOLVER_LABEL -t A -V $TEST_IP_GNS2DNS -e never -c test_gns_lookup.conf
50# map 'homepage.gnu' to 'gnunet.org' in DNS 53# map '$TEST_RECORD_NAME.$MY_EGO' to 'gnunet.org' in DNS
51gnunet-namestore -p -z testego -a -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS -e never -c test_gns_lookup.conf 54gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS -e never -c test_gns_lookup.conf
52 55
53which timeout &> /dev/null && DO_TIMEOUT="timeout 15" 56which timeout &> /dev/null && DO_TIMEOUT="timeout 15"
54 57
58echo "EGOs:"
59gnunet-identity -d
60
55# lookup 'www.gnunet.org', IPv4 61# lookup 'www.gnunet.org', IPv4
56RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_DOMAIN -t A -c test_gns_lookup.conf` 62RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t A -c test_gns_lookup.conf`
57# lookup 'www.gnunet.org', IPv6 63# lookup 'www.gnunet.org', IPv6
58RES_IP6=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_DOMAIN -t AAAA -c test_gns_lookup.conf` 64RES_IP6=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t AAAA -c test_gns_lookup.conf`
59# lookup 'gnunet.org', IPv4 65# lookup 'gnunet.org', IPv4
60RES_IP_ALT=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_DOMAIN_ALT -t A -c test_gns_lookup.conf` 66RES_IP_ALT=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_ALT -t A -c test_gns_lookup.conf`
61# lookup 'uk.gnunet.org', IPv4 67# lookup 'uk.gnunet.org', IPv4
62RES_IP_ALT2=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_DOMAIN_ALT2 -t A -c test_gns_lookup.conf` 68RES_IP_ALT2=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_ALT2 -t A -c test_gns_lookup.conf`
63 69
64# clean up 70# clean up
65gnunet-namestore -z testego -d -n $TEST_RESOLVER_LABEL -t A -V $TEST_IP_GNS2DNS -e never -c test_gns_lookup.conf 71gnunet-namestore -z $MY_EGO -d -n $TEST_RESOLVER_LABEL -t A -V $TEST_IP_GNS2DNS -e never -c test_gns_lookup.conf
66gnunet-namestore -z testego -d -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS -e never -c test_gns_lookup.conf 72gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS -e never -c test_gns_lookup.conf
67gnunet-identity -D testego -c test_gns_lookup.conf 73gnunet-identity -D $MY_EGO -c test_gns_lookup.conf
68gnunet-arm -e -c test_gns_lookup.conf 74gnunet-arm -e -c test_gns_lookup.conf
69rm -rf /tmp/test-gnunet-gns-peer-1/ 75rm -rf /tmp/test-gnunet-gns-peer-1/
70 76
diff --git a/src/gns/test_gns_ipv6_lookup.sh b/src/gns/test_gns_ipv6_lookup.sh
index f34a76727..118c23060 100755
--- a/src/gns/test_gns_ipv6_lookup.sh
+++ b/src/gns/test_gns_ipv6_lookup.sh
@@ -12,16 +12,17 @@ then
12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" 12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
13 exit 77 13 exit 77
14fi 14fi
15MY_EGO="myego"
15 16
16rm -rf `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f` 17rm -rf `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f`
17which timeout &> /dev/null && DO_TIMEOUT="timeout 30" 18which timeout &> /dev/null && DO_TIMEOUT="timeout 30"
18TEST_IP="dead::beef" 19TEST_IP="dead::beef"
19gnunet-arm -s -c test_gns_lookup.conf 20gnunet-arm -s -c test_gns_lookup.conf
20gnunet-identity -C testego -c test_gns_lookup.conf 21gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
21gnunet-namestore -p -z testego -a -n www -t AAAA -V $TEST_IP -e never -c test_gns_lookup.conf 22gnunet-namestore -p -z $MY_EGO -a -n www -t AAAA -V $TEST_IP -e never -c test_gns_lookup.conf
22RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.gnu -t AAAA -c test_gns_lookup.conf` 23RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.$MY_EGO -t AAAA -c test_gns_lookup.conf`
23gnunet-namestore -z testego -d -n www -t AAAA -V $TEST_IP -e never -c test_gns_lookup.conf 24gnunet-namestore -z $MY_EGO -d -n www -t AAAA -V $TEST_IP -e never -c test_gns_lookup.conf
24gnunet-identity -D testego -c test_gns_lookup.conf 25gnunet-identity -D $MY_EGO -c test_gns_lookup.conf
25gnunet-arm -e -c test_gns_lookup.conf 26gnunet-arm -e -c test_gns_lookup.conf
26rm -rf /tmp/test-gnunet-gns-peer-1/ 27rm -rf /tmp/test-gnunet-gns-peer-1/
27 28
diff --git a/src/gns/test_gns_lookup.sh b/src/gns/test_gns_lookup.sh
index ddee5b78d..79558afae 100755
--- a/src/gns/test_gns_lookup.sh
+++ b/src/gns/test_gns_lookup.sh
@@ -16,12 +16,14 @@ fi
16rm -rf `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f` 16rm -rf `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f`
17which timeout &> /dev/null && DO_TIMEOUT="timeout 30" 17which timeout &> /dev/null && DO_TIMEOUT="timeout 30"
18TEST_IP="127.0.0.1" 18TEST_IP="127.0.0.1"
19MY_EGO="myego"
20LABEL="www"
19gnunet-arm -s -c test_gns_lookup.conf 21gnunet-arm -s -c test_gns_lookup.conf
20gnunet-identity -C testego -c test_gns_lookup.conf 22gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
21gnunet-namestore -p -z testego -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf 23gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t A -V $TEST_IP -e never -c test_gns_lookup.conf
22RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.gnu -t A -c test_gns_lookup.conf` 24RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$MY_EGO -t A -c test_gns_lookup.conf`
23gnunet-namestore -z testego -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf 25gnunet-namestore -z $MY_EGO -d -n $LABEL -t A -V $TEST_IP -e never -c test_gns_lookup.conf
24gnunet-identity -D testego -c test_gns_lookup.conf 26gnunet-identity -D $MY_EGO -c test_gns_lookup.conf
25gnunet-arm -e -c test_gns_lookup.conf 27gnunet-arm -e -c test_gns_lookup.conf
26 28
27if [ "$RES_IP" == "$TEST_IP" ] 29if [ "$RES_IP" == "$TEST_IP" ]
diff --git a/src/gns/test_gns_mx_lookup.sh b/src/gns/test_gns_mx_lookup.sh
index f8cea2d0f..8abc9f509 100755
--- a/src/gns/test_gns_mx_lookup.sh
+++ b/src/gns/test_gns_mx_lookup.sh
@@ -16,21 +16,24 @@ fi
16rm -rf /tmp/test-gnunet-gns-peer-1/ 16rm -rf /tmp/test-gnunet-gns-peer-1/
17which timeout &> /dev/null && DO_TIMEOUT="timeout 5" 17which timeout &> /dev/null && DO_TIMEOUT="timeout 5"
18 18
19TEST_MX="5,mail.gnu" 19MY_EGO="myego"
20TEST_MX="5,mail.+"
20gnunet-arm -s -c test_gns_lookup.conf 21gnunet-arm -s -c test_gns_lookup.conf
21gnunet-identity -C testego -c test_gns_lookup.conf 22gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
22gnunet-namestore -p -z testego -a -n www -t MX -V "$TEST_MX" -e never -c test_gns_lookup.conf 23PKEY=`gnunet-identity -d | grep "$MY_EGO - " | awk '{print $3'}`
24WANT_MX="5,mail.$PKEY"
25gnunet-namestore -p -z $MY_EGO -a -n www -t MX -V "$TEST_MX" -e never -c test_gns_lookup.conf
23 26
24RES_MX=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.gnu -t MX -c test_gns_lookup.conf` 27RES_MX=`$DO_TIMEOUT gnunet-gns --raw -u www.$MY_EGO -t MX -c test_gns_lookup.conf`
25gnunet-namestore -z testego -d -n www -t MX -V "$TEST_MX" -e never -c test_gns_lookup.conf 28gnunet-namestore -z $MY_EGO -d -n www -t MX -V "$TEST_MX" -e never -c test_gns_lookup.conf
26gnunet-identity -D testego -c test_gns_lookup.conf 29gnunet-identity -D $MY_EGO -c test_gns_lookup.conf
27gnunet-arm -e -c test_gns_lookup.conf 30gnunet-arm -e -c test_gns_lookup.conf
28rm -rf /tmp/test-gnunet-gns-peer-1/ 31rm -rf /tmp/test-gnunet-gns-peer-1/
29 32
30if [ "$RES_MX" == "$TEST_MX" ] 33if [ "$RES_MX" == "$WANT_MX" ]
31then 34then
32 exit 0 35 exit 0
33else 36else
34 echo "FAIL: did not get proper IP, got $RES_MX." 37 echo "FAIL: did not get proper IP, got $RES_MX, expected $WANT_MX."
35 exit 1 38 exit 1
36fi 39fi
diff --git a/src/gns/test_gns_plus_lookup.sh b/src/gns/test_gns_plus_lookup.sh
index a6a9e8da4..4cf7a8855 100755
--- a/src/gns/test_gns_plus_lookup.sh
+++ b/src/gns/test_gns_plus_lookup.sh
@@ -17,14 +17,15 @@ which timeout &> /dev/null && DO_TIMEOUT="timeout 5"
17rm -rf /tmp/test-gnunet-gns-peer-1/ 17rm -rf /tmp/test-gnunet-gns-peer-1/
18 18
19TEST_IP="127.0.0.1" 19TEST_IP="127.0.0.1"
20MY_EGO="myego"
20gnunet-arm -s -c test_gns_lookup.conf 21gnunet-arm -s -c test_gns_lookup.conf
21gnunet-identity -C delegatedego -c test_gns_lookup.conf 22gnunet-identity -C delegatedego -c test_gns_lookup.conf
22DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}') 23DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}')
23gnunet-identity -C testego -c test_gns_lookup.conf 24gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
24gnunet-namestore -p -z testego -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf 25gnunet-namestore -p -z $MY_EGO -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf
25gnunet-namestore -p -z delegatedego -a -n '+' -t A -V $TEST_IP -e never -c test_gns_lookup.conf 26gnunet-namestore -p -z delegatedego -a -n '+' -t A -V $TEST_IP -e never -c test_gns_lookup.conf
26RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u b.gnu -t A -c test_gns_lookup.conf` 27RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u b.$MY_EGO -t A -c test_gns_lookup.conf`
27gnunet-namestore -z testego -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf 28gnunet-namestore -z $MY_EGO -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf
28gnunet-namestore -z delegatedego -d -n '+' -t A -V $TEST_IP -e never -c test_gns_lookup.conf 29gnunet-namestore -z delegatedego -d -n '+' -t A -V $TEST_IP -e never -c test_gns_lookup.conf
29gnunet-arm -e -c test_gns_lookup.conf 30gnunet-arm -e -c test_gns_lookup.conf
30rm -rf /tmp/test-gnunet-gns-peer-1/ 31rm -rf /tmp/test-gnunet-gns-peer-1/
diff --git a/src/gns/test_gns_quickupdate.sh b/src/gns/test_gns_quickupdate.sh
index d58a2712c..5606491e4 100755
--- a/src/gns/test_gns_quickupdate.sh
+++ b/src/gns/test_gns_quickupdate.sh
@@ -9,41 +9,49 @@ fi
9$LOCATION --version 1> /dev/null 9$LOCATION --version 1> /dev/null
10if test $? != 0 10if test $? != 0
11then 11then
12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" 12 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
13 exit 77 13 exit 77
14fi 14fi
15 15
16MY_EGO="myego"
17OTHER_EGO="delegatedego"
18
19
16rm -rf /tmp/test-gnunet-gns-peer-1/ 20rm -rf /tmp/test-gnunet-gns-peer-1/
17which timeout &> /dev/null && DO_TIMEOUT="timeout 5" 21which timeout &> /dev/null && DO_TIMEOUT="timeout 5"
18TEST_IP="127.0.0.1" 22TEST_IP="127.0.0.1"
19gnunet-arm -s -c test_gns_lookup.conf 23gnunet-arm -s -c test_gns_lookup.conf
20gnunet-identity -C testego -c test_gns_lookup.conf 24gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
21gnunet-identity -C delegatedego -c test_gns_lookup.conf 25gnunet-identity -C $OTHER_EGO -c test_gns_lookup.conf
22DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}') 26DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep $OTHER_EGO | awk '{print $3}')
23gnunet-arm -i gns -c test_gns_lookup.conf 27gnunet-arm -i gns -c test_gns_lookup.conf
24gnunet-namestore -p -z testego -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf 28gnunet-namestore -p -z $MY_EGO -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf
25# Give GNS/namestore time to fully start and finish initial iteration 29# Give GNS/namestore time to fully start and finish initial iteration
26sleep 2 30sleep 2
27# Performing namestore update 31# Performing namestore update
28gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf 32gnunet-namestore -p -z $OTHER_EGO -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf
29# Give GNS chance to observe store event via monitor 33# Give GNS chance to observe store event via monitor
30sleep 1 34sleep 1
31gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf 35gnunet-namestore -z $OTHER_EGO -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf
32# give GNS chance to process monitor event 36# give GNS chance to process monitor event
33sleep 1 37sleep 1
34# stop everything and restart to check that DHT PUT did happen 38# stop everything and restart to check that DHT PUT did happen
35gnunet-arm -k gns -c test_gns_lookup.conf 39gnunet-arm -k gns -c test_gns_lookup.conf
36gnunet-arm -k namestore -c test_gns_lookup.conf 40gnunet-arm -k namestore -c test_gns_lookup.conf
37gnunet-arm -k namecache -c test_gns_lookup.conf 41gnunet-arm -k namecache -c test_gns_lookup.conf
42gnunet-arm -k zonemaster -c test_gns_lookup.conf
38# Purge nameacache, as we might otherwise fetch from there 43# Purge nameacache, as we might otherwise fetch from there
39rm -r `gnunet-config -c test_gns_lookup.conf -s namecache-sqlite -o FILENAME` 44# FIXME: testcase started failing after the line below was fixed by adding '-f',
45# might have never worked (!)
46rm -r `gnunet-config -f -c test_gns_lookup.conf -s namecache-sqlite -o FILENAME`
40gnunet-arm -i namestore -c test_gns_lookup.conf 47gnunet-arm -i namestore -c test_gns_lookup.conf
41gnunet-arm -i namecache -c test_gns_lookup.conf 48gnunet-arm -i namecache -c test_gns_lookup.conf
49gnunet-arm -i zonemaster -c test_gns_lookup.conf
42gnunet-arm -i gns -c test_gns_lookup.conf 50gnunet-arm -i gns -c test_gns_lookup.conf
43RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.b.gnu -t A -c test_gns_lookup.conf` 51RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.b.$MY_EGO -t A -c test_gns_lookup.conf`
44gnunet-namestore -z testego -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf 52gnunet-namestore -z $MY_EGO -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf
45gnunet-identity -D testego -c test_gns_lookup.conf 53gnunet-identity -D $MY_EGO -c test_gns_lookup.conf
46gnunet-identity -D delegatedego -c test_gns_lookup.conf 54gnunet-identity -D $OTHER_EGO -c test_gns_lookup.conf
47gnunet-arm -e -c test_gns_lookup.conf 55gnunet-arm -e -c test_gns_lookup.conf
48rm -rf /tmp/test-gnunet-gns-peer-1/ 56rm -rf /tmp/test-gnunet-gns-peer-1/
49 57
@@ -51,6 +59,6 @@ if [ "$RES_IP" == "$TEST_IP" ]
51then 59then
52 exit 0 60 exit 0
53else 61else
54 echo "Failed to properly resolve IP, got $RES_IP." 62 echo "Failed to properly resolve IP, expected $TEST_IP, got $RES_IP."
55 exit 1 63 exit 1
56fi 64fi
diff --git a/src/gns/test_gns_rel_expiration.sh b/src/gns/test_gns_rel_expiration.sh
index 9890641e2..992098db3 100755
--- a/src/gns/test_gns_rel_expiration.sh
+++ b/src/gns/test_gns_rel_expiration.sh
@@ -13,27 +13,30 @@ then
13 exit 77 13 exit 77
14fi 14fi
15 15
16MY_EGO="myego"
17OTHER_EGO="delegatedego"
18
16rm -rf /tmp/test-gnunet-gns-peer-1/ 19rm -rf /tmp/test-gnunet-gns-peer-1/
17which timeout &> /dev/null && DO_TIMEOUT="timeout 5" 20which timeout &> /dev/null && DO_TIMEOUT="timeout 5"
18TEST_IP="127.0.0.1" 21TEST_IP="127.0.0.1"
19gnunet-arm -s -c test_gns_lookup.conf 22gnunet-arm -s -c test_gns_lookup.conf
20gnunet-identity -C testego -c test_gns_lookup.conf 23gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
21gnunet-identity -C delegatedego -c test_gns_lookup.conf 24gnunet-identity -C $OTHER_EGO -c test_gns_lookup.conf
22DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}') 25DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep $OTHER_EGO | awk '{print $3}')
23gnunet-namestore -p -z testego -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf 26gnunet-namestore -p -z $MY_EGO -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf
24gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e '5 s' -c test_gns_lookup.conf 27gnunet-namestore -p -z $OTHER_EGO -a -n www -t A -V $TEST_IP -e '5 s' -c test_gns_lookup.conf
25gnunet-arm -i gns -c test_gns_lookup.conf 28gnunet-arm -i gns -c test_gns_lookup.conf
26# confirm that lookup currently works 29# confirm that lookup currently works
27RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.b.gnu -t A -c test_gns_lookup.conf` 30RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.b.$MY_EGO -t A -c test_gns_lookup.conf`
28# remove entry 31# remove entry
29gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP -e '5 s' -c test_gns_lookup.conf 32gnunet-namestore -z $OTHER_EGO -d -n www -t A -V $TEST_IP -e '5 s' -c test_gns_lookup.conf
30# wait for old entry with 5s 'expiration' to definitively expire 33# wait for old entry with 5s 'expiration' to definitively expire
31sleep 6 34sleep 6
32# try again, should no longer work 35# try again, should no longer work
33RES_IP_EXP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.b.gnu -t A -c test_gns_lookup.conf` 36RES_IP_EXP=`$DO_TIMEOUT gnunet-gns --raw -u www.b.$MY_EGO -t A -c test_gns_lookup.conf`
34gnunet-namestore -z testego -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf 37gnunet-namestore -z $MY_EGO -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf
35gnunet-identity -D testego -c test_gns_lookup.conf 38gnunet-identity -D $MY_EGO -c test_gns_lookup.conf
36gnunet-identity -D delegatedego -c test_gns_lookup.conf 39gnunet-identity -D $OTHER_EGO -c test_gns_lookup.conf
37gnunet-arm -e -c test_gns_lookup.conf 40gnunet-arm -e -c test_gns_lookup.conf
38rm -rf /tmp/test-gnunet-gns-peer-1/ 41rm -rf /tmp/test-gnunet-gns-peer-1/
39 42
diff --git a/src/gns/test_gns_revocation.sh b/src/gns/test_gns_revocation.sh
index fdd3c76de..269b940d9 100755
--- a/src/gns/test_gns_revocation.sh
+++ b/src/gns/test_gns_revocation.sh
@@ -15,19 +15,21 @@ then
15fi 15fi
16 16
17rm -rf /tmp/test-gnunet-gns-peer-1/ 17rm -rf /tmp/test-gnunet-gns-peer-1/
18 18MY_EGO="myego"
19OTHER_EGO="delegatedego"
19TEST_IP="127.0.0.1" 20TEST_IP="127.0.0.1"
21
20gnunet-arm -s -c test_gns_lookup.conf 22gnunet-arm -s -c test_gns_lookup.conf
21gnunet-identity -C delegatedego -c test_gns_lookup.conf 23gnunet-identity -C $OTHER_EGO -c test_gns_lookup.conf
22DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}') 24DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep $OTHER_EGO | awk '{print $3}')
23gnunet-identity -C testego -c test_gns_lookup.conf 25gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
24gnunet-namestore -p -z testego -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf 26gnunet-namestore -p -z $MY_EGO -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf
25gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf 27gnunet-namestore -p -z $OTHER_EGO -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf
26RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.b.gnu -t A -c test_gns_lookup.conf` 28RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.b.$MY_EGO -t A -c test_gns_lookup.conf`
27gnunet-revocation -R delegatedego -p -c test_gns_lookup.conf 29gnunet-revocation -R $OTHER_EGO -p -c test_gns_lookup.conf
28RES_IP_REV=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.b.gnu -t A -c test_gns_lookup.conf` 30RES_IP_REV=`$DO_TIMEOUT gnunet-gns --raw -u www.b.$MY_EGO -t A -c test_gns_lookup.conf`
29gnunet-namestore -z testego -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf 31gnunet-namestore -z $MY_EGO -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf
30gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf 32gnunet-namestore -z $OTHER_EGO -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf
31gnunet-arm -e -c test_gns_lookup.conf 33gnunet-arm -e -c test_gns_lookup.conf
32rm -rf /tmp/test-gnunet-gns-peer-1/ 34rm -rf /tmp/test-gnunet-gns-peer-1/
33 35
diff --git a/src/gns/test_gns_soa_lookup.sh b/src/gns/test_gns_soa_lookup.sh
index bd8adcb63..2f9cc58de 100755
--- a/src/gns/test_gns_soa_lookup.sh
+++ b/src/gns/test_gns_soa_lookup.sh
@@ -16,7 +16,8 @@ fi
16which timeout &> /dev/null && DO_TIMEOUT="timeout 5" 16which timeout &> /dev/null && DO_TIMEOUT="timeout 5"
17 17
18rm -rf /tmp/test-gnunet-gns-peer-1/ 18rm -rf /tmp/test-gnunet-gns-peer-1/
19TEST_DOMAIN="homepage.gnu" 19MY_EGO="myego"
20TEST_DOMAIN="homepage.$MY_EGO"
20# some public DNS resolver we can use 21# some public DNS resolver we can use
21TEST_IP_GNS2DNS="184.172.157.218" 22TEST_IP_GNS2DNS="184.172.157.218"
22TEST_RECORD_NAME="homepage" 23TEST_RECORD_NAME="homepage"
@@ -29,11 +30,11 @@ then
29fi 30fi
30 31
31gnunet-arm -s -c test_gns_lookup.conf 32gnunet-arm -s -c test_gns_lookup.conf
32gnunet-identity -C testego -c test_gns_lookup.conf 33gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
33gnunet-namestore -p -z testego -a -n $TEST_RECORD_NAME -t GNS2DNS -V ${TEST_RECORD_GNS2DNS}@${TEST_IP_GNS2DNS} -e never -c test_gns_lookup.conf 34gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V ${TEST_RECORD_GNS2DNS}@${TEST_IP_GNS2DNS} -e never -c test_gns_lookup.conf
34RES_SOA=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_DOMAIN -t SOA -c test_gns_lookup.conf` 35RES_SOA=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t SOA -c test_gns_lookup.conf`
35gnunet-namestore -z testego -d -n $TEST_RECORD_NAME -t GNS2DNS -V ${TEST_RECORD_GNS2DNS}@${TEST_IP_GNS2DNS} -e never -c test_gns_lookup.conf &> /dev/null 36gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V ${TEST_RECORD_GNS2DNS}@${TEST_IP_GNS2DNS} -e never -c test_gns_lookup.conf &> /dev/null
36gnunet-identity -D testego -c test_gns_lookup.conf 37gnunet-identity -D $MY_EGO -c test_gns_lookup.conf
37gnunet-arm -e -c test_gns_lookup.conf 38gnunet-arm -e -c test_gns_lookup.conf
38rm -rf /tmp/test-gnunet-gns-peer-1/ 39rm -rf /tmp/test-gnunet-gns-peer-1/
39 40
diff --git a/src/gns/test_gns_txt_lookup.sh b/src/gns/test_gns_txt_lookup.sh
index dcf51112f..68a60c8b6 100755
--- a/src/gns/test_gns_txt_lookup.sh
+++ b/src/gns/test_gns_txt_lookup.sh
@@ -16,12 +16,14 @@ fi
16rm -rf /tmp/test-gnunet-gns-peer-1/ 16rm -rf /tmp/test-gnunet-gns-peer-1/
17which timeout &> /dev/null && DO_TIMEOUT="timeout 30" 17which timeout &> /dev/null && DO_TIMEOUT="timeout 30"
18TEST_TXT="GNS powered txt record data" 18TEST_TXT="GNS powered txt record data"
19MY_EGO="myego"
20LABEL="testtxt"
19gnunet-arm -s -c test_gns_lookup.conf 21gnunet-arm -s -c test_gns_lookup.conf
20gnunet-identity -C testego -c test_gns_lookup.conf 22gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
21gnunet-namestore -p -z testego -a -n testtxt -t TXT -V "$TEST_TXT" -e never -c test_gns_lookup.conf 23gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t TXT -V "$TEST_TXT" -e never -c test_gns_lookup.conf
22RES_TXT=`$DO_TIMEOUT gnunet-gns --raw -z testego -u testtxt.gnu -t TXT -c test_gns_lookup.conf` 24RES_TXT=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$MY_EGO -t TXT -c test_gns_lookup.conf`
23gnunet-namestore -z testego -d -n testtxt -t TXT -V "$TEST_TXT" -e never -c test_gns_lookup.conf 25gnunet-namestore -z $MY_EGO -d -n $LABEL -t TXT -V "$TEST_TXT" -e never -c test_gns_lookup.conf
24gnunet-identity -D testego -c test_gns_lookup.conf 26gnunet-identity -D $MY_EGO -c test_gns_lookup.conf
25gnunet-arm -e -c test_gns_lookup.conf 27gnunet-arm -e -c test_gns_lookup.conf
26rm -rf /tmp/test-gnunet-gns-peer-1/ 28rm -rf /tmp/test-gnunet-gns-peer-1/
27 29
diff --git a/src/gns/test_gns_zkey_lookup.sh b/src/gns/test_gns_zkey_lookup.sh
index 6262c1eb2..312198780 100755
--- a/src/gns/test_gns_zkey_lookup.sh
+++ b/src/gns/test_gns_zkey_lookup.sh
@@ -23,7 +23,7 @@ DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego
23gnunet-identity -C testego -c test_gns_lookup.conf 23gnunet-identity -C testego -c test_gns_lookup.conf
24gnunet-namestore -p -z testego -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf 24gnunet-namestore -p -z testego -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf
25gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf 25gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf
26RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.${DELEGATED_PKEY}.zkey -t A -c test_gns_lookup.conf` 26RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.${DELEGATED_PKEY} -t A -c test_gns_lookup.conf`
27gnunet-namestore -z testego -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf 27gnunet-namestore -z testego -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf
28gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf 28gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf
29gnunet-arm -e -c test_gns_lookup.conf 29gnunet-arm -e -c test_gns_lookup.conf
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c
index 4c3bf6fa8..3c1ead437 100644
--- a/src/gnsrecord/gnsrecord_misc.c
+++ b/src/gnsrecord/gnsrecord_misc.c
@@ -241,7 +241,7 @@ GNUNET_GNSRECORD_pkey_to_zkey (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey)
241 pkeys = GNUNET_CRYPTO_ecdsa_public_key_to_string (pkey); 241 pkeys = GNUNET_CRYPTO_ecdsa_public_key_to_string (pkey);
242 GNUNET_snprintf (ret, 242 GNUNET_snprintf (ret,
243 sizeof (ret), 243 sizeof (ret),
244 "%s.zkey", 244 "%s",
245 pkeys); 245 pkeys);
246 GNUNET_free (pkeys); 246 GNUNET_free (pkeys);
247 return ret; 247 return ret;
@@ -249,10 +249,10 @@ GNUNET_GNSRECORD_pkey_to_zkey (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey)
249 249
250 250
251/** 251/**
252 * Convert an absolute domain name in the ".zkey" pTLD to the 252 * Convert an absolute domain name to the
253 * respective public key. 253 * respective public key.
254 * 254 *
255 * @param zkey string "X.zkey" where X is the coordinates of the public 255 * @param zkey string encoding the coordinates of the public
256 * key in an encoding suitable for DNS labels. 256 * key in an encoding suitable for DNS labels.
257 * @param pkey set to a public key on the eliptic curve 257 * @param pkey set to a public key on the eliptic curve
258 * @return #GNUNET_SYSERR if @a zkey has the wrong syntax 258 * @return #GNUNET_SYSERR if @a zkey has the wrong syntax
@@ -261,29 +261,12 @@ int
261GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey, 261GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey,
262 struct GNUNET_CRYPTO_EcdsaPublicKey *pkey) 262 struct GNUNET_CRYPTO_EcdsaPublicKey *pkey)
263{ 263{
264 char *cpy;
265 char *dot;
266 const char *x;
267
268 cpy = GNUNET_strdup (zkey);
269 x = cpy;
270 if (NULL == (dot = strchr (x, (int) '.')))
271 goto error;
272 *dot = '\0';
273 if (0 != strcasecmp (dot + 1,
274 "zkey"))
275 goto error;
276
277 if (GNUNET_OK != 264 if (GNUNET_OK !=
278 GNUNET_CRYPTO_ecdsa_public_key_from_string (x, 265 GNUNET_CRYPTO_ecdsa_public_key_from_string (zkey,
279 strlen (x), 266 strlen (zkey),
280 pkey)) 267 pkey))
281 goto error; 268 return GNUNET_SYSERR;
282 GNUNET_free (cpy);
283 return GNUNET_OK; 269 return GNUNET_OK;
284 error:
285 GNUNET_free (cpy);
286 return GNUNET_SYSERR;
287} 270}
288 271
289 272
diff --git a/src/include/gnunet_gns_service.h b/src/include/gnunet_gns_service.h
index ccc868c05..2ef946a82 100644
--- a/src/include/gnunet_gns_service.h
+++ b/src/include/gnunet_gns_service.h
@@ -50,6 +50,9 @@ extern "C"
50/** 50/**
51 * String we use to indicate the local master zone or a 51 * String we use to indicate the local master zone or a
52 * root entry in the current zone. 52 * root entry in the current zone.
53 *
54 * FIXME: probably should be changed to "@" and renamed
55 * (this name is confusing!)
53 */ 56 */
54#define GNUNET_GNS_MASTERZONE_STR "+" 57#define GNUNET_GNS_MASTERZONE_STR "+"
55 58
diff --git a/src/namecache/gnunet-service-namecache.c b/src/namecache/gnunet-service-namecache.c
index f20d664a2..c08f2aef7 100644
--- a/src/namecache/gnunet-service-namecache.c
+++ b/src/namecache/gnunet-service-namecache.c
@@ -50,7 +50,7 @@ struct NamecacheClient
50 * The message queue to talk to @e client. 50 * The message queue to talk to @e client.
51 */ 51 */
52 struct GNUNET_MQ_Handle *mq; 52 struct GNUNET_MQ_Handle *mq;
53 53
54}; 54};
55 55
56 56
@@ -208,7 +208,7 @@ handle_lookup_block (void *cls,
208 208
209 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 209 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
210 "Received NAMECACHE_LOOKUP_BLOCK message\n"); 210 "Received NAMECACHE_LOOKUP_BLOCK message\n");
211 211
212 lnc.request_id = ntohl (ln_msg->gns_header.r_id); 212 lnc.request_id = ntohl (ln_msg->gns_header.r_id);
213 lnc.nc = nc; 213 lnc.nc = nc;
214 if (GNUNET_SYSERR == 214 if (GNUNET_SYSERR ==
@@ -306,7 +306,7 @@ handle_block_cache (void *cls,
306 * @param service the initialized service 306 * @param service the initialized service
307 */ 307 */
308static void 308static void
309run (void *cls, 309run (void *cls,
310 const struct GNUNET_CONFIGURATION_Handle *cfg, 310 const struct GNUNET_CONFIGURATION_Handle *cfg,
311 struct GNUNET_SERVICE_Handle *service) 311 struct GNUNET_SERVICE_Handle *service)
312{ 312{
@@ -319,8 +319,8 @@ run (void *cls,
319 /* Loading database plugin */ 319 /* Loading database plugin */
320 if (GNUNET_OK != 320 if (GNUNET_OK !=
321 GNUNET_CONFIGURATION_get_value_string (cfg, 321 GNUNET_CONFIGURATION_get_value_string (cfg,
322 "namecache", 322 "namecache",
323 "database", 323 "database",
324 &database)) 324 &database))
325 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 325 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
326 "No database backend configured\n"); 326 "No database backend configured\n");
diff --git a/src/namecache/plugin_namecache_flat.c b/src/namecache/plugin_namecache_flat.c
index 66ab776e3..220c60305 100644
--- a/src/namecache/plugin_namecache_flat.c
+++ b/src/namecache/plugin_namecache_flat.c
@@ -86,8 +86,10 @@ database_setup (struct Plugin *plugin)
86 struct GNUNET_DISK_FileHandle *fh; 86 struct GNUNET_DISK_FileHandle *fh;
87 87
88 if (GNUNET_OK != 88 if (GNUNET_OK !=
89 GNUNET_CONFIGURATION_get_value_filename (plugin->cfg, "namecache-flat", 89 GNUNET_CONFIGURATION_get_value_filename (plugin->cfg,
90 "FILENAME", &afsdir)) 90 "namecache-flat",
91 "FILENAME",
92 &afsdir))
91 { 93 {
92 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 94 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
93 "namecache-flat", "FILENAME"); 95 "namecache-flat", "FILENAME");
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index dcb9dd678..4f512713b 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -403,7 +403,7 @@ display_record (void *cls,
403 { 403 {
404 if ( (GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) && 404 if ( (GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
405 (0 != strcmp (rname, 405 (0 != strcmp (rname,
406 "+")) ) 406 GNUNET_GNS_MASTERZONE_STR)) )
407 continue; 407 continue;
408 typestring = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type); 408 typestring = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type);
409 s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type, 409 s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type,
@@ -1145,7 +1145,7 @@ main (int argc,
1145 GNUNET_GETOPT_option_flag ('D', 1145 GNUNET_GETOPT_option_flag ('D',
1146 "display", 1146 "display",
1147 gettext_noop ("display records"), 1147 gettext_noop ("display records"),
1148 &list), 1148 &list),
1149 1149
1150 GNUNET_GETOPT_option_string ('e', 1150 GNUNET_GETOPT_option_string ('e',
1151 "expiration", 1151 "expiration",
@@ -1157,7 +1157,7 @@ main (int argc,
1157 "nick", 1157 "nick",
1158 "NICKNAME", 1158 "NICKNAME",
1159 gettext_noop ("set the desired nick name for the zone"), 1159 gettext_noop ("set the desired nick name for the zone"),
1160 &nickstring), 1160 &nickstring),
1161 1161
1162 GNUNET_GETOPT_option_flag ('m', 1162 GNUNET_GETOPT_option_flag ('m',
1163 "monitor", 1163 "monitor",
@@ -1210,7 +1210,7 @@ main (int argc,
1210 "zone", 1210 "zone",
1211 "EGO", 1211 "EGO",
1212 gettext_noop ("name of the ego controlling the zone"), 1212 gettext_noop ("name of the ego controlling the zone"),
1213 &ego_name), 1213 &ego_name),
1214 1214
1215 GNUNET_GETOPT_OPTION_END 1215 GNUNET_GETOPT_OPTION_END
1216 }; 1216 };
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index b27cfb732..dea13b982 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -105,7 +105,7 @@ struct NamestoreClient
105 * Message queue for transmission to @e client 105 * Message queue for transmission to @e client
106 */ 106 */
107 struct GNUNET_MQ_Handle *mq; 107 struct GNUNET_MQ_Handle *mq;
108 108
109 /** 109 /**
110 * Head of the DLL of 110 * Head of the DLL of
111 * Zone iteration operations in progress initiated by this client 111 * Zone iteration operations in progress initiated by this client
@@ -268,7 +268,7 @@ cleanup_task (void *cls)
268 } 268 }
269 GNUNET_NAMECACHE_disconnect (namecache); 269 GNUNET_NAMECACHE_disconnect (namecache);
270 namecache = NULL; 270 namecache = NULL;
271 GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, 271 GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name,
272 GSN_database)); 272 GSN_database));
273 GNUNET_free (db_lib_name); 273 GNUNET_free (db_lib_name);
274 db_lib_name = NULL; 274 db_lib_name = NULL;
@@ -1011,7 +1011,8 @@ handle_record_store (void *cls,
1011 struct GNUNET_GNSRECORD_Data rd_clean[rd_count]; 1011 struct GNUNET_GNSRECORD_Data rd_clean[rd_count];
1012 unsigned int rd_clean_off; 1012 unsigned int rd_clean_off;
1013 1013
1014 /* remove "NICK" records, unless this is for the "+" label */ 1014 /* remove "NICK" records, unless this is for the
1015 #GNUNET_GNS_MASTERZONE_STR label */
1015 rd_clean_off = 0; 1016 rd_clean_off = 0;
1016 for (unsigned int i=0;i<rd_count;i++) 1017 for (unsigned int i=0;i<rd_count;i++)
1017 { 1018 {
@@ -1669,23 +1670,23 @@ GNUNET_SERVICE_MAIN
1669 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME, 1670 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME,
1670 struct ZoneToNameMessage, 1671 struct ZoneToNameMessage,
1671 NULL), 1672 NULL),
1672 GNUNET_MQ_hd_fixed_size (iteration_start, 1673 GNUNET_MQ_hd_fixed_size (iteration_start,
1673 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START, 1674 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START,
1674 struct ZoneIterationStartMessage, 1675 struct ZoneIterationStartMessage,
1675 NULL), 1676 NULL),
1676 GNUNET_MQ_hd_fixed_size (iteration_next, 1677 GNUNET_MQ_hd_fixed_size (iteration_next,
1677 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT, 1678 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT,
1678 struct ZoneIterationNextMessage, 1679 struct ZoneIterationNextMessage,
1679 NULL), 1680 NULL),
1680 GNUNET_MQ_hd_fixed_size (iteration_stop, 1681 GNUNET_MQ_hd_fixed_size (iteration_stop,
1681 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP, 1682 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP,
1682 struct ZoneIterationStopMessage, 1683 struct ZoneIterationStopMessage,
1683 NULL), 1684 NULL),
1684 GNUNET_MQ_hd_fixed_size (monitor_start, 1685 GNUNET_MQ_hd_fixed_size (monitor_start,
1685 GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START, 1686 GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START,
1686 struct ZoneMonitorStartMessage, 1687 struct ZoneMonitorStartMessage,
1687 NULL), 1688 NULL),
1688 GNUNET_MQ_handler_end ()); 1689 GNUNET_MQ_handler_end ());
1689 1690
1690 1691
1691/* end of gnunet-service-namestore.c */ 1692/* end of gnunet-service-namestore.c */
diff --git a/src/namestore/plugin_rest_namestore.c b/src/namestore/plugin_rest_namestore.c
index 05776801b..954af98d2 100644
--- a/src/namestore/plugin_rest_namestore.c
+++ b/src/namestore/plugin_rest_namestore.c
@@ -26,6 +26,7 @@
26 26
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_rest_plugin.h" 28#include "gnunet_rest_plugin.h"
29#include "gnunet_gns_service.h"
29#include "gnunet_namestore_service.h" 30#include "gnunet_namestore_service.h"
30#include "gnunet_identity_service.h" 31#include "gnunet_identity_service.h"
31#include "gnunet_rest_lib.h" 32#include "gnunet_rest_lib.h"
@@ -458,7 +459,7 @@ namestore_list_response (void *cls,
458 for (i=0; i<rd_len; i++) 459 for (i=0; i<rd_len; i++)
459 { 460 {
460 if ( (GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) && 461 if ( (GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
461 (0 != strcmp (rname, "+")) ) 462 (0 != strcmp (rname, GNUNET_GNS_MASTERZONE_STR)) )
462 continue; 463 continue;
463 464
464 if ( (rd[i].record_type != handle->type) && 465 if ( (rd[i].record_type != handle->type) &&