gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r30672 - gnunet/src/gns


From: gnunet
Subject: [GNUnet-SVN] r30672 - gnunet/src/gns
Date: Wed, 13 Nov 2013 17:38:16 +0100

Author: wachs
Date: 2013-11-13 17:38:16 +0100 (Wed, 13 Nov 2013)
New Revision: 30672

Modified:
   gnunet/src/gns/gnunet-service-gns_resolver.c
   gnunet/src/gns/gnunet-service-gns_shorten.c
   gnunet/src/gns/gnunet-service-gns_shorten.h
Log:
use nick instead of PSEU lookup

Modified: gnunet/src/gns/gnunet-service-gns_resolver.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.c        2013-11-13 16:30:01 UTC 
(rev 30671)
+++ gnunet/src/gns/gnunet-service-gns_resolver.c        2013-11-13 16:38:16 UTC 
(rev 30672)
@@ -1078,6 +1078,7 @@
     /* tigger shortening */
     if (NULL != rh->shorten_key)
       GNS_shorten_start (rh->ac_tail->label,
+                         NULL,
                         &ac->authority_info.gns_authority,
                         rh->shorten_key);
     /* add AC to tail */
@@ -1333,12 +1334,14 @@
   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;
 
@@ -1612,7 +1615,17 @@
           /* tigger shortening */
           if (NULL != rh->shorten_key)
           {
-            GNS_shorten_start (rh->ac_tail->label,
+            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);
           }
@@ -1684,9 +1697,21 @@
       ac->label = resolver_lookup_get_next_label (rh);
       /* tigger shortening */
       if (NULL != rh->shorten_key)
-       GNS_shorten_start (rh->ac_tail->label,
+      {
+        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,

Modified: gnunet/src/gns/gnunet-service-gns_shorten.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_shorten.c 2013-11-13 16:30:01 UTC (rev 
30671)
+++ gnunet/src/gns/gnunet-service-gns_shorten.c 2013-11-13 16:38:16 UTC (rev 
30672)
@@ -74,6 +74,11 @@
   char label[GNUNET_DNSPARSER_MAX_LABEL_LENGTH + 1];
 
   /**
+   * Suggested label based on NICK record
+   */
+  char * suggested_label;
+
+  /**
    * Label we are currently trying out (during #perform_pseu_lookup).
    */
   char *current_label;
@@ -236,7 +241,7 @@
 
 
 /**
- * Lookup in the namestore for the shorten zone the given label.
+ * Lookup in the namecache for the shorten zone the given label.
  *
  * @param gph the handle to our shorten operation
  * @param label the label to lookup
@@ -476,7 +481,26 @@
   }
 }
 
+static void suggested_lookup_cb (void *cls,
+                                const struct GNUNET_CRYPTO_EcdsaPrivateKey 
*zone,
+                                const char *label,
+                                unsigned int rd_count,
+                                const struct GNUNET_GNSRECORD_Data *rd)
+{
+  struct GetPseuAuthorityHandle* gph = cls;
+  gph->namestore_task = NULL;
+  if ((0 == strcmp (label, gph->suggested_label)) && (0 == rd_count) && (NULL 
== rd))
+  {
 
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Shortening to suggested name `%s' possible\n",
+                gph->suggested_label);
+    process_pseu_result (gph, gph->suggested_label);
+  }
+}
+
+
+
 /**
  * Callback called by namestore for a zone to name result.  We're
  * trying to see if a short name for a given zone already exists.
@@ -495,7 +519,9 @@
                               const struct GNUNET_GNSRECORD_Data *rd)
 {
   struct GetPseuAuthorityHandle* gph = cls;
+#if 0
   struct GNUNET_HashCode lookup_key;
+#endif
 
   gph->namestore_task = NULL;
   if (0 != rd_len)
@@ -507,7 +533,13 @@
     free_get_pseu_authority_handle (gph);
     return;
   }
-  /* record does not yet exist, go into DHT to find PSEU record */
+  /* record does not yet exist, check if suggested label is available */
+
+  if (NULL != gph->suggested_label)
+    gph->namestore_task = GNUNET_NAMESTORE_records_lookup (namestore_handle, 
zone_key,
+        gph->suggested_label, &suggested_lookup_cb, gph);
+
+#if 0
   GNUNET_GNSRECORD_query_from_public_key (&gph->target_zone,
                                          GNUNET_GNS_TLD_PLUS,
                                          &lookup_key);
@@ -527,6 +559,7 @@
                                          NULL, 0,
                                          &process_auth_discovery_dht_result,
                                          gph);
+#endif
 }
 
 
@@ -536,11 +569,13 @@
  * @a original_label as one possible suggestion.
  *
  * @param original_label original label for the zone
+ * @param suggested_label suggested label for the zone
  * @param pub public key of the zone to shorten
  * @param shorten_zone private key of the target zone for the new record
  */
 void
 GNS_shorten_start (const char *original_label,
+                   const char *suggested_label,
                   const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
                   const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_zone)
 {
@@ -558,6 +593,7 @@
   gph = GNUNET_new (struct GetPseuAuthorityHandle);
   gph->shorten_zone_key = *shorten_zone;
   gph->target_zone = *pub;
+  gph->suggested_label = GNUNET_strdup (suggested_label);
   strcpy (gph->label, original_label);
   GNUNET_CONTAINER_DLL_insert (gph_head, gph_tail, gph);
   /* first, check if we *already* have a record for this zone */

Modified: gnunet/src/gns/gnunet-service-gns_shorten.h
===================================================================
--- gnunet/src/gns/gnunet-service-gns_shorten.h 2013-11-13 16:30:01 UTC (rev 
30671)
+++ gnunet/src/gns/gnunet-service-gns_shorten.h 2013-11-13 16:38:16 UTC (rev 
30672)
@@ -62,8 +62,9 @@
  */
 void
 GNS_shorten_start (const char *original_label,
-                  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
-                  const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_zone);
+                   const char *suggested_label,
+                   const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
+                   const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_zone);
 
 
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]