diff options
author | ng0 <ng0@n0.is> | 2018-03-05 07:46:55 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2018-03-05 07:46:55 +0000 |
commit | d5a7fa6adddccf17296b44a832eb393fd1cebe1b (patch) | |
tree | db54c8909fb3a1b68bda7276a4ae8a972403829b /src/gns | |
parent | b48942b46913de4876431e3574a7ace641fb548c (diff) | |
parent | 1f46cd73049570f21ff47cd3ee81ea88da45af07 (diff) | |
download | gnunet-d5a7fa6adddccf17296b44a832eb393fd1cebe1b.tar.gz gnunet-d5a7fa6adddccf17296b44a832eb393fd1cebe1b.zip |
Merge branch 'master' of gnunet.org:gnunet
Diffstat (limited to 'src/gns')
24 files changed, 629 insertions, 561 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? |
17 | MAX_PARALLEL_BACKGROUND_QUERIES = 1000 | 17 | MAX_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). | ||
23 | INTERCEPT_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] |
26 | BINARY = gnunet-gns-proxy | 35 | BINARY = 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; | |||
56 | static char *lookup_type; | 56 | static char *lookup_type; |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * Identity of the zone to use for the lookup (-z option) | ||
60 | */ | ||
61 | static char *zone_ego_name; | ||
62 | |||
63 | /** | ||
64 | * Public key of the zone to use for the lookup (-p option) | ||
65 | */ | ||
66 | static 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 | */ |
71 | static enum GNUNET_GNS_LocalOptions local_options; | 61 | static enum GNUNET_GNS_LocalOptions local_options; |
@@ -105,6 +95,15 @@ static struct GNUNET_IDENTITY_Operation *id_op; | |||
105 | */ | 95 | */ |
106 | static struct GNUNET_SCHEDULER_Task *tt; | 96 | static 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 | */ | ||
105 | static 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 | */ |
302 | static void | 293 | static const char * |
303 | identity_master_cb (void *cls, | 294 | get_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; | 313 | static void |
330 | lookup_with_public_key (&pkey); | 314 | eat_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 @@ | |||
44 | struct GnsClient; | 44 | struct 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 | */ |
49 | struct ClientLookupHandle | 49 | struct 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 | */ | ||
79 | struct GnsClient | 83 | struct 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; | |||
143 | static struct GNUNET_NAMECACHE_Handle *namecache_handle; | 147 | static struct GNUNET_NAMECACHE_Handle *namecache_handle; |
144 | 148 | ||
145 | /** | 149 | /** |
146 | * Our handle to the identity service | ||
147 | */ | ||
148 | static 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 | */ | ||
154 | static struct GNUNET_IDENTITY_Operation *identity_op; | ||
155 | |||
156 | /** | ||
157 | * #GNUNET_YES if ipv6 is supported | 150 | * #GNUNET_YES if ipv6 is supported |
158 | */ | 151 | */ |
159 | static int v6_enabled; | 152 | static int v6_enabled; |
@@ -188,7 +181,7 @@ static struct GNS_TopLevelDomain *tld_tail; | |||
188 | */ | 181 | */ |
189 | int | 182 | int |
190 | GNS_find_tld (const char *tld_str, | 183 | GNS_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 | */ | ||
214 | const char * | ||
215 | GNS_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 | |||
223 | shutdown_task (void *cls) | 236 | shutdown_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 | */ | ||
473 | static void | ||
474 | identity_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 | */ |
37 | int | 37 | int |
38 | GNS_find_tld (const char *tld_str, | 38 | GNS_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 | */ | ||
49 | const char * | ||
50 | GNS_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 | |||
73 | static struct GNUNET_DNS_Handle *dns_handle; | 74 | static struct GNUNET_DNS_Handle *dns_handle; |
74 | 75 | ||
75 | /** | 76 | /** |
76 | * Key of the zone we start lookups in. | ||
77 | */ | ||
78 | static struct GNUNET_CRYPTO_EcdsaPublicKey zone; | ||
79 | |||
80 | /** | ||
81 | * Head of the DLL. | 77 | * Head of the DLL. |
82 | */ | 78 | */ |
83 | static struct InterceptLookupHandle *ilh_head; | 79 | static 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 | */ |
358 | int | 354 | int |
359 | GNS_interceptor_init (const struct GNUNET_CRYPTO_EcdsaPublicKey *gnu_zone, | 355 | GNS_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 | */ |
38 | int | 37 | int |
39 | GNS_interceptor_init (const struct GNUNET_CRYPTO_EcdsaPublicKey *gnu_zone, | 38 | GNS_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 | */ |
484 | static int | 489 | /* dead, but keep for now */ int |
485 | is_canonical (const char *name) | 490 | is_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 | */ | ||
1429 | static void | ||
1430 | handle_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 | */ | ||
2600 | int | ||
2601 | is_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, | |||
100 | void | 100 | void |
101 | GNS_resolver_lookup_cancel (struct GNS_ResolverHandle *rh); | 101 | GNS_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 | */ | ||
111 | int | ||
112 | is_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 | */ | ||
51 | static 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 | */ | ||
69 | static 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 | */ |
85 | enum nss_status _nss_gns_gethostbyname2_r( | 56 | enum 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 | */ |
215 | enum nss_status _nss_gns_gethostbyname_r ( | 183 | enum 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 | */ |
247 | enum nss_status _nss_gns_gethostbyaddr_r( | 216 | enum 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 | ||
25 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 25 | rm -rf /tmp/test-gnunet-gns-peer-1/ |
26 | 26 | ||
27 | TEST_DOMAIN_PLUS="www.gnu" | ||
28 | TEST_DOMAIN_DNS="www3.gnu" | ||
29 | TEST_IP_PLUS="127.0.0.1" | 27 | TEST_IP_PLUS="127.0.0.1" |
30 | TEST_IP_DNS="131.159.74.67" | 28 | TEST_IP_DNS="131.159.74.67" |
31 | TEST_RECORD_CNAME_SERVER="server" | 29 | TEST_RECORD_CNAME_SERVER="server" |
@@ -34,35 +32,38 @@ TEST_RECORD_CNAME_DNS="gnunet.org" | |||
34 | TEST_RECORD_NAME_SERVER="server" | 32 | TEST_RECORD_NAME_SERVER="server" |
35 | TEST_RECORD_NAME_PLUS="www" | 33 | TEST_RECORD_NAME_PLUS="www" |
36 | TEST_RECORD_NAME_DNS="www3" | 34 | TEST_RECORD_NAME_DNS="www3" |
35 | MY_EGO="myego" | ||
36 | TEST_DOMAIN_PLUS="www.$MY_EGO" | ||
37 | TEST_DOMAIN_DNS="www3.$MY_EGO" | ||
37 | which timeout &> /dev/null && DO_TIMEOUT="timeout 15" | 38 | which timeout &> /dev/null && DO_TIMEOUT="timeout 15" |
38 | 39 | ||
39 | gnunet-arm -s -c test_gns_lookup.conf | 40 | gnunet-arm -s -c test_gns_lookup.conf |
40 | gnunet-identity -C testego -c test_gns_lookup.conf | 41 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf |
41 | gnunet-namestore -p -z testego -a -n $TEST_RECORD_NAME_DNS -t CNAME -V $TEST_RECORD_CNAME_DNS -e never -c test_gns_lookup.conf | 42 | gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME_DNS -t CNAME -V $TEST_RECORD_CNAME_DNS -e never -c test_gns_lookup.conf |
42 | gnunet-namestore -p -z testego -a -n $TEST_RECORD_NAME_PLUS -t CNAME -V $TEST_RECORD_CNAME_PLUS -e never -c test_gns_lookup.conf | 43 | gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME_PLUS -t CNAME -V $TEST_RECORD_CNAME_PLUS -e never -c test_gns_lookup.conf |
43 | gnunet-namestore -p -z testego -a -n $TEST_RECORD_CNAME_SERVER -t A -V $TEST_IP_PLUS -e never -c test_gns_lookup.conf | 44 | gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_CNAME_SERVER -t A -V $TEST_IP_PLUS -e never -c test_gns_lookup.conf |
44 | RES_CNAME=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_DOMAIN_PLUS -t A -c test_gns_lookup.conf` | 45 | RES_CNAME=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t A -c test_gns_lookup.conf` |
45 | RES_CNAME_RAW=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_DOMAIN_PLUS -t CNAME -c test_gns_lookup.conf` | 46 | RES_CNAME_RAW=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t CNAME -c test_gns_lookup.conf` |
46 | RES_CNAME_DNS=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_DOMAIN_DNS -t A -c test_gns_lookup.conf` | 47 | RES_CNAME_DNS=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_DNS -t A -c test_gns_lookup.conf` |
47 | TESTEGOZONE=`gnunet-identity -c test_gns_lookup.conf -d | awk '{print $3}'` | 48 | TESTEGOZONE=`gnunet-identity -c test_gns_lookup.conf -d | awk '{print $3}'` |
48 | gnunet-namestore -p -z testego -d -n $TEST_RECORD_NAME_DNS -t CNAME -V $TEST_RECORD_CNAME_DNS -e never -c test_gns_lookup.conf | 49 | gnunet-namestore -p -z $MY_EGO -d -n $TEST_RECORD_NAME_DNS -t CNAME -V $TEST_RECORD_CNAME_DNS -e never -c test_gns_lookup.conf |
49 | gnunet-namestore -p -z testego -d -n $TEST_RECORD_NAME_PLUS -t CNAME -V $TEST_RECORD_CNAME_PLUS -e never -c test_gns_lookup.conf | 50 | gnunet-namestore -p -z $MY_EGO -d -n $TEST_RECORD_NAME_PLUS -t CNAME -V $TEST_RECORD_CNAME_PLUS -e never -c test_gns_lookup.conf |
50 | gnunet-namestore -p -z testego -d -n $TEST_RECORD_CNAME_SERVER -t A -V $TEST_IP_PLUS -e never -c test_gns_lookup.conf | 51 | gnunet-namestore -p -z $MY_EGO -d -n $TEST_RECORD_CNAME_SERVER -t A -V $TEST_IP_PLUS -e never -c test_gns_lookup.conf |
51 | gnunet-identity -D testego -c test_gns_lookup.conf | 52 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf |
52 | gnunet-arm -e -c test_gns_lookup.conf | 53 | gnunet-arm -e -c test_gns_lookup.conf |
53 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 54 | rm -rf /tmp/test-gnunet-gns-peer-1/ |
54 | 55 | ||
55 | if [ "$RES_CNAME_RAW" == "server.$TESTEGOZONE.zkey" ] | 56 | if [ "$RES_CNAME_RAW" == "server.$TESTEGOZONE" ] |
56 | then | 57 | then |
57 | echo "PASS: CNAME resulution from GNS" | 58 | echo "PASS: CNAME resolution from GNS" |
58 | else | 59 | else |
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 |
61 | fi | 62 | fi |
62 | 63 | ||
63 | if [ "$RES_CNAME" == "$TEST_IP_PLUS" ] | 64 | if [ "$RES_CNAME" == "$TEST_IP_PLUS" ] |
64 | then | 65 | then |
65 | echo "PASS: IP resulution from GNS" | 66 | echo "PASS: IP resolution from GNS" |
66 | else | 67 | else |
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 | ||
71 | if [ "$RES_CNAME_DNS" == "$TEST_IP_DNS" ] | 72 | if [ "$RES_CNAME_DNS" == "$TEST_IP_DNS" ] |
72 | then | 73 | then |
73 | echo "PASS: IP resulution from DNS" | 74 | echo "PASS: IP resolution from DNS" |
74 | exit 0 | 75 | exit 0 |
75 | else | 76 | else |
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 |
78 | fi | 79 | fi |
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 |
11 | if test $? != 0 | 11 | if test $? != 0 |
12 | then | 12 | then |
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 |
15 | fi | 15 | fi |
16 | 16 | ||
17 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 17 | rm -rf /tmp/test-gnunet-gns-peer-1/ |
18 | MY_EGO="myego" | ||
19 | OTHER_EGO="delegatedego" | ||
20 | FINAL_LABEL="www" | ||
21 | DELEGATION_LABEL="b" | ||
18 | 22 | ||
19 | TEST_IP="127.0.0.1" | 23 | TEST_IP="127.0.0.1" |
20 | gnunet-arm -s -c test_gns_lookup.conf | 24 | gnunet-arm -s -c test_gns_lookup.conf |
21 | gnunet-identity -C delegatedego -c test_gns_lookup.conf | 25 | gnunet-identity -C $OTHER_EGO -c test_gns_lookup.conf |
22 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}') | 26 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep $OTHER_EGO | awk '{print $3}') |
23 | gnunet-identity -C testego -c test_gns_lookup.conf | 27 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf |
24 | gnunet-namestore -p -z testego -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | 28 | gnunet-namestore -p -z $MY_EGO -a -n $DELEGATION_LABEL -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf |
25 | gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | 29 | gnunet-namestore -p -z $OTHER_EGO -a -n $FINAL_LABEL -t A -V $TEST_IP -e never -c test_gns_lookup.conf |
26 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.b.gnu -t A -c test_gns_lookup.conf` | 30 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u $FINAL_LABEL.$DELEGATION_LABEL.$MY_EGO -t A -c test_gns_lookup.conf` |
27 | gnunet-namestore -z testego -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | 31 | gnunet-namestore -z $MY_EGO -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf |
28 | gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | 32 | gnunet-namestore -z $OTHER_EGO -d -n $FINAL_LABEL -t A -V $TEST_IP -e never -c test_gns_lookup.conf |
29 | gnunet-arm -e -c test_gns_lookup.conf | 33 | gnunet-arm -e -c test_gns_lookup.conf |
30 | 34 | ||
31 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 35 | rm -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 |
11 | if test $? != 0 | 11 | if test $? != 0 |
12 | then | 12 | then |
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 |
15 | fi | 15 | fi |
16 | 16 | ||
17 | TEST_IP="127.0.0.1" | 17 | TEST_IP="127.0.0.1" |
18 | MY_EGO="myego" | ||
19 | OTHER_EGO="delegatedego" | ||
20 | |||
21 | |||
18 | gnunet-arm -s -c test_gns_lookup.conf | 22 | gnunet-arm -s -c test_gns_lookup.conf |
19 | gnunet-identity -C delegatedego -c test_gns_lookup.conf | 23 | gnunet-identity -C $OTHER_EGO -c test_gns_lookup.conf |
20 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}') | 24 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep $OTHER_EGO | awk '{print $3}') |
21 | gnunet-identity -C testego -c test_gns_lookup.conf | 25 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf |
22 | gnunet-namestore -p -z testego -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | 26 | gnunet-namestore -p -z $MY_EGO -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf |
23 | gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | 27 | gnunet-namestore -p -z $OTHER_EGO -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf |
24 | gnunet-arm -i gns -c test_gns_lookup.conf | 28 | gnunet-arm -i gns -c test_gns_lookup.conf |
25 | sleep 0.5 | 29 | sleep 0.5 |
26 | gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | 30 | gnunet-namestore -z $OTHER_EGO -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf |
27 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.b.gnu -t A -c test_gns_lookup.conf` | 31 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.b.$MY_EGO -t A -c test_gns_lookup.conf` |
28 | gnunet-namestore -z testego -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | 32 | gnunet-namestore -z $MY_EGO -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf |
29 | gnunet-arm -e -c test_gns_lookup.conf | 33 | gnunet-arm -e -c test_gns_lookup.conf |
30 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 34 | rm -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 |
27 | TEST_RECORD_NAME="homepage" | 27 | TEST_RECORD_NAME="homepage" |
28 | # various names we will use for resolution | ||
29 | TEST_DOMAIN="www.${TEST_RECORD_NAME}.gnu" | ||
30 | TEST_DOMAIN_ALT="${TEST_RECORD_NAME}.gnu" | ||
31 | TEST_DOMAIN_ALT2="uk.${TEST_RECORD_NAME}.gnu" | ||
32 | 28 | ||
33 | if ! nslookup gnunet.org $TEST_IP_GNS2DNS &> /dev/null | 29 | if ! nslookup gnunet.org $TEST_IP_GNS2DNS &> /dev/null |
34 | then | 30 | then |
@@ -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 |
43 | TEST_RECORD_GNS2DNS="gnunet.org@${TEST_RESOLVER_LABEL}.+" | 39 | TEST_RECORD_GNS2DNS="gnunet.org@${TEST_RESOLVER_LABEL}.+" |
44 | 40 | ||
41 | MY_EGO="myego" | ||
42 | # various names we will use for resolution | ||
43 | TEST_DOMAIN="www.${TEST_RECORD_NAME}.$MY_EGO" | ||
44 | TEST_DOMAIN_ALT="${TEST_RECORD_NAME}.$MY_EGO" | ||
45 | TEST_DOMAIN_ALT2="uk.${TEST_RECORD_NAME}.$MY_EGO" | ||
46 | |||
47 | |||
45 | gnunet-arm -s -c test_gns_lookup.conf | 48 | gnunet-arm -s -c test_gns_lookup.conf |
46 | gnunet-identity -C testego -c test_gns_lookup.conf | 49 | gnunet-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 |
49 | gnunet-namestore -p -z testego -a -n $TEST_RESOLVER_LABEL -t A -V $TEST_IP_GNS2DNS -e never -c test_gns_lookup.conf | 52 | gnunet-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 |
51 | gnunet-namestore -p -z testego -a -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS -e never -c test_gns_lookup.conf | 54 | gnunet-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 | ||
53 | which timeout &> /dev/null && DO_TIMEOUT="timeout 15" | 56 | which timeout &> /dev/null && DO_TIMEOUT="timeout 15" |
54 | 57 | ||
58 | echo "EGOs:" | ||
59 | gnunet-identity -d | ||
60 | |||
55 | # lookup 'www.gnunet.org', IPv4 | 61 | # lookup 'www.gnunet.org', IPv4 |
56 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_DOMAIN -t A -c test_gns_lookup.conf` | 62 | RES_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 |
58 | RES_IP6=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_DOMAIN -t AAAA -c test_gns_lookup.conf` | 64 | RES_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 |
60 | RES_IP_ALT=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_DOMAIN_ALT -t A -c test_gns_lookup.conf` | 66 | RES_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 |
62 | RES_IP_ALT2=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_DOMAIN_ALT2 -t A -c test_gns_lookup.conf` | 68 | RES_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 |
65 | gnunet-namestore -z testego -d -n $TEST_RESOLVER_LABEL -t A -V $TEST_IP_GNS2DNS -e never -c test_gns_lookup.conf | 71 | gnunet-namestore -z $MY_EGO -d -n $TEST_RESOLVER_LABEL -t A -V $TEST_IP_GNS2DNS -e never -c test_gns_lookup.conf |
66 | gnunet-namestore -z testego -d -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS -e never -c test_gns_lookup.conf | 72 | gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS -e never -c test_gns_lookup.conf |
67 | gnunet-identity -D testego -c test_gns_lookup.conf | 73 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf |
68 | gnunet-arm -e -c test_gns_lookup.conf | 74 | gnunet-arm -e -c test_gns_lookup.conf |
69 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 75 | rm -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 |
14 | fi | 14 | fi |
15 | MY_EGO="myego" | ||
15 | 16 | ||
16 | rm -rf `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f` | 17 | rm -rf `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f` |
17 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | 18 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" |
18 | TEST_IP="dead::beef" | 19 | TEST_IP="dead::beef" |
19 | gnunet-arm -s -c test_gns_lookup.conf | 20 | gnunet-arm -s -c test_gns_lookup.conf |
20 | gnunet-identity -C testego -c test_gns_lookup.conf | 21 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf |
21 | gnunet-namestore -p -z testego -a -n www -t AAAA -V $TEST_IP -e never -c test_gns_lookup.conf | 22 | gnunet-namestore -p -z $MY_EGO -a -n www -t AAAA -V $TEST_IP -e never -c test_gns_lookup.conf |
22 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.gnu -t AAAA -c test_gns_lookup.conf` | 23 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.$MY_EGO -t AAAA -c test_gns_lookup.conf` |
23 | gnunet-namestore -z testego -d -n www -t AAAA -V $TEST_IP -e never -c test_gns_lookup.conf | 24 | gnunet-namestore -z $MY_EGO -d -n www -t AAAA -V $TEST_IP -e never -c test_gns_lookup.conf |
24 | gnunet-identity -D testego -c test_gns_lookup.conf | 25 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf |
25 | gnunet-arm -e -c test_gns_lookup.conf | 26 | gnunet-arm -e -c test_gns_lookup.conf |
26 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 27 | rm -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 | |||
16 | rm -rf `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f` | 16 | rm -rf `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f` |
17 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | 17 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" |
18 | TEST_IP="127.0.0.1" | 18 | TEST_IP="127.0.0.1" |
19 | MY_EGO="myego" | ||
20 | LABEL="www" | ||
19 | gnunet-arm -s -c test_gns_lookup.conf | 21 | gnunet-arm -s -c test_gns_lookup.conf |
20 | gnunet-identity -C testego -c test_gns_lookup.conf | 22 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf |
21 | gnunet-namestore -p -z testego -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | 23 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t A -V $TEST_IP -e never -c test_gns_lookup.conf |
22 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.gnu -t A -c test_gns_lookup.conf` | 24 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$MY_EGO -t A -c test_gns_lookup.conf` |
23 | gnunet-namestore -z testego -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | 25 | gnunet-namestore -z $MY_EGO -d -n $LABEL -t A -V $TEST_IP -e never -c test_gns_lookup.conf |
24 | gnunet-identity -D testego -c test_gns_lookup.conf | 26 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf |
25 | gnunet-arm -e -c test_gns_lookup.conf | 27 | gnunet-arm -e -c test_gns_lookup.conf |
26 | 28 | ||
27 | if [ "$RES_IP" == "$TEST_IP" ] | 29 | if [ "$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 | |||
16 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 16 | rm -rf /tmp/test-gnunet-gns-peer-1/ |
17 | which timeout &> /dev/null && DO_TIMEOUT="timeout 5" | 17 | which timeout &> /dev/null && DO_TIMEOUT="timeout 5" |
18 | 18 | ||
19 | TEST_MX="5,mail.gnu" | 19 | MY_EGO="myego" |
20 | TEST_MX="5,mail.+" | ||
20 | gnunet-arm -s -c test_gns_lookup.conf | 21 | gnunet-arm -s -c test_gns_lookup.conf |
21 | gnunet-identity -C testego -c test_gns_lookup.conf | 22 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf |
22 | gnunet-namestore -p -z testego -a -n www -t MX -V "$TEST_MX" -e never -c test_gns_lookup.conf | 23 | PKEY=`gnunet-identity -d | grep "$MY_EGO - " | awk '{print $3'}` |
24 | WANT_MX="5,mail.$PKEY" | ||
25 | gnunet-namestore -p -z $MY_EGO -a -n www -t MX -V "$TEST_MX" -e never -c test_gns_lookup.conf | ||
23 | 26 | ||
24 | RES_MX=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.gnu -t MX -c test_gns_lookup.conf` | 27 | RES_MX=`$DO_TIMEOUT gnunet-gns --raw -u www.$MY_EGO -t MX -c test_gns_lookup.conf` |
25 | gnunet-namestore -z testego -d -n www -t MX -V "$TEST_MX" -e never -c test_gns_lookup.conf | 28 | gnunet-namestore -z $MY_EGO -d -n www -t MX -V "$TEST_MX" -e never -c test_gns_lookup.conf |
26 | gnunet-identity -D testego -c test_gns_lookup.conf | 29 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf |
27 | gnunet-arm -e -c test_gns_lookup.conf | 30 | gnunet-arm -e -c test_gns_lookup.conf |
28 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 31 | rm -rf /tmp/test-gnunet-gns-peer-1/ |
29 | 32 | ||
30 | if [ "$RES_MX" == "$TEST_MX" ] | 33 | if [ "$RES_MX" == "$WANT_MX" ] |
31 | then | 34 | then |
32 | exit 0 | 35 | exit 0 |
33 | else | 36 | else |
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 |
36 | fi | 39 | fi |
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" | |||
17 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 17 | rm -rf /tmp/test-gnunet-gns-peer-1/ |
18 | 18 | ||
19 | TEST_IP="127.0.0.1" | 19 | TEST_IP="127.0.0.1" |
20 | MY_EGO="myego" | ||
20 | gnunet-arm -s -c test_gns_lookup.conf | 21 | gnunet-arm -s -c test_gns_lookup.conf |
21 | gnunet-identity -C delegatedego -c test_gns_lookup.conf | 22 | gnunet-identity -C delegatedego -c test_gns_lookup.conf |
22 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}') | 23 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}') |
23 | gnunet-identity -C testego -c test_gns_lookup.conf | 24 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf |
24 | gnunet-namestore -p -z testego -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | 25 | gnunet-namestore -p -z $MY_EGO -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf |
25 | gnunet-namestore -p -z delegatedego -a -n '+' -t A -V $TEST_IP -e never -c test_gns_lookup.conf | 26 | gnunet-namestore -p -z delegatedego -a -n '+' -t A -V $TEST_IP -e never -c test_gns_lookup.conf |
26 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u b.gnu -t A -c test_gns_lookup.conf` | 27 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u b.$MY_EGO -t A -c test_gns_lookup.conf` |
27 | gnunet-namestore -z testego -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | 28 | gnunet-namestore -z $MY_EGO -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf |
28 | gnunet-namestore -z delegatedego -d -n '+' -t A -V $TEST_IP -e never -c test_gns_lookup.conf | 29 | gnunet-namestore -z delegatedego -d -n '+' -t A -V $TEST_IP -e never -c test_gns_lookup.conf |
29 | gnunet-arm -e -c test_gns_lookup.conf | 30 | gnunet-arm -e -c test_gns_lookup.conf |
30 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 31 | rm -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 |
10 | if test $? != 0 | 10 | if test $? != 0 |
11 | then | 11 | 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 |
14 | fi | 14 | fi |
15 | 15 | ||
16 | MY_EGO="myego" | ||
17 | OTHER_EGO="delegatedego" | ||
18 | |||
19 | |||
16 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 20 | rm -rf /tmp/test-gnunet-gns-peer-1/ |
17 | which timeout &> /dev/null && DO_TIMEOUT="timeout 5" | 21 | which timeout &> /dev/null && DO_TIMEOUT="timeout 5" |
18 | TEST_IP="127.0.0.1" | 22 | TEST_IP="127.0.0.1" |
19 | gnunet-arm -s -c test_gns_lookup.conf | 23 | gnunet-arm -s -c test_gns_lookup.conf |
20 | gnunet-identity -C testego -c test_gns_lookup.conf | 24 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf |
21 | gnunet-identity -C delegatedego -c test_gns_lookup.conf | 25 | gnunet-identity -C $OTHER_EGO -c test_gns_lookup.conf |
22 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}') | 26 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep $OTHER_EGO | awk '{print $3}') |
23 | gnunet-arm -i gns -c test_gns_lookup.conf | 27 | gnunet-arm -i gns -c test_gns_lookup.conf |
24 | gnunet-namestore -p -z testego -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | 28 | gnunet-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 |
26 | sleep 2 | 30 | sleep 2 |
27 | # Performing namestore update | 31 | # Performing namestore update |
28 | gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | 32 | gnunet-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 |
30 | sleep 1 | 34 | sleep 1 |
31 | gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | 35 | gnunet-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 |
33 | sleep 1 | 37 | sleep 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 |
35 | gnunet-arm -k gns -c test_gns_lookup.conf | 39 | gnunet-arm -k gns -c test_gns_lookup.conf |
36 | gnunet-arm -k namestore -c test_gns_lookup.conf | 40 | gnunet-arm -k namestore -c test_gns_lookup.conf |
37 | gnunet-arm -k namecache -c test_gns_lookup.conf | 41 | gnunet-arm -k namecache -c test_gns_lookup.conf |
42 | gnunet-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 |
39 | rm -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 (!) | ||
46 | rm -r `gnunet-config -f -c test_gns_lookup.conf -s namecache-sqlite -o FILENAME` | ||
40 | gnunet-arm -i namestore -c test_gns_lookup.conf | 47 | gnunet-arm -i namestore -c test_gns_lookup.conf |
41 | gnunet-arm -i namecache -c test_gns_lookup.conf | 48 | gnunet-arm -i namecache -c test_gns_lookup.conf |
49 | gnunet-arm -i zonemaster -c test_gns_lookup.conf | ||
42 | gnunet-arm -i gns -c test_gns_lookup.conf | 50 | gnunet-arm -i gns -c test_gns_lookup.conf |
43 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.b.gnu -t A -c test_gns_lookup.conf` | 51 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.b.$MY_EGO -t A -c test_gns_lookup.conf` |
44 | gnunet-namestore -z testego -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | 52 | gnunet-namestore -z $MY_EGO -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf |
45 | gnunet-identity -D testego -c test_gns_lookup.conf | 53 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf |
46 | gnunet-identity -D delegatedego -c test_gns_lookup.conf | 54 | gnunet-identity -D $OTHER_EGO -c test_gns_lookup.conf |
47 | gnunet-arm -e -c test_gns_lookup.conf | 55 | gnunet-arm -e -c test_gns_lookup.conf |
48 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 56 | rm -rf /tmp/test-gnunet-gns-peer-1/ |
49 | 57 | ||
@@ -51,6 +59,6 @@ if [ "$RES_IP" == "$TEST_IP" ] | |||
51 | then | 59 | then |
52 | exit 0 | 60 | exit 0 |
53 | else | 61 | else |
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 |
56 | fi | 64 | fi |
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 |
14 | fi | 14 | fi |
15 | 15 | ||
16 | MY_EGO="myego" | ||
17 | OTHER_EGO="delegatedego" | ||
18 | |||
16 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 19 | rm -rf /tmp/test-gnunet-gns-peer-1/ |
17 | which timeout &> /dev/null && DO_TIMEOUT="timeout 5" | 20 | which timeout &> /dev/null && DO_TIMEOUT="timeout 5" |
18 | TEST_IP="127.0.0.1" | 21 | TEST_IP="127.0.0.1" |
19 | gnunet-arm -s -c test_gns_lookup.conf | 22 | gnunet-arm -s -c test_gns_lookup.conf |
20 | gnunet-identity -C testego -c test_gns_lookup.conf | 23 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf |
21 | gnunet-identity -C delegatedego -c test_gns_lookup.conf | 24 | gnunet-identity -C $OTHER_EGO -c test_gns_lookup.conf |
22 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}') | 25 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep $OTHER_EGO | awk '{print $3}') |
23 | gnunet-namestore -p -z testego -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | 26 | gnunet-namestore -p -z $MY_EGO -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf |
24 | gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e '5 s' -c test_gns_lookup.conf | 27 | gnunet-namestore -p -z $OTHER_EGO -a -n www -t A -V $TEST_IP -e '5 s' -c test_gns_lookup.conf |
25 | gnunet-arm -i gns -c test_gns_lookup.conf | 28 | gnunet-arm -i gns -c test_gns_lookup.conf |
26 | # confirm that lookup currently works | 29 | # confirm that lookup currently works |
27 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.b.gnu -t A -c test_gns_lookup.conf` | 30 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.b.$MY_EGO -t A -c test_gns_lookup.conf` |
28 | # remove entry | 31 | # remove entry |
29 | gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP -e '5 s' -c test_gns_lookup.conf | 32 | gnunet-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 |
31 | sleep 6 | 34 | sleep 6 |
32 | # try again, should no longer work | 35 | # try again, should no longer work |
33 | RES_IP_EXP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.b.gnu -t A -c test_gns_lookup.conf` | 36 | RES_IP_EXP=`$DO_TIMEOUT gnunet-gns --raw -u www.b.$MY_EGO -t A -c test_gns_lookup.conf` |
34 | gnunet-namestore -z testego -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | 37 | gnunet-namestore -z $MY_EGO -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf |
35 | gnunet-identity -D testego -c test_gns_lookup.conf | 38 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf |
36 | gnunet-identity -D delegatedego -c test_gns_lookup.conf | 39 | gnunet-identity -D $OTHER_EGO -c test_gns_lookup.conf |
37 | gnunet-arm -e -c test_gns_lookup.conf | 40 | gnunet-arm -e -c test_gns_lookup.conf |
38 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 41 | rm -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 | |||
15 | fi | 15 | fi |
16 | 16 | ||
17 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 17 | rm -rf /tmp/test-gnunet-gns-peer-1/ |
18 | 18 | MY_EGO="myego" | |
19 | OTHER_EGO="delegatedego" | ||
19 | TEST_IP="127.0.0.1" | 20 | TEST_IP="127.0.0.1" |
21 | |||
20 | gnunet-arm -s -c test_gns_lookup.conf | 22 | gnunet-arm -s -c test_gns_lookup.conf |
21 | gnunet-identity -C delegatedego -c test_gns_lookup.conf | 23 | gnunet-identity -C $OTHER_EGO -c test_gns_lookup.conf |
22 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}') | 24 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep $OTHER_EGO | awk '{print $3}') |
23 | gnunet-identity -C testego -c test_gns_lookup.conf | 25 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf |
24 | gnunet-namestore -p -z testego -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | 26 | gnunet-namestore -p -z $MY_EGO -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf |
25 | gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | 27 | gnunet-namestore -p -z $OTHER_EGO -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf |
26 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.b.gnu -t A -c test_gns_lookup.conf` | 28 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.b.$MY_EGO -t A -c test_gns_lookup.conf` |
27 | gnunet-revocation -R delegatedego -p -c test_gns_lookup.conf | 29 | gnunet-revocation -R $OTHER_EGO -p -c test_gns_lookup.conf |
28 | RES_IP_REV=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.b.gnu -t A -c test_gns_lookup.conf` | 30 | RES_IP_REV=`$DO_TIMEOUT gnunet-gns --raw -u www.b.$MY_EGO -t A -c test_gns_lookup.conf` |
29 | gnunet-namestore -z testego -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | 31 | gnunet-namestore -z $MY_EGO -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf |
30 | gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | 32 | gnunet-namestore -z $OTHER_EGO -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf |
31 | gnunet-arm -e -c test_gns_lookup.conf | 33 | gnunet-arm -e -c test_gns_lookup.conf |
32 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 34 | rm -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 | |||
16 | which timeout &> /dev/null && DO_TIMEOUT="timeout 5" | 16 | which timeout &> /dev/null && DO_TIMEOUT="timeout 5" |
17 | 17 | ||
18 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 18 | rm -rf /tmp/test-gnunet-gns-peer-1/ |
19 | TEST_DOMAIN="homepage.gnu" | 19 | MY_EGO="myego" |
20 | TEST_DOMAIN="homepage.$MY_EGO" | ||
20 | # some public DNS resolver we can use | 21 | # some public DNS resolver we can use |
21 | TEST_IP_GNS2DNS="184.172.157.218" | 22 | TEST_IP_GNS2DNS="184.172.157.218" |
22 | TEST_RECORD_NAME="homepage" | 23 | TEST_RECORD_NAME="homepage" |
@@ -29,11 +30,11 @@ then | |||
29 | fi | 30 | fi |
30 | 31 | ||
31 | gnunet-arm -s -c test_gns_lookup.conf | 32 | gnunet-arm -s -c test_gns_lookup.conf |
32 | gnunet-identity -C testego -c test_gns_lookup.conf | 33 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf |
33 | gnunet-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 | 34 | gnunet-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 |
34 | RES_SOA=`$DO_TIMEOUT gnunet-gns --raw -z testego -u $TEST_DOMAIN -t SOA -c test_gns_lookup.conf` | 35 | RES_SOA=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t SOA -c test_gns_lookup.conf` |
35 | gnunet-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 | 36 | gnunet-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 |
36 | gnunet-identity -D testego -c test_gns_lookup.conf | 37 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf |
37 | gnunet-arm -e -c test_gns_lookup.conf | 38 | gnunet-arm -e -c test_gns_lookup.conf |
38 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 39 | rm -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 | |||
16 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 16 | rm -rf /tmp/test-gnunet-gns-peer-1/ |
17 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | 17 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" |
18 | TEST_TXT="GNS powered txt record data" | 18 | TEST_TXT="GNS powered txt record data" |
19 | MY_EGO="myego" | ||
20 | LABEL="testtxt" | ||
19 | gnunet-arm -s -c test_gns_lookup.conf | 21 | gnunet-arm -s -c test_gns_lookup.conf |
20 | gnunet-identity -C testego -c test_gns_lookup.conf | 22 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf |
21 | gnunet-namestore -p -z testego -a -n testtxt -t TXT -V "$TEST_TXT" -e never -c test_gns_lookup.conf | 23 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t TXT -V "$TEST_TXT" -e never -c test_gns_lookup.conf |
22 | RES_TXT=`$DO_TIMEOUT gnunet-gns --raw -z testego -u testtxt.gnu -t TXT -c test_gns_lookup.conf` | 24 | RES_TXT=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$MY_EGO -t TXT -c test_gns_lookup.conf` |
23 | gnunet-namestore -z testego -d -n testtxt -t TXT -V "$TEST_TXT" -e never -c test_gns_lookup.conf | 25 | gnunet-namestore -z $MY_EGO -d -n $LABEL -t TXT -V "$TEST_TXT" -e never -c test_gns_lookup.conf |
24 | gnunet-identity -D testego -c test_gns_lookup.conf | 26 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf |
25 | gnunet-arm -e -c test_gns_lookup.conf | 27 | gnunet-arm -e -c test_gns_lookup.conf |
26 | rm -rf /tmp/test-gnunet-gns-peer-1/ | 28 | rm -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 | |||
23 | gnunet-identity -C testego -c test_gns_lookup.conf | 23 | gnunet-identity -C testego -c test_gns_lookup.conf |
24 | gnunet-namestore -p -z testego -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | 24 | gnunet-namestore -p -z testego -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf |
25 | gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | 25 | gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf |
26 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -z testego -u www.${DELEGATED_PKEY}.zkey -t A -c test_gns_lookup.conf` | 26 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.${DELEGATED_PKEY} -t A -c test_gns_lookup.conf` |
27 | gnunet-namestore -z testego -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | 27 | gnunet-namestore -z testego -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf |
28 | gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | 28 | gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf |
29 | gnunet-arm -e -c test_gns_lookup.conf | 29 | gnunet-arm -e -c test_gns_lookup.conf |