[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r30829 - gnunet/src/gns
From: |
gnunet |
Subject: |
[GNUnet-SVN] r30829 - gnunet/src/gns |
Date: |
Wed, 20 Nov 2013 16:39:59 +0100 |
Author: wachs
Date: 2013-11-20 16:39:58 +0100 (Wed, 20 Nov 2013)
New Revision: 30829
Modified:
gnunet/src/gns/gnunet-service-gns_resolver.c
Log:
- renaming namestore references to namecache
- implementing nick record based shortening in resolver
Modified: gnunet/src/gns/gnunet-service-gns_resolver.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.c 2013-11-20 15:27:52 UTC
(rev 30828)
+++ gnunet/src/gns/gnunet-service-gns_resolver.c 2013-11-20 15:39:58 UTC
(rev 30829)
@@ -101,6 +101,16 @@
char *label;
/**
+ * label/name suggested for shortening to the authority
+ */
+ char *suggested_shortening_label;
+
+ /**
+ * Do we already try to shorten this authority?
+ */
+ int shortening_started;
+
+ /**
* #GNUNET_YES if the authority was a GNS authority,
* #GNUNET_NO if the authority was a DNS authority.
*/
@@ -1075,15 +1085,8 @@
ac->gns_authority = GNUNET_YES;
ac->authority_info.gns_authority =
rh->ac_tail->authority_info.gns_authority;
ac->label = resolver_lookup_get_next_label (rh);
- /* tigger shortening */
- if (NULL != rh->shorten_key)
- {
- GNUNET_break (0); /* FIXME suggested label*/
- GNS_shorten_start (rh->ac_tail->label,
- NULL,
- &ac->authority_info.gns_authority,
- rh->shorten_key);
- }
+ ac->suggested_shortening_label = NULL;
+ ac->shortening_started = GNUNET_NO;
/* add AC to tail */
GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head,
rh->ac_tail,
@@ -1332,27 +1335,30 @@
{
struct GNS_ResolverHandle *rh = cls;
struct AuthorityChain *ac;
+ struct AuthorityChain *shorten_ac;
unsigned int i;
char *cname;
struct VpnContext *vpn_ctx;
const struct GNUNET_TUN_GnsVpnRecord *vpn;
const char *vname;
- const char *suggested_label;
struct GNUNET_HashCode vhash;
int af;
char scratch[UINT16_MAX];
size_t scratch_off;
size_t scratch_start;
size_t off;
- int c2;
struct GNUNET_GNSRECORD_Data rd_new[rd_count];
unsigned int rd_off;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Resolution succeeded for `%s' in zone %s, got %u records\n",
rh->ac_tail->label,
GNUNET_GNSRECORD_z2s (&rh->ac_tail->authority_info.gns_authority),
rd_count);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "%u \n\n",
+ rh->name_resolution_pos);
if (0 == rh->name_resolution_pos)
{
/* top-level match, are we done yet? */
@@ -1439,13 +1445,14 @@
}
default:
break;
- }
- }
- }
+ } /* end: switch */
+ } /* end: for rd */
+ } /* end: name_resolution_pos */
/* convert relative names in record values to absolute names,
using 'scratch' array for memory allocations */
scratch_off = 0;
rd_off = 0;
+ shorten_ac = rh->ac_tail;
for (i=0;i<rd_count;i++)
{
rd_new[rd_off] = rd[i];
@@ -1604,6 +1611,22 @@
GNUNET_DNSPARSER_free_srv (srv);
}
break;
+
+ case GNUNET_GNSRECORD_TYPE_NICK:
+ {
+ const char *nick;
+ nick = rd[i].data;
+ if ((GNUNET_GNSRECORD_TYPE_NICK ==rd[i].record_type) &&
+ (rd[i].data_size > 0) &&
+ (nick[rd[i].data_size -1] == '\0'))
+ {
+ GNUNET_break_op (0);
+ break;
+ }
+ if (NULL == shorten_ac->suggested_shortening_label)
+ shorten_ac->suggested_shortening_label = GNUNET_strdup (nick);
+ break;
+ }
case GNUNET_GNSRECORD_TYPE_PKEY:
{
struct GNUNET_CRYPTO_EcdsaPublicKey pub;
@@ -1614,24 +1637,6 @@
break;
}
memcpy (&pub, rd[i].data, rd[i].data_size);
-
- /* tigger shortening */
- if (NULL != rh->shorten_key)
- {
- suggested_label = NULL;
- for (c2 = 0; c2< rd_count; c2++)
- {
- if ((GNUNET_GNSRECORD_TYPE_NICK ==rd[c2].record_type) &&
- (rd[i].data_size > 0) &&
- (((const char *) rd[c2].data)[rd[c2].data_size -1] == '\0'))
- suggested_label = (const char *) rd->data;
- }
- if (NULL != suggested_label)
- GNS_shorten_start (rh->ac_tail->label,
- suggested_label,
- &pub,
- rh->shorten_key);
- }
rd_off++;
if (GNUNET_GNSRECORD_TYPE_PKEY != rh->record_type)
{
@@ -1643,6 +1648,8 @@
ac->gns_authority = GNUNET_YES;
ac->authority_info.gns_authority = pub;
ac->label = GNUNET_strdup (GNUNET_GNS_MASTERZONE_STR);
+ ac->suggested_shortening_label = NULL;
+ ac->shortening_started = GNUNET_NO;
GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head,
rh->ac_tail,
ac);
@@ -1662,7 +1669,24 @@
default:
rd_off++;
break;
- }
+ } /* end: switch */
+ } /* end: for rd_count */
+
+ /* trigger shortening */
+ if ((NULL != rh->shorten_key) &&
+ (NULL != shorten_ac) &&
+ (GNUNET_NO == shorten_ac->shortening_started) &&
+ (NULL != shorten_ac->suggested_shortening_label))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Start shortening for label `%s' based on nick `%s'\n",
+ shorten_ac->label,
+ shorten_ac->suggested_shortening_label);
+ shorten_ac->shortening_started = GNUNET_YES;
+ GNS_shorten_start (shorten_ac->label,
+ shorten_ac->suggested_shortening_label,
+ &shorten_ac->authority_info.gns_authority,
+ rh->shorten_key);
}
/* yes, we are done, return result */
@@ -1694,27 +1718,12 @@
ac = GNUNET_new (struct AuthorityChain);
ac->rh = rh;
ac->gns_authority = GNUNET_YES;
+ ac->suggested_shortening_label = NULL;
+ ac->shortening_started = GNUNET_NO;
memcpy (&ac->authority_info.gns_authority,
rd[i].data,
sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
ac->label = resolver_lookup_get_next_label (rh);
- /* tigger shortening */
- if (NULL != rh->shorten_key)
- {
- suggested_label = NULL;
- for (c2 = 0; c2< rd_count; c2++)
- {
- if ((GNUNET_GNSRECORD_TYPE_NICK ==rd[c2].record_type) &&
- (rd[c2].data_size > 0) &&
- ((const char *) rd[c2].data)[rd[c2].data_size -1] == '\0')
- suggested_label = (const char *) rd[c2].data;
- }
- if (NULL != suggested_label)
- GNS_shorten_start (rh->ac_tail->label,
- suggested_label,
- &ac->authority_info.gns_authority,
- rh->shorten_key);
- }
/* add AC to tail */
GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head,
rh->ac_tail,
@@ -1923,10 +1932,10 @@
/**
- * Process a record that was stored in the namestore.
+ * Process a record that was stored in the namecache.
*
* @param cls closure with the `struct GNS_ResolverHandle`
- * @param block block that was stored in the namestore
+ * @param block block that was stored in the namecache
*/
static void
handle_namestore_block_response (void *cls,
@@ -1948,7 +1957,7 @@
( (NULL == block) ||
(0 == GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh
(block->expiration_time)).rel_value_us) ) )
{
- /* Namestore knows nothing; try DHT lookup */
+ /* namecache knows nothing; try DHT lookup */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting DHT lookup for `%s' in zone %s\n",
ac->label,
@@ -2207,6 +2216,7 @@
ac = GNUNET_new (struct AuthorityChain);
ac->rh = rh;
ac->label = resolver_lookup_get_next_label (rh);
+ ac->suggested_shortening_label = NULL;
if (NULL == ac->label)
/* name was just "gnu", so we default to label '+' */
ac->label = GNUNET_strdup (GNUNET_GNS_MASTERZONE_STR);
@@ -2290,6 +2300,7 @@
rh->ac_tail,
ac);
GNUNET_free (ac->label);
+ GNUNET_free_non_null (ac->suggested_shortening_label);
GNUNET_free (ac);
}
if (NULL != rh->g2dc)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r30829 - gnunet/src/gns,
gnunet <=