aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gns/gnunet-service-gns_resolver.c29
-rw-r--r--src/gns/gnunet-service-gns_shorten.c40
-rw-r--r--src/gns/gnunet-service-gns_shorten.h5
3 files changed, 68 insertions, 6 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 2ab3c9a88..8f21b0d13 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -1078,6 +1078,7 @@ handle_gns_cname_result (struct GNS_ResolverHandle *rh,
1078 /* tigger shortening */ 1078 /* tigger shortening */
1079 if (NULL != rh->shorten_key) 1079 if (NULL != rh->shorten_key)
1080 GNS_shorten_start (rh->ac_tail->label, 1080 GNS_shorten_start (rh->ac_tail->label,
1081 NULL,
1081 &ac->authority_info.gns_authority, 1082 &ac->authority_info.gns_authority,
1082 rh->shorten_key); 1083 rh->shorten_key);
1083 /* add AC to tail */ 1084 /* add AC to tail */
@@ -1333,12 +1334,14 @@ handle_gns_resolution_result (void *cls,
1333 struct VpnContext *vpn_ctx; 1334 struct VpnContext *vpn_ctx;
1334 const struct GNUNET_TUN_GnsVpnRecord *vpn; 1335 const struct GNUNET_TUN_GnsVpnRecord *vpn;
1335 const char *vname; 1336 const char *vname;
1337 const char *suggested_label;
1336 struct GNUNET_HashCode vhash; 1338 struct GNUNET_HashCode vhash;
1337 int af; 1339 int af;
1338 char scratch[UINT16_MAX]; 1340 char scratch[UINT16_MAX];
1339 size_t scratch_off; 1341 size_t scratch_off;
1340 size_t scratch_start; 1342 size_t scratch_start;
1341 size_t off; 1343 size_t off;
1344 int c2;
1342 struct GNUNET_GNSRECORD_Data rd_new[rd_count]; 1345 struct GNUNET_GNSRECORD_Data rd_new[rd_count];
1343 unsigned int rd_off; 1346 unsigned int rd_off;
1344 1347
@@ -1612,7 +1615,17 @@ handle_gns_resolution_result (void *cls,
1612 /* tigger shortening */ 1615 /* tigger shortening */
1613 if (NULL != rh->shorten_key) 1616 if (NULL != rh->shorten_key)
1614 { 1617 {
1615 GNS_shorten_start (rh->ac_tail->label, 1618 suggested_label = NULL;
1619 for (c2 = 0; c2< rd_count; c2++)
1620 {
1621 if ((GNUNET_GNSRECORD_TYPE_NICK ==rd[c2].record_type) &&
1622 (rd[i].data_size > 0) &&
1623 (((const char *) rd[c2].data)[rd[c2].data_size -1] == '\0'))
1624 suggested_label = (const char *) rd->data;
1625 }
1626 if (NULL != suggested_label)
1627 GNS_shorten_start (rh->ac_tail->label,
1628 suggested_label,
1616 &pub, 1629 &pub,
1617 rh->shorten_key); 1630 rh->shorten_key);
1618 } 1631 }
@@ -1684,9 +1697,21 @@ handle_gns_resolution_result (void *cls,
1684 ac->label = resolver_lookup_get_next_label (rh); 1697 ac->label = resolver_lookup_get_next_label (rh);
1685 /* tigger shortening */ 1698 /* tigger shortening */
1686 if (NULL != rh->shorten_key) 1699 if (NULL != rh->shorten_key)
1687 GNS_shorten_start (rh->ac_tail->label, 1700 {
1701 suggested_label = NULL;
1702 for (c2 = 0; c2< rd_count; c2++)
1703 {
1704 if ((GNUNET_GNSRECORD_TYPE_NICK ==rd[c2].record_type) &&
1705 (rd[c2].data_size > 0) &&
1706 ((const char *) rd[c2].data)[rd[c2].data_size -1] == '\0')
1707 suggested_label = (const char *) rd[c2].data;
1708 }
1709 if (NULL != suggested_label)
1710 GNS_shorten_start (rh->ac_tail->label,
1711 suggested_label,
1688 &ac->authority_info.gns_authority, 1712 &ac->authority_info.gns_authority,
1689 rh->shorten_key); 1713 rh->shorten_key);
1714 }
1690 /* add AC to tail */ 1715 /* add AC to tail */
1691 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head, 1716 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head,
1692 rh->ac_tail, 1717 rh->ac_tail,
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 */
diff --git a/src/gns/gnunet-service-gns_shorten.h b/src/gns/gnunet-service-gns_shorten.h
index f99d465f9..1e55a89d7 100644
--- a/src/gns/gnunet-service-gns_shorten.h
+++ b/src/gns/gnunet-service-gns_shorten.h
@@ -62,8 +62,9 @@ GNS_shorten_done (void);
62 */ 62 */
63void 63void
64GNS_shorten_start (const char *original_label, 64GNS_shorten_start (const char *original_label,
65 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, 65 const char *suggested_label,
66 const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_zone); 66 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
67 const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_zone);
67 68
68 69
69#endif 70#endif