aboutsummaryrefslogtreecommitdiff
path: root/src/gns/gnunet-service-gns_shorten.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-11-13 16:38:16 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-11-13 16:38:16 +0000
commitc6a0a7573374a3e7718687df73c953c67301f400 (patch)
treea301765f05a2bfea1496b74c98f2d829ef381153 /src/gns/gnunet-service-gns_shorten.c
parent6845de36e4af2861a7dae04036f0a0d505519412 (diff)
downloadgnunet-c6a0a7573374a3e7718687df73c953c67301f400.tar.gz
gnunet-c6a0a7573374a3e7718687df73c953c67301f400.zip
use nick instead of PSEU lookup
Diffstat (limited to 'src/gns/gnunet-service-gns_shorten.c')
-rw-r--r--src/gns/gnunet-service-gns_shorten.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/gns/gnunet-service-gns_shorten.c b/src/gns/gnunet-service-gns_shorten.c
index 9c27da16f..55b7ca3d7 100644
--- a/src/gns/gnunet-service-gns_shorten.c
+++ b/src/gns/gnunet-service-gns_shorten.c
@@ -74,6 +74,11 @@ struct GetPseuAuthorityHandle
74 char label[GNUNET_DNSPARSER_MAX_LABEL_LENGTH + 1]; 74 char label[GNUNET_DNSPARSER_MAX_LABEL_LENGTH + 1];
75 75
76 /** 76 /**
77 * Suggested label based on NICK record
78 */
79 char * suggested_label;
80
81 /**
77 * Label we are currently trying out (during #perform_pseu_lookup). 82 * Label we are currently trying out (during #perform_pseu_lookup).
78 */ 83 */
79 char *current_label; 84 char *current_label;
@@ -236,7 +241,7 @@ process_pseu_block_ns (void *cls,
236 241
237 242
238/** 243/**
239 * Lookup in the namestore for the shorten zone the given label. 244 * Lookup in the namecache for the shorten zone the given label.
240 * 245 *
241 * @param gph the handle to our shorten operation 246 * @param gph the handle to our shorten operation
242 * @param label the label to lookup 247 * @param label the label to lookup
@@ -476,6 +481,25 @@ process_auth_discovery_dht_result (void* cls,
476 } 481 }
477} 482}
478 483
484static void suggested_lookup_cb (void *cls,
485 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
486 const char *label,
487 unsigned int rd_count,
488 const struct GNUNET_GNSRECORD_Data *rd)
489{
490 struct GetPseuAuthorityHandle* gph = cls;
491 gph->namestore_task = NULL;
492 if ((0 == strcmp (label, gph->suggested_label)) && (0 == rd_count) && (NULL == rd))
493 {
494
495 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
496 "Shortening to suggested name `%s' possible\n",
497 gph->suggested_label);
498 process_pseu_result (gph, gph->suggested_label);
499 }
500}
501
502
479 503
480/** 504/**
481 * Callback called by namestore for a zone to name result. We're 505 * Callback called by namestore for a zone to name result. We're
@@ -495,7 +519,9 @@ process_zone_to_name_discover (void *cls,
495 const struct GNUNET_GNSRECORD_Data *rd) 519 const struct GNUNET_GNSRECORD_Data *rd)
496{ 520{
497 struct GetPseuAuthorityHandle* gph = cls; 521 struct GetPseuAuthorityHandle* gph = cls;
522#if 0
498 struct GNUNET_HashCode lookup_key; 523 struct GNUNET_HashCode lookup_key;
524#endif
499 525
500 gph->namestore_task = NULL; 526 gph->namestore_task = NULL;
501 if (0 != rd_len) 527 if (0 != rd_len)
@@ -507,7 +533,13 @@ process_zone_to_name_discover (void *cls,
507 free_get_pseu_authority_handle (gph); 533 free_get_pseu_authority_handle (gph);
508 return; 534 return;
509 } 535 }
510 /* record does not yet exist, go into DHT to find PSEU record */ 536 /* record does not yet exist, check if suggested label is available */
537
538 if (NULL != gph->suggested_label)
539 gph->namestore_task = GNUNET_NAMESTORE_records_lookup (namestore_handle, zone_key,
540 gph->suggested_label, &suggested_lookup_cb, gph);
541
542#if 0
511 GNUNET_GNSRECORD_query_from_public_key (&gph->target_zone, 543 GNUNET_GNSRECORD_query_from_public_key (&gph->target_zone,
512 GNUNET_GNS_TLD_PLUS, 544 GNUNET_GNS_TLD_PLUS,
513 &lookup_key); 545 &lookup_key);
@@ -527,6 +559,7 @@ process_zone_to_name_discover (void *cls,
527 NULL, 0, 559 NULL, 0,
528 &process_auth_discovery_dht_result, 560 &process_auth_discovery_dht_result,
529 gph); 561 gph);
562#endif
530} 563}
531 564
532 565
@@ -536,11 +569,13 @@ process_zone_to_name_discover (void *cls,
536 * @a original_label as one possible suggestion. 569 * @a original_label as one possible suggestion.
537 * 570 *
538 * @param original_label original label for the zone 571 * @param original_label original label for the zone
572 * @param suggested_label suggested label for the zone
539 * @param pub public key of the zone to shorten 573 * @param pub public key of the zone to shorten
540 * @param shorten_zone private key of the target zone for the new record 574 * @param shorten_zone private key of the target zone for the new record
541 */ 575 */
542void 576void
543GNS_shorten_start (const char *original_label, 577GNS_shorten_start (const char *original_label,
578 const char *suggested_label,
544 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, 579 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
545 const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_zone) 580 const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_zone)
546{ 581{
@@ -558,6 +593,7 @@ GNS_shorten_start (const char *original_label,
558 gph = GNUNET_new (struct GetPseuAuthorityHandle); 593 gph = GNUNET_new (struct GetPseuAuthorityHandle);
559 gph->shorten_zone_key = *shorten_zone; 594 gph->shorten_zone_key = *shorten_zone;
560 gph->target_zone = *pub; 595 gph->target_zone = *pub;
596 gph->suggested_label = GNUNET_strdup (suggested_label);
561 strcpy (gph->label, original_label); 597 strcpy (gph->label, original_label);
562 GNUNET_CONTAINER_DLL_insert (gph_head, gph_tail, gph); 598 GNUNET_CONTAINER_DLL_insert (gph_head, gph_tail, gph);
563 /* first, check if we *already* have a record for this zone */ 599 /* first, check if we *already* have a record for this zone */