diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-03-04 11:26:26 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-03-04 11:26:26 +0000 |
commit | 5c779811684d383940d6e3766ace4bdce7bc0ae6 (patch) | |
tree | c8aeeee7e987d8d69f8bd195f02428c49028f9ae /src/gns | |
parent | 6927a8b2ec77eb4403dab98ae7df8d9e882ba6ae (diff) | |
download | gnunet-5c779811684d383940d6e3766ace4bdce7bc0ae6.tar.gz gnunet-5c779811684d383940d6e3766ace4bdce7bc0ae6.zip |
-presumably better fix for instantly resolving names in master zone
Diffstat (limited to 'src/gns')
-rw-r--r-- | src/gns/gns.h | 5 | ||||
-rw-r--r-- | src/gns/gns_api.c | 6 | ||||
-rw-r--r-- | src/gns/gnunet-gns.c | 11 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns.c | 2 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 14 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.h | 5 |
6 files changed, 25 insertions, 18 deletions
diff --git a/src/gns/gns.h b/src/gns/gns.h index a8402b196..35ff969f2 100644 --- a/src/gns/gns.h +++ b/src/gns/gns.h | |||
@@ -66,9 +66,10 @@ struct GNUNET_GNS_ClientLookupMessage | |||
66 | struct GNUNET_CRYPTO_EcdsaPublicKey zone; | 66 | struct GNUNET_CRYPTO_EcdsaPublicKey zone; |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Only check cached results | 69 | * Local options for where to look for results |
70 | * (an `enum GNUNET_GNS_LocalOptions` in NBO). | ||
70 | */ | 71 | */ |
71 | int16_t only_cached GNUNET_PACKED; | 72 | int16_t options GNUNET_PACKED; |
72 | 73 | ||
73 | /** | 74 | /** |
74 | * Is a shorten key attached? | 75 | * Is a shorten key attached? |
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c index 66bd005cf..9f7f28b71 100644 --- a/src/gns/gns_api.c +++ b/src/gns/gns_api.c | |||
@@ -523,7 +523,7 @@ GNUNET_GNS_lookup_cancel (struct GNUNET_GNS_LookupRequest *lr) | |||
523 | * @param name the name to look up | 523 | * @param name the name to look up |
524 | * @param zone the zone to start the resolution in | 524 | * @param zone the zone to start the resolution in |
525 | * @param type the record type to look up | 525 | * @param type the record type to look up |
526 | * @param only_cached #GNUNET_YES to only check locally (not in the DHT) | 526 | * @param options local options for the lookup |
527 | * @param shorten_zone_key the private key of the shorten zone (can be NULL) | 527 | * @param shorten_zone_key the private key of the shorten zone (can be NULL) |
528 | * @param proc processor to call on result | 528 | * @param proc processor to call on result |
529 | * @param proc_cls closure for @a proc | 529 | * @param proc_cls closure for @a proc |
@@ -534,7 +534,7 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, | |||
534 | const char *name, | 534 | const char *name, |
535 | const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, | 535 | const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, |
536 | uint32_t type, | 536 | uint32_t type, |
537 | int only_cached, | 537 | enum GNUNET_GNS_LocalOptions options, |
538 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_zone_key, | 538 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_zone_key, |
539 | GNUNET_GNS_LookupResultProcessor proc, | 539 | GNUNET_GNS_LookupResultProcessor proc, |
540 | void *proc_cls) | 540 | void *proc_cls) |
@@ -576,7 +576,7 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, | |||
576 | lookup_msg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_LOOKUP); | 576 | lookup_msg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_LOOKUP); |
577 | lookup_msg->header.size = htons (msize); | 577 | lookup_msg->header.size = htons (msize); |
578 | lookup_msg->id = htonl (lr->r_id); | 578 | lookup_msg->id = htonl (lr->r_id); |
579 | lookup_msg->only_cached = htons (only_cached); | 579 | lookup_msg->options = htons ((uint16_t) options); |
580 | lookup_msg->zone = *zone; | 580 | lookup_msg->zone = *zone; |
581 | lookup_msg->type = htonl (type); | 581 | lookup_msg->type = htonl (type); |
582 | if (NULL != shorten_zone_key) | 582 | if (NULL != shorten_zone_key) |
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c index 7951eb569..f59239b9d 100644 --- a/src/gns/gnunet-gns.c +++ b/src/gns/gnunet-gns.c | |||
@@ -66,9 +66,9 @@ static char *zone_ego_name; | |||
66 | static char *public_key; | 66 | static char *public_key; |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Set to #GNUNET_YES if we must not use the DHT (only local lookup). | 69 | * Set to GNUNET_GNS_LO_LOCAL_MASTER if we are looking up in the master zone. |
70 | */ | 70 | */ |
71 | static int only_cached; | 71 | static enum GNUNET_GNS_LocalOptions local_options; |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * raw output | 74 | * raw output |
@@ -216,7 +216,7 @@ lookup_with_keys (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey, | |||
216 | lookup_name, | 216 | lookup_name, |
217 | pkey, | 217 | pkey, |
218 | rtype, | 218 | rtype, |
219 | only_cached, | 219 | local_options, |
220 | shorten_key, | 220 | shorten_key, |
221 | &process_lookup_result, | 221 | &process_lookup_result, |
222 | lookup_name); | 222 | lookup_name); |
@@ -349,13 +349,16 @@ identity_master_cb (void *cls, | |||
349 | return; | 349 | return; |
350 | } | 350 | } |
351 | GNUNET_IDENTITY_ego_get_public_key (ego, &pkey); | 351 | GNUNET_IDENTITY_ego_get_public_key (ego, &pkey); |
352 | /* main name is our own master zone, do no look for that in the DHT */ | ||
353 | local_options = GNUNET_GNS_LO_LOCAL_MASTER; | ||
354 | |||
352 | /* if the name is of the form 'label.gnu', never go to the DHT */ | 355 | /* if the name is of the form 'label.gnu', never go to the DHT */ |
353 | dot = NULL; | 356 | dot = NULL; |
354 | if (NULL != lookup_name) | 357 | if (NULL != lookup_name) |
355 | dot = strchr (lookup_name, '.'); | 358 | dot = strchr (lookup_name, '.'); |
356 | if ( (NULL != dot) && | 359 | if ( (NULL != dot) && |
357 | (0 == strcasecmp (dot, ".gnu")) ) | 360 | (0 == strcasecmp (dot, ".gnu")) ) |
358 | only_cached = GNUNET_YES; | 361 | local_options = GNUNET_GNS_LO_NO_DHT; |
359 | lookup_with_public_key (&pkey); | 362 | lookup_with_public_key (&pkey); |
360 | } | 363 | } |
361 | 364 | ||
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index 87dfed246..28e6c3cc7 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -788,7 +788,7 @@ handle_lookup (void *cls, | |||
788 | ntohl (sh_msg->type), | 788 | ntohl (sh_msg->type), |
789 | name, | 789 | name, |
790 | key, | 790 | key, |
791 | ntohs (sh_msg->only_cached), | 791 | (enum GNUNET_GNS_LocalOptions) ntohs (sh_msg->options), |
792 | &send_lookup_response, clh); | 792 | &send_lookup_response, clh); |
793 | GNUNET_STATISTICS_update (statistics, | 793 | GNUNET_STATISTICS_update (statistics, |
794 | "Lookup attempts", | 794 | "Lookup attempts", |
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 8e4de4b7d..d1e958961 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -365,7 +365,7 @@ struct GNS_ResolverHandle | |||
365 | /** | 365 | /** |
366 | * Use only cache | 366 | * Use only cache |
367 | */ | 367 | */ |
368 | int only_cached; | 368 | enum GNUNET_GNS_LocalOptions options; |
369 | 369 | ||
370 | /** | 370 | /** |
371 | * Desired type for the resolution. | 371 | * Desired type for the resolution. |
@@ -1779,7 +1779,7 @@ handle_gns_resolution_result (void *cls, | |||
1779 | g2dc->rh->proc = &handle_gns2dns_result; | 1779 | g2dc->rh->proc = &handle_gns2dns_result; |
1780 | g2dc->rh->proc_cls = rh; | 1780 | g2dc->rh->proc_cls = rh; |
1781 | g2dc->rh->record_type = GNUNET_GNSRECORD_TYPE_ANY; | 1781 | g2dc->rh->record_type = GNUNET_GNSRECORD_TYPE_ANY; |
1782 | g2dc->rh->only_cached = GNUNET_NO; | 1782 | g2dc->rh->options = GNUNET_GNS_LO_DEFAULT; |
1783 | g2dc->rh->loop_limiter = rh->loop_limiter + 1; | 1783 | g2dc->rh->loop_limiter = rh->loop_limiter + 1; |
1784 | rh->g2dc = g2dc; | 1784 | rh->g2dc = g2dc; |
1785 | start_resolver_lookup (g2dc->rh); | 1785 | start_resolver_lookup (g2dc->rh); |
@@ -2011,7 +2011,9 @@ handle_namecache_block_response (void *cls, | |||
2011 | 2011 | ||
2012 | GNUNET_assert (NULL != rh->namecache_qe); | 2012 | GNUNET_assert (NULL != rh->namecache_qe); |
2013 | rh->namecache_qe = NULL; | 2013 | rh->namecache_qe = NULL; |
2014 | if ( (GNUNET_NO == rh->only_cached) && | 2014 | if ( ( (GNUNET_GNS_LO_DEFAULT == rh->options) || |
2015 | ( (GNUNET_GNS_LO_LOCAL_MASTER == rh->options) && | ||
2016 | (ac != rh->ac_head) ) ) && | ||
2015 | ( (NULL == block) || | 2017 | ( (NULL == block) || |
2016 | (0 == GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh (block->expiration_time)).rel_value_us) ) ) | 2018 | (0 == GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh (block->expiration_time)).rel_value_us) ) ) |
2017 | { | 2019 | { |
@@ -2303,7 +2305,7 @@ start_resolver_lookup (struct GNS_ResolverHandle *rh) | |||
2303 | * @param record_type the record type to look up | 2305 | * @param record_type the record type to look up |
2304 | * @param name the name to look up | 2306 | * @param name the name to look up |
2305 | * @param shorten_key a private key for use with PSEU import (can be NULL) | 2307 | * @param shorten_key a private key for use with PSEU import (can be NULL) |
2306 | * @param only_cached #GNUNET_NO to only check locally not DHT for performance | 2308 | * @param options local options to control local lookup |
2307 | * @param proc the processor to call on result | 2309 | * @param proc the processor to call on result |
2308 | * @param proc_cls the closure to pass to @a proc | 2310 | * @param proc_cls the closure to pass to @a proc |
2309 | * @return handle to cancel operation | 2311 | * @return handle to cancel operation |
@@ -2313,7 +2315,7 @@ GNS_resolver_lookup (const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, | |||
2313 | uint32_t record_type, | 2315 | uint32_t record_type, |
2314 | const char *name, | 2316 | const char *name, |
2315 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_key, | 2317 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_key, |
2316 | int only_cached, | 2318 | enum GNUNET_GNS_LocalOptions options, |
2317 | GNS_ResultProcessor proc, void *proc_cls) | 2319 | GNS_ResultProcessor proc, void *proc_cls) |
2318 | { | 2320 | { |
2319 | struct GNS_ResolverHandle *rh; | 2321 | struct GNS_ResolverHandle *rh; |
@@ -2330,7 +2332,7 @@ GNS_resolver_lookup (const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, | |||
2330 | rh->authority_zone = *zone; | 2332 | rh->authority_zone = *zone; |
2331 | rh->proc = proc; | 2333 | rh->proc = proc; |
2332 | rh->proc_cls = proc_cls; | 2334 | rh->proc_cls = proc_cls; |
2333 | rh->only_cached = only_cached; | 2335 | rh->options = options; |
2334 | rh->record_type = record_type; | 2336 | rh->record_type = record_type; |
2335 | rh->name = GNUNET_strdup (name); | 2337 | rh->name = GNUNET_strdup (name); |
2336 | rh->name_resolution_pos = strlen (name); | 2338 | rh->name_resolution_pos = strlen (name); |
diff --git a/src/gns/gnunet-service-gns_resolver.h b/src/gns/gnunet-service-gns_resolver.h index ffb7142a7..baad44e38 100644 --- a/src/gns/gnunet-service-gns_resolver.h +++ b/src/gns/gnunet-service-gns_resolver.h | |||
@@ -26,6 +26,7 @@ | |||
26 | #define GNS_RESOLVER_H | 26 | #define GNS_RESOLVER_H |
27 | #include "gns.h" | 27 | #include "gns.h" |
28 | #include "gnunet_dht_service.h" | 28 | #include "gnunet_dht_service.h" |
29 | #include "gnunet_gns_service.h" | ||
29 | #include "gnunet_namecache_service.h" | 30 | #include "gnunet_namecache_service.h" |
30 | 31 | ||
31 | /** | 32 | /** |
@@ -77,7 +78,7 @@ typedef void (*GNS_ResultProcessor)(void *cls, | |||
77 | * @param record_type the record type to look up | 78 | * @param record_type the record type to look up |
78 | * @param name the name to look up | 79 | * @param name the name to look up |
79 | * @param shorten_key optional private key for authority caching, can be NULL | 80 | * @param shorten_key optional private key for authority caching, can be NULL |
80 | * @param only_cached GNUNET_NO to only check locally not DHT for performance | 81 | * @param options options set to control local lookup |
81 | * @param proc the processor to call | 82 | * @param proc the processor to call |
82 | * @param proc_cls the closure to pass to @a proc | 83 | * @param proc_cls the closure to pass to @a proc |
83 | * @return handle to cancel operation | 84 | * @return handle to cancel operation |
@@ -87,7 +88,7 @@ GNS_resolver_lookup (const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, | |||
87 | uint32_t record_type, | 88 | uint32_t record_type, |
88 | const char *name, | 89 | const char *name, |
89 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_key, | 90 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_key, |
90 | int only_cached, | 91 | enum GNUNET_GNS_LocalOptions options, |
91 | GNS_ResultProcessor proc, | 92 | GNS_ResultProcessor proc, |
92 | void *proc_cls); | 93 | void *proc_cls); |
93 | 94 | ||