aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2018-03-05 07:46:55 +0000
committerng0 <ng0@n0.is>2018-03-05 07:46:55 +0000
commitd5a7fa6adddccf17296b44a832eb393fd1cebe1b (patch)
treedb54c8909fb3a1b68bda7276a4ae8a972403829b /src
parentb48942b46913de4876431e3574a7ace641fb548c (diff)
parent1f46cd73049570f21ff47cd3ee81ea88da45af07 (diff)
downloadgnunet-d5a7fa6adddccf17296b44a832eb393fd1cebe1b.tar.gz
gnunet-d5a7fa6adddccf17296b44a832eb393fd1cebe1b.zip
Merge branch 'master' of gnunet.org:gnunet
Diffstat (limited to 'src')
-rw-r--r--src/gns/gns.conf.in9
-rw-r--r--src/gns/gnunet-gns.c253
-rw-r--r--src/gns/gnunet-service-gns.c164
-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
-rw-r--r--src/gns/nss/nss_gns.c75
-rw-r--r--src/gns/nss/nss_gns_query.c7
-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.c68
-rw-r--r--src/namestore/gnunet-service-namestore.c17
-rw-r--r--src/namestore/plugin_rest_namestore.c3
-rw-r--r--src/util/client.c46
-rw-r--r--src/util/mq.c32
-rw-r--r--src/util/resolver_api.c32
-rw-r--r--src/util/scheduler.c26
35 files changed, 756 insertions, 708 deletions
diff --git a/src/gns/gns.conf.in b/src/gns/gns.conf.in
index b34246cef..6b764904f 100644
--- a/src/gns/gns.conf.in
+++ b/src/gns/gns.conf.in
@@ -16,11 +16,20 @@ 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
22# PREFIX = valgrind --leak-check=full --track-origins=yes 28# PREFIX = valgrind --leak-check=full --track-origins=yes
23 29
30# Zones
31.pin = DWJASSPE33MRN8T6Q0PENRNBTQY0E6ZYGTRCDP5DGPBF2CRJMJEG
32
24 33
25[gns-proxy] 34[gns-proxy]
26BINARY = gnunet-gns-proxy 35BINARY = gnunet-gns-proxy
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 e13beb889..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
@@ -223,19 +236,10 @@ static void
223shutdown_task (void *cls) 236shutdown_task (void *cls)
224{ 237{
225 struct GNS_TopLevelDomain *tld; 238 struct GNS_TopLevelDomain *tld;
239
226 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 240 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
227 "Shutting down!\n"); 241 "Shutting down!\n");
228 GNS_interceptor_done (); 242 GNS_interceptor_done ();
229 if (NULL != identity_op)
230 {
231 GNUNET_IDENTITY_cancel (identity_op);
232 identity_op = NULL;
233 }
234 if (NULL != identity_handle)
235 {
236 GNUNET_IDENTITY_disconnect (identity_handle);
237 identity_handle = NULL;
238 }
239 GNS_resolver_done (); 243 GNS_resolver_done ();
240 if (NULL != statistics) 244 if (NULL != statistics)
241 { 245 {
@@ -415,7 +419,8 @@ handle_lookup (void *cls,
415 419
416 GNUNET_SERVICE_client_continue (gc->client); 420 GNUNET_SERVICE_client_continue (gc->client);
417 utf_in = (const char *) &sh_msg[1]; 421 utf_in = (const char *) &sh_msg[1];
418 GNUNET_STRINGS_utf8_tolower (utf_in, nameptr); 422 GNUNET_STRINGS_utf8_tolower (utf_in,
423 nameptr);
419 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 424 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
420 "Received LOOKUP `%s' message\n", 425 "Received LOOKUP `%s' message\n",
421 name); 426 name);
@@ -431,7 +436,9 @@ handle_lookup (void *cls,
431 { 436 {
432 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 437 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
433 "LOOKUP: Query for A record but AF_INET not supported!"); 438 "LOOKUP: Query for A record but AF_INET not supported!");
434 send_lookup_response (clh, 0, NULL); 439 send_lookup_response (clh,
440 0,
441 NULL);
435 return; 442 return;
436 } 443 }
437 if ( (GNUNET_DNSPARSER_TYPE_AAAA == ntohl (sh_msg->type)) && 444 if ( (GNUNET_DNSPARSER_TYPE_AAAA == ntohl (sh_msg->type)) &&
@@ -439,7 +446,9 @@ handle_lookup (void *cls,
439 { 446 {
440 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 447 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
441 "LOOKUP: Query for AAAA record but AF_INET6 not supported!"); 448 "LOOKUP: Query for AAAA record but AF_INET6 not supported!");
442 send_lookup_response (clh, 0, NULL); 449 send_lookup_response (clh,
450 0,
451 NULL);
443 return; 452 return;
444 } 453 }
445 clh->lookup = GNS_resolver_lookup (&sh_msg->zone, 454 clh->lookup = GNS_resolver_lookup (&sh_msg->zone,
@@ -454,57 +463,6 @@ handle_lookup (void *cls,
454 463
455 464
456/** 465/**
457 * Method called to inform about the ego to be used for the master zone
458 * for DNS interceptions.
459 *
460 * This function is only called ONCE, and 'NULL' being passed in
461 * @a ego does indicate that interception is not configured.
462 * If @a ego is non-NULL, we should start to intercept DNS queries
463 * and resolve ".gnu" queries using the given ego as the master zone.
464 *
465 * @param cls closure, our `const struct GNUNET_CONFIGURATION_Handle *c`
466 * @param ego ego handle
467 * @param ctx context for application to store data for this ego
468 * (during the lifetime of this process, initially NULL)
469 * @param name name assigned by the user for this ego,
470 * NULL if the user just deleted the ego and it
471 * must thus no longer be used
472 */
473static void
474identity_intercept_cb (void *cls,
475 struct GNUNET_IDENTITY_Ego *ego,
476 void **ctx,
477 const char *name)
478{
479 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
480 struct GNUNET_CRYPTO_EcdsaPublicKey dns_root;
481
482 identity_op = NULL;
483 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
484 "Looking for gns-intercept ego\n");
485 if (NULL == ego)
486 {
487 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
488 _("No ego configured for `%s`\n"),
489 "gns-intercept");
490
491 return;
492 }
493 GNUNET_IDENTITY_ego_get_public_key (ego,
494 &dns_root);
495 if (GNUNET_SYSERR ==
496 GNS_interceptor_init (&dns_root,
497 cfg))
498 {
499 GNUNET_break (0);
500 GNUNET_SCHEDULER_add_now (&shutdown_task,
501 NULL);
502 return;
503 }
504}
505
506
507/**
508 * Reads the configuration and populates TLDs 466 * Reads the configuration and populates TLDs
509 * 467 *
510 * @param cls unused 468 * @param cls unused
@@ -518,7 +476,7 @@ read_service_conf (void *cls,
518 const char *option, 476 const char *option,
519 const char *value) 477 const char *value)
520{ 478{
521 struct GNUNET_CRYPTO_EddsaPublicKey pk; 479 struct GNUNET_CRYPTO_EcdsaPublicKey pk;
522 struct GNS_TopLevelDomain *tld; 480 struct GNS_TopLevelDomain *tld;
523 481
524 if (option[0] != '.') 482 if (option[0] != '.')
@@ -536,7 +494,7 @@ read_service_conf (void *cls,
536 return; 494 return;
537 } 495 }
538 tld = GNUNET_new (struct GNS_TopLevelDomain); 496 tld = GNUNET_new (struct GNS_TopLevelDomain);
539 tld->tld = GNUNET_strdup (option); 497 tld->tld = GNUNET_strdup (&option[1]);
540 tld->pkey = pk; 498 tld->pkey = pk;
541 GNUNET_CONTAINER_DLL_insert (tld_head, 499 GNUNET_CONTAINER_DLL_insert (tld_head,
542 tld_tail, 500 tld_tail,
@@ -544,7 +502,6 @@ read_service_conf (void *cls,
544} 502}
545 503
546 504
547
548/** 505/**
549 * Process GNS requests. 506 * Process GNS requests.
550 * 507 *
@@ -593,29 +550,24 @@ run (void *cls,
593 NULL); 550 NULL);
594 return; 551 return;
595 } 552 }
596
597 identity_handle = GNUNET_IDENTITY_connect (c,
598 NULL,
599 NULL);
600 if (NULL == identity_handle)
601 {
602 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
603 "Could not connect to identity service!\n");
604 }
605 else
606 {
607 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
608 "Looking for gns-intercept ego\n");
609 identity_op = GNUNET_IDENTITY_get (identity_handle,
610 "gns-intercept",
611 &identity_intercept_cb,
612 (void *) c);
613 }
614 GNS_resolver_init (namecache_handle, 553 GNS_resolver_init (namecache_handle,
615 dht_handle, 554 dht_handle,
616 c, 555 c,
617 max_parallel_bg_queries); 556 max_parallel_bg_queries);
618 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);
619 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, 571 GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
620 NULL); 572 NULL);
621} 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/nss/nss_gns.c b/src/gns/nss/nss_gns.c
index 31435cf95..03ac6e09c 100644
--- a/src/gns/nss/nss_gns.c
+++ b/src/gns/nss/nss_gns.c
@@ -42,35 +42,6 @@
42 42
43 43
44/** 44/**
45 * function to check if name ends with a specific suffix
46 *
47 * @param name the name to check
48 * @param suffix the suffix to check for
49 * @return 1 if true
50 */
51static int ends_with(const char *name, const char* suffix) {
52 size_t ln, ls;
53 assert(name);
54 assert(suffix);
55
56 if ((ls = strlen(suffix)) > (ln = strlen(name)))
57 return 0;
58
59 return strcasecmp(name+ln-ls, suffix) == 0;
60}
61
62
63/**
64 * Check if name is inside .gnu or .zkey TLD
65 *
66 * @param name name to check
67 * @return 1 if true
68 */
69static int verify_name_allowed (const char *name) {
70 return ends_with(name, ".gnu") || ends_with(name, ".zkey");
71}
72
73/**
74 * The gethostbyname hook executed by nsswitch 45 * The gethostbyname hook executed by nsswitch
75 * 46 *
76 * @param name the name to resolve 47 * @param name the name to resolve
@@ -82,7 +53,8 @@ static int verify_name_allowed (const char *name) {
82 * @param h_errnop idk 53 * @param h_errnop idk
83 * @return a nss_status code 54 * @return a nss_status code
84 */ 55 */
85enum nss_status _nss_gns_gethostbyname2_r( 56enum nss_status
57_nss_gns_gethostbyname2_r(
86 const char *name, 58 const char *name,
87 int af, 59 int af,
88 struct hostent * result, 60 struct hostent * result,
@@ -95,7 +67,6 @@ enum nss_status _nss_gns_gethostbyname2_r(
95 enum nss_status status = NSS_STATUS_UNAVAIL; 67 enum nss_status status = NSS_STATUS_UNAVAIL;
96 int i; 68 int i;
97 size_t address_length, l, idx, astart; 69 size_t address_length, l, idx, astart;
98 int name_allowed;
99 70
100 if (af == AF_UNSPEC) 71 if (af == AF_UNSPEC)
101#ifdef NSS_IPV6_ONLY 72#ifdef NSS_IPV6_ONLY
@@ -133,28 +104,25 @@ enum nss_status _nss_gns_gethostbyname2_r(
133 u.count = 0; 104 u.count = 0;
134 u.data_len = 0; 105 u.data_len = 0;
135 106
136 name_allowed = verify_name_allowed(name); 107 i = gns_resolve_name(af, name, &u);
137 108 if (-3 == i)
138 if (name_allowed) { 109 {
139 110 status = NSS_STATUS_NOTFOUND;
140 if (!gns_resolve_name(af, name, &u) == 0) 111 goto finish;
141 { 112 }
142 status = NSS_STATUS_NOTFOUND; 113 if (-2 == i)
143 goto finish; 114 {
144 } 115 status = NSS_STATUS_UNAVAIL;
145 } 116 goto finish;
146 else 117 }
147 { 118 if ( (-1 == i) ||
148 status = NSS_STATUS_UNAVAIL; 119 (u.count == 0) )
149 goto finish; 120 {
150 }
151
152 if (u.count == 0) {
153 *errnop = ETIMEDOUT; 121 *errnop = ETIMEDOUT;
154 *h_errnop = HOST_NOT_FOUND; 122 *h_errnop = HOST_NOT_FOUND;
155 status = NSS_STATUS_NOTFOUND; 123 status = NSS_STATUS_NOTFOUND;
156 goto finish; 124 goto finish;
157 } 125 }
158 126
159 127
160 /* Alias names */ 128 /* Alias names */
@@ -212,7 +180,8 @@ finish:
212 * @param h_errnop idk 180 * @param h_errnop idk
213 * @return a nss_status code 181 * @return a nss_status code
214 */ 182 */
215enum nss_status _nss_gns_gethostbyname_r ( 183enum nss_status
184_nss_gns_gethostbyname_r (
216 const char *name, 185 const char *name,
217 struct hostent *result, 186 struct hostent *result,
218 char *buffer, 187 char *buffer,
@@ -244,7 +213,8 @@ enum nss_status _nss_gns_gethostbyname_r (
244 * @param h_errnop idk 213 * @param h_errnop idk
245 * @return NSS_STATUS_UNAVAIL 214 * @return NSS_STATUS_UNAVAIL
246 */ 215 */
247enum nss_status _nss_gns_gethostbyaddr_r( 216enum nss_status
217_nss_gns_gethostbyaddr_r(
248 const void* addr, 218 const void* addr,
249 int len, 219 int len,
250 int af, 220 int af,
@@ -253,10 +223,9 @@ enum nss_status _nss_gns_gethostbyaddr_r(
253 size_t buflen, 223 size_t buflen,
254 int *errnop, 224 int *errnop,
255 int *h_errnop) { 225 int *h_errnop) {
256 226
257 *errnop = EINVAL; 227 *errnop = EINVAL;
258 *h_errnop = NO_RECOVERY; 228 *h_errnop = NO_RECOVERY;
259 //NOTE we allow to leak this into DNS so no NOTFOUND 229 //NOTE we allow to leak this into DNS so no NOTFOUND
260 return NSS_STATUS_UNAVAIL; 230 return NSS_STATUS_UNAVAIL;
261} 231}
262
diff --git a/src/gns/nss/nss_gns_query.c b/src/gns/nss/nss_gns_query.c
index 273eaa619..4700100b5 100644
--- a/src/gns/nss/nss_gns_query.c
+++ b/src/gns/nss/nss_gns_query.c
@@ -44,6 +44,7 @@ gns_resolve_name (int af,
44 FILE *p; 44 FILE *p;
45 char *cmd; 45 char *cmd;
46 char line[128]; 46 char line[128];
47 int ret;
47 48
48 if (AF_INET6 == af) 49 if (AF_INET6 == af)
49 { 50 {
@@ -101,8 +102,12 @@ gns_resolve_name (int af,
101 } 102 }
102 } 103 }
103 } 104 }
104 pclose (p); 105 ret = pclose (p);
105 free (cmd); 106 free (cmd);
107 if (4 == ret)
108 return -2; /* not for GNS */
109 if (3 == ret)
110 return -3; /* timeout */
106 return 0; 111 return 0;
107} 112}
108/* end of nss_gns_query.c */ 113/* end of nss_gns_query.c */
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..054417ab5 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,
@@ -1127,97 +1127,81 @@ int
1127main (int argc, 1127main (int argc,
1128 char *const *argv) 1128 char *const *argv)
1129{ 1129{
1130 is_public = -1;
1131 is_shadow = -1;
1132
1133 struct GNUNET_GETOPT_CommandLineOption options[] = { 1130 struct GNUNET_GETOPT_CommandLineOption options[] = {
1134
1135 GNUNET_GETOPT_option_flag ('a', 1131 GNUNET_GETOPT_option_flag ('a',
1136 "add", 1132 "add",
1137 gettext_noop ("add record"), 1133 gettext_noop ("add record"),
1138 &add), 1134 &add),
1139
1140 GNUNET_GETOPT_option_flag ('d', 1135 GNUNET_GETOPT_option_flag ('d',
1141 "delete", 1136 "delete",
1142 gettext_noop ("delete record"), 1137 gettext_noop ("delete record"),
1143 &del), 1138 &del),
1144
1145 GNUNET_GETOPT_option_flag ('D', 1139 GNUNET_GETOPT_option_flag ('D',
1146 "display", 1140 "display",
1147 gettext_noop ("display records"), 1141 gettext_noop ("display records"),
1148 &list), 1142 &list),
1149
1150 GNUNET_GETOPT_option_string ('e', 1143 GNUNET_GETOPT_option_string ('e',
1151 "expiration", 1144 "expiration",
1152 "TIME", 1145 "TIME",
1153 gettext_noop ("expiration time for record to use (for adding only), \"never\" is possible"), 1146 gettext_noop ("expiration time for record to use (for adding only), \"never\" is possible"),
1154 &expirationstring), 1147 &expirationstring),
1155
1156 GNUNET_GETOPT_option_string ('i', 1148 GNUNET_GETOPT_option_string ('i',
1157 "nick", 1149 "nick",
1158 "NICKNAME", 1150 "NICKNAME",
1159 gettext_noop ("set the desired nick name for the zone"), 1151 gettext_noop ("set the desired nick name for the zone"),
1160 &nickstring), 1152 &nickstring),
1161
1162 GNUNET_GETOPT_option_flag ('m', 1153 GNUNET_GETOPT_option_flag ('m',
1163 "monitor", 1154 "monitor",
1164 gettext_noop ("monitor changes in the namestore"), 1155 gettext_noop ("monitor changes in the namestore"),
1165 &monitor), 1156 &monitor),
1166
1167 GNUNET_GETOPT_option_string ('n', 1157 GNUNET_GETOPT_option_string ('n',
1168 "name", 1158 "name",
1169 "NAME", 1159 "NAME",
1170 gettext_noop ("name of the record to add/delete/display"), 1160 gettext_noop ("name of the record to add/delete/display"),
1171 &name), 1161 &name),
1172
1173 GNUNET_GETOPT_option_string ('r', 1162 GNUNET_GETOPT_option_string ('r',
1174 "reverse", 1163 "reverse",
1175 "PKEY", 1164 "PKEY",
1176 gettext_noop ("determine our name for the given PKEY"), 1165 gettext_noop ("determine our name for the given PKEY"),
1177 &reverse_pkey), 1166 &reverse_pkey),
1178
1179
1180
1181 GNUNET_GETOPT_option_string ('t', 1167 GNUNET_GETOPT_option_string ('t',
1182 "type", 1168 "type",
1183 "TYPE", 1169 "TYPE",
1184 gettext_noop ("type of the record to add/delete/display"), 1170 gettext_noop ("type of the record to add/delete/display"),
1185 &typestring), 1171 &typestring),
1186
1187 GNUNET_GETOPT_option_string ('u', 1172 GNUNET_GETOPT_option_string ('u',
1188 "uri", 1173 "uri",
1189 "URI", 1174 "URI",
1190 gettext_noop ("URI to import into our zone"), 1175 gettext_noop ("URI to import into our zone"),
1191 &uri), 1176 &uri),
1192
1193 GNUNET_GETOPT_option_string ('V', 1177 GNUNET_GETOPT_option_string ('V',
1194 "value", 1178 "value",
1195 "VALUE", 1179 "VALUE",
1196 gettext_noop ("value of the record to add/delete"), 1180 gettext_noop ("value of the record to add/delete"),
1197 &value), 1181 &value),
1198
1199 GNUNET_GETOPT_option_flag ('p', 1182 GNUNET_GETOPT_option_flag ('p',
1200 "public", 1183 "public",
1201 gettext_noop ("create or list public record"), 1184 gettext_noop ("create or list public record"),
1202 &is_public), 1185 &is_public),
1203
1204 GNUNET_GETOPT_option_flag ('s', 1186 GNUNET_GETOPT_option_flag ('s',
1205 "shadow", 1187 "shadow",
1206 gettext_noop ("create shadow record (only valid if all other records of the same type have expired"), 1188 gettext_noop ("create shadow record (only valid if all other records of the same type have expired"),
1207 &is_shadow), 1189 &is_shadow),
1208
1209 GNUNET_GETOPT_option_string ('z', 1190 GNUNET_GETOPT_option_string ('z',
1210 "zone", 1191 "zone",
1211 "EGO", 1192 "EGO",
1212 gettext_noop ("name of the ego controlling the zone"), 1193 gettext_noop ("name of the ego controlling the zone"),
1213 &ego_name), 1194 &ego_name),
1214
1215 GNUNET_GETOPT_OPTION_END 1195 GNUNET_GETOPT_OPTION_END
1216 }; 1196 };
1217 1197
1218 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 1198 if (GNUNET_OK !=
1199 GNUNET_STRINGS_get_utf8_args (argc, argv,
1200 &argc, &argv))
1219 return 2; 1201 return 2;
1220 1202
1203 is_public = -1;
1204 is_shadow = -1;
1221 GNUNET_log_setup ("gnunet-namestore", 1205 GNUNET_log_setup ("gnunet-namestore",
1222 "WARNING", 1206 "WARNING",
1223 NULL); 1207 NULL);
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) &&
diff --git a/src/util/client.c b/src/util/client.c
index 7a718fc8d..3479fa971 100644
--- a/src/util/client.c
+++ b/src/util/client.c
@@ -261,11 +261,11 @@ transmit_ready (void *cls)
261 pos = (const char *) cstate->msg; 261 pos = (const char *) cstate->msg;
262 len = ntohs (cstate->msg->size); 262 len = ntohs (cstate->msg->size);
263 GNUNET_assert (cstate->msg_off < len); 263 GNUNET_assert (cstate->msg_off < len);
264 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 264 LOG (GNUNET_ERROR_TYPE_DEBUG,
265 "client: message of type %u trying to send with socket %p (MQ: %p\n", 265 "message of type %u trying to send with socket %p (MQ: %p\n",
266 ntohs(cstate->msg->type), 266 ntohs(cstate->msg->type),
267 cstate->sock, 267 cstate->sock,
268 cstate->mq); 268 cstate->mq);
269 269
270 RETRY: 270 RETRY:
271 ret = GNUNET_NETWORK_socket_send (cstate->sock, 271 ret = GNUNET_NETWORK_socket_send (cstate->sock,
@@ -273,13 +273,13 @@ transmit_ready (void *cls)
273 len - cstate->msg_off); 273 len - cstate->msg_off);
274 if (-1 == ret) 274 if (-1 == ret)
275 { 275 {
276 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 276 LOG (GNUNET_ERROR_TYPE_WARNING,
277 "client: error during sending message of type %u\n", 277 "Error during sending message of type %u\n",
278 ntohs(cstate->msg->type)); 278 ntohs(cstate->msg->type));
279 if (EINTR == errno){ 279 if (EINTR == errno){
280 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 280 LOG (GNUNET_ERROR_TYPE_DEBUG,
281 "client: retrying message of type %u\n", 281 "Retrying message of type %u\n",
282 ntohs(cstate->msg->type)); 282 ntohs(cstate->msg->type));
283 goto RETRY; 283 goto RETRY;
284 } 284 }
285 GNUNET_MQ_inject_error (cstate->mq, 285 GNUNET_MQ_inject_error (cstate->mq,
@@ -290,9 +290,9 @@ transmit_ready (void *cls)
290 cstate->msg_off += ret; 290 cstate->msg_off += ret;
291 if (cstate->msg_off < len) 291 if (cstate->msg_off < len)
292 { 292 {
293 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 293 LOG (GNUNET_ERROR_TYPE_DEBUG,
294 "client: rescheduling message of type %u\n", 294 "rescheduling message of type %u\n",
295 ntohs(cstate->msg->type)); 295 ntohs(cstate->msg->type));
296 cstate->send_task 296 cstate->send_task
297 = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, 297 = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
298 cstate->sock, 298 cstate->sock,
@@ -302,9 +302,9 @@ transmit_ready (void *cls)
302 GNUNET_MQ_impl_send_in_flight (cstate->mq); 302 GNUNET_MQ_impl_send_in_flight (cstate->mq);
303 return; 303 return;
304 } 304 }
305 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 305 LOG (GNUNET_ERROR_TYPE_DEBUG,
306 "client: sending message of type %u successful\n", 306 "sending message of type %u successful\n",
307 ntohs(cstate->msg->type)); 307 ntohs(cstate->msg->type));
308 cstate->msg = NULL; 308 cstate->msg = NULL;
309 GNUNET_MQ_impl_send_continue (cstate->mq); 309 GNUNET_MQ_impl_send_continue (cstate->mq);
310} 310}
@@ -394,9 +394,9 @@ connection_client_destroy_impl (struct GNUNET_MQ_Handle *mq,
394 if (NULL != cstate->retry_task) 394 if (NULL != cstate->retry_task)
395 GNUNET_SCHEDULER_cancel (cstate->retry_task); 395 GNUNET_SCHEDULER_cancel (cstate->retry_task);
396 if (NULL != cstate->sock){ 396 if (NULL != cstate->sock){
397 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 397 LOG (GNUNET_ERROR_TYPE_DEBUG,
398 "client: destroying socket: %p\n", 398 "destroying socket: %p\n",
399 cstate->sock); 399 cstate->sock);
400 GNUNET_NETWORK_socket_close (cstate->sock); 400 GNUNET_NETWORK_socket_close (cstate->sock);
401 } 401 }
402 cancel_aps (cstate); 402 cancel_aps (cstate);
@@ -822,9 +822,9 @@ connection_client_send_impl (struct GNUNET_MQ_Handle *mq,
822 cstate->msg = msg; 822 cstate->msg = msg;
823 cstate->msg_off = 0; 823 cstate->msg_off = 0;
824 if (NULL == cstate->sock){ 824 if (NULL == cstate->sock){
825 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 825 LOG (GNUNET_ERROR_TYPE_DEBUG,
826 "client: message of type %u waiting for socket\n", 826 "message of type %u waiting for socket\n",
827 ntohs(msg->type)); 827 ntohs(msg->type));
828 return; /* still waiting for connection */ 828 return; /* still waiting for connection */
829 } 829 }
830 cstate->send_task 830 cstate->send_task
diff --git a/src/util/mq.c b/src/util/mq.c
index 33bbaa6ad..af700836c 100644
--- a/src/util/mq.c
+++ b/src/util/mq.c
@@ -358,10 +358,10 @@ GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq,
358 GNUNET_assert (NULL == mq->envelope_head); 358 GNUNET_assert (NULL == mq->envelope_head);
359 mq->current_envelope = ev; 359 mq->current_envelope = ev;
360 360
361 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 361 LOG (GNUNET_ERROR_TYPE_DEBUG,
362 "mq: sending message of type %u, queue empty (MQ: %p)\n", 362 "sending message of type %u, queue empty (MQ: %p)\n",
363 ntohs(ev->mh->type), 363 ntohs(ev->mh->type),
364 mq); 364 mq);
365 365
366 mq->send_impl (mq, 366 mq->send_impl (mq,
367 ev->mh, 367 ev->mh,
@@ -459,9 +459,9 @@ impl_send_continue (void *cls)
459 mq->envelope_tail, 459 mq->envelope_tail,
460 mq->current_envelope); 460 mq->current_envelope);
461 461
462 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 462 LOG (GNUNET_ERROR_TYPE_DEBUG,
463 "mq: sending message of type %u from queue\n", 463 "sending message of type %u from queue\n",
464 ntohs(mq->current_envelope->mh->type)); 464 ntohs(mq->current_envelope->mh->type));
465 465
466 mq->send_impl (mq, 466 mq->send_impl (mq,
467 mq->current_envelope->mh, 467 mq->current_envelope->mh,
@@ -851,9 +851,9 @@ GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq)
851 ev); 851 ev);
852 GNUNET_assert (0 < mq->queue_length); 852 GNUNET_assert (0 < mq->queue_length);
853 mq->queue_length--; 853 mq->queue_length--;
854 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 854 LOG (GNUNET_ERROR_TYPE_DEBUG,
855 "MQ destroy drops message of type %u\n", 855 "MQ destroy drops message of type %u\n",
856 ntohs (ev->mh->type)); 856 ntohs (ev->mh->type));
857 GNUNET_MQ_discard (ev); 857 GNUNET_MQ_discard (ev);
858 } 858 }
859 if (NULL != mq->current_envelope) 859 if (NULL != mq->current_envelope)
@@ -861,9 +861,9 @@ GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq)
861 /* we can only discard envelopes that 861 /* we can only discard envelopes that
862 * are not queued! */ 862 * are not queued! */
863 mq->current_envelope->parent_queue = NULL; 863 mq->current_envelope->parent_queue = NULL;
864 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 864 LOG (GNUNET_ERROR_TYPE_DEBUG,
865 "MQ destroy drops current message of type %u\n", 865 "MQ destroy drops current message of type %u\n",
866 ntohs (mq->current_envelope->mh->type)); 866 ntohs (mq->current_envelope->mh->type));
867 GNUNET_MQ_discard (mq->current_envelope); 867 GNUNET_MQ_discard (mq->current_envelope);
868 mq->current_envelope = NULL; 868 mq->current_envelope = NULL;
869 GNUNET_assert (0 < mq->queue_length); 869 GNUNET_assert (0 < mq->queue_length);
@@ -946,9 +946,9 @@ GNUNET_MQ_send_cancel (struct GNUNET_MQ_Envelope *ev)
946 mq->envelope_tail, 946 mq->envelope_tail,
947 mq->current_envelope); 947 mq->current_envelope);
948 948
949 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 949 LOG (GNUNET_ERROR_TYPE_DEBUG,
950 "mq: sending canceled message of type %u queue\n", 950 "sending canceled message of type %u queue\n",
951 ntohs(ev->mh->type)); 951 ntohs(ev->mh->type));
952 952
953 mq->send_impl (mq, 953 mq->send_impl (mq,
954 mq->current_envelope->mh, 954 mq->current_envelope->mh,
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c
index bd46b4fbb..b92fd6a02 100644
--- a/src/util/resolver_api.c
+++ b/src/util/resolver_api.c
@@ -500,11 +500,13 @@ handle_response (void *cls,
500 GNUNET_free (nret); 500 GNUNET_free (nret);
501 } 501 }
502 /* finally, make termination call */ 502 /* finally, make termination call */
503 rh->name_callback (rh->cls, 503 if (GNUNET_SYSERR != rh->was_transmitted)
504 NULL); 504 rh->name_callback (rh->cls,
505 NULL);
505 } 506 }
506 if (NULL != rh->addr_callback) 507 if ( (NULL != rh->addr_callback) &&
507 rh->addr_callback (rh->cls, 508 (GNUNET_SYSERR != rh->was_transmitted) )
509 rh->addr_callback (rh->cls,
508 NULL, 510 NULL,
509 0); 511 0);
510 } 512 }
@@ -637,6 +639,7 @@ numeric_resolution (void *cls)
637 (const struct sockaddr *) &v4, 639 (const struct sockaddr *) &v4,
638 sizeof (v4)); 640 sizeof (v4));
639 if ( (rh->af == AF_UNSPEC) && 641 if ( (rh->af == AF_UNSPEC) &&
642 (GNUNET_SYSERR != rh->was_transmitted) &&
640 (1 == inet_pton (AF_INET6, 643 (1 == inet_pton (AF_INET6,
641 hostname, 644 hostname,
642 &v6.sin6_addr)) ) 645 &v6.sin6_addr)) )
@@ -646,9 +649,10 @@ numeric_resolution (void *cls)
646 (const struct sockaddr *) &v6, 649 (const struct sockaddr *) &v6,
647 sizeof (v6)); 650 sizeof (v6));
648 } 651 }
649 rh->addr_callback (rh->cls, 652 if (GNUNET_SYSERR != rh->was_transmitted)
650 NULL, 653 rh->addr_callback (rh->cls,
651 0); 654 NULL,
655 0);
652 GNUNET_free (rh); 656 GNUNET_free (rh);
653 return; 657 return;
654 } 658 }
@@ -661,9 +665,10 @@ numeric_resolution (void *cls)
661 rh->addr_callback (rh->cls, 665 rh->addr_callback (rh->cls,
662 (const struct sockaddr *) &v6, 666 (const struct sockaddr *) &v6,
663 sizeof (v6)); 667 sizeof (v6));
664 rh->addr_callback (rh->cls, 668 if (GNUNET_SYSERR != rh->was_transmitted)
665 NULL, 669 rh->addr_callback (rh->cls,
666 0); 670 NULL,
671 0);
667 GNUNET_free (rh); 672 GNUNET_free (rh);
668 return; 673 return;
669 } 674 }
@@ -725,9 +730,10 @@ loopback_resolution (void *cls)
725 GNUNET_break (0); 730 GNUNET_break (0);
726 break; 731 break;
727 } 732 }
728 rh->addr_callback (rh->cls, 733 if (GNUNET_SYSERR != rh->was_transmitted)
729 NULL, 734 rh->addr_callback (rh->cls,
730 0); 735 NULL,
736 0);
731 LOG (GNUNET_ERROR_TYPE_DEBUG, 737 LOG (GNUNET_ERROR_TYPE_DEBUG,
732 "Finished resolving hostname `%s'.\n", 738 "Finished resolving hostname `%s'.\n",
733 (const char *) &rh[1]); 739 (const char *) &rh[1]);
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index 51afc85e5..e00ca444b 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -520,8 +520,8 @@ GNUNET_SCHEDULER_shutdown ()
520{ 520{
521 struct GNUNET_SCHEDULER_Task *pos; 521 struct GNUNET_SCHEDULER_Task *pos;
522 522
523 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 523 LOG (GNUNET_ERROR_TYPE_DEBUG,
524 "GNUNET_SCHEDULER_shutdown\n"); 524 "GNUNET_SCHEDULER_shutdown\n");
525 if (NULL != install_parent_control_task) 525 if (NULL != install_parent_control_task)
526 { 526 {
527 GNUNET_SCHEDULER_cancel (install_parent_control_task); 527 GNUNET_SCHEDULER_cancel (install_parent_control_task);
@@ -1953,7 +1953,7 @@ GNUNET_SCHEDULER_task_ready (struct GNUNET_SCHEDULER_Task *task,
1953/** 1953/**
1954 * Function called by external event loop implementations to tell the 1954 * Function called by external event loop implementations to tell the
1955 * scheduler to run some of the tasks that are ready. Must be called 1955 * scheduler to run some of the tasks that are ready. Must be called
1956 * only after #GNUNET_SCHEDULER_driver_init has been called and before 1956 * only after #GNUNET_SCHEDULER_driver_init has been called and before
1957 * #GNUNET_SCHEDULER_driver_done is called. 1957 * #GNUNET_SCHEDULER_driver_done is called.
1958 * This function may return even though there are tasks left to run 1958 * This function may return even though there are tasks left to run
1959 * just to give other tasks a chance as well. If we return #GNUNET_YES, 1959 * just to give other tasks a chance as well. If we return #GNUNET_YES,
@@ -2023,9 +2023,9 @@ GNUNET_SCHEDULER_do_work (struct GNUNET_SCHEDULER_Handle *sh)
2023 * waiting for the timeout, so we handle this gracefully. It might 2023 * waiting for the timeout, so we handle this gracefully. It might
2024 * also be a programming error in the driver though. 2024 * also be a programming error in the driver though.
2025 */ 2025 */
2026 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2026 LOG (GNUNET_ERROR_TYPE_DEBUG,
2027 "GNUNET_SCHEDULER_do_work did not find any ready " 2027 "GNUNET_SCHEDULER_do_work did not find any ready "
2028 "tasks and timeout has not been reached yet."); 2028 "tasks and timeout has not been reached yet.\n");
2029 return GNUNET_NO; 2029 return GNUNET_NO;
2030 } 2030 }
2031 /** 2031 /**
@@ -2128,7 +2128,7 @@ GNUNET_SCHEDULER_do_work (struct GNUNET_SCHEDULER_Handle *sh)
2128 * Function called by external event loop implementations to initialize 2128 * Function called by external event loop implementations to initialize
2129 * the scheduler. An external implementation has to provide @a driver 2129 * the scheduler. An external implementation has to provide @a driver
2130 * which contains callbacks for the scheduler (see definition of struct 2130 * which contains callbacks for the scheduler (see definition of struct
2131 * #GNUNET_SCHEDULER_Driver). The callbacks are used to instruct the 2131 * #GNUNET_SCHEDULER_Driver). The callbacks are used to instruct the
2132 * external implementation to watch for events. If it detects any of 2132 * external implementation to watch for events. If it detects any of
2133 * those events it is expected to call #GNUNET_SCHEDULER_do_work to let 2133 * those events it is expected to call #GNUNET_SCHEDULER_do_work to let
2134 * the scheduler handle it. If an event is related to a specific task 2134 * the scheduler handle it. If an event is related to a specific task
@@ -2137,11 +2137,11 @@ GNUNET_SCHEDULER_do_work (struct GNUNET_SCHEDULER_Handle *sh)
2137 * before by calling #GNUNET_SCHEDULER_task_ready. 2137 * before by calling #GNUNET_SCHEDULER_task_ready.
2138 2138
2139 * This function has to be called before any tasks are scheduled and 2139 * This function has to be called before any tasks are scheduled and
2140 * before GNUNET_SCHEDULER_do_work is called for the first time. It 2140 * before GNUNET_SCHEDULER_do_work is called for the first time. It
2141 * allocates resources that have to be freed again by calling 2141 * allocates resources that have to be freed again by calling
2142 * #GNUNET_SCHEDULER_driver_done. 2142 * #GNUNET_SCHEDULER_driver_done.
2143 * 2143 *
2144 * This function installs the same signal handlers as 2144 * This function installs the same signal handlers as
2145 * #GNUNET_SCHEDULER_run. This means SIGTERM (and other similar signals) 2145 * #GNUNET_SCHEDULER_run. This means SIGTERM (and other similar signals)
2146 * will induce a call to #GNUNET_SCHEDULER_shutdown during the next 2146 * will induce a call to #GNUNET_SCHEDULER_shutdown during the next
2147 * call to #GNUNET_SCHEDULER_do_work. As a result, SIGTERM causes all 2147 * call to #GNUNET_SCHEDULER_do_work. As a result, SIGTERM causes all
@@ -2228,7 +2228,7 @@ GNUNET_SCHEDULER_driver_init (const struct GNUNET_SCHEDULER_Driver *driver)
2228 * by external event loop implementations after the scheduler has 2228 * by external event loop implementations after the scheduler has
2229 * shut down. This is the case if both of the following conditions 2229 * shut down. This is the case if both of the following conditions
2230 * are met: 2230 * are met:
2231 * 2231 *
2232 * - all tasks the scheduler has added through the driver's add 2232 * - all tasks the scheduler has added through the driver's add
2233 * callback have been removed again through the driver's del 2233 * callback have been removed again through the driver's del
2234 * callback 2234 * callback
@@ -2376,8 +2376,8 @@ select_loop (struct GNUNET_SCHEDULER_Handle *sh, struct DriverContext *context)
2376 } 2376 }
2377 if (GNUNET_YES == GNUNET_SCHEDULER_do_work (sh)) 2377 if (GNUNET_YES == GNUNET_SCHEDULER_do_work (sh))
2378 { 2378 {
2379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2379 LOG (GNUNET_ERROR_TYPE_DEBUG,
2380 "scheduler has more tasks ready!\n"); 2380 "scheduler has more tasks ready!\n");
2381 } 2381 }
2382 } 2382 }
2383 GNUNET_NETWORK_fdset_destroy (rs); 2383 GNUNET_NETWORK_fdset_destroy (rs);
@@ -2451,7 +2451,7 @@ select_set_wakeup (void *cls,
2451 struct GNUNET_TIME_Absolute dt) 2451 struct GNUNET_TIME_Absolute dt)
2452{ 2452{
2453 struct DriverContext *context = cls; 2453 struct DriverContext *context = cls;
2454 2454
2455 GNUNET_assert (NULL != context); 2455 GNUNET_assert (NULL != context);
2456 context->timeout = dt; 2456 context->timeout = dt;
2457} 2457}