renaming PSEU to NICK
authorMatthias Wachs <wachs@net.in.tum.de>
Wed, 13 Nov 2013 09:31:07 +0000 (09:31 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Wed, 13 Nov 2013 09:31:07 +0000 (09:31 +0000)
gnunet-namestore can set nick name in namestore

src/gns/gnunet-service-gns_shorten.c
src/gns/plugin_gnsrecord_gns.c
src/include/gnunet_gnsrecord_lib.h
src/namestore/gnunet-namestore.c

index 543b4042f7345d60dfd91c2f0ae7c3d65e279032..9c27da16fb2416e07d2db24c75a0f5955eaa4880 100644 (file)
@@ -380,7 +380,7 @@ process_auth_records (void *cls,
 
   for (i=0; i < rd_count; i++)
   {
-    if (GNUNET_GNSRECORD_TYPE_PSEU == rd[i].record_type)
+    if (GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type)
     {
       char pseu[rd[i].data_size + 1];
 
index 96ad0aa8d6030fd56884116dd8e7a548511b9d9a..14b015c0cc5160cf351039aa0cbbe76c42925e5e 100644 (file)
@@ -57,7 +57,7 @@ gns_value_to_string (void *cls,
     if (data_size != sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))
       return NULL;
     return GNUNET_CRYPTO_ecdsa_public_key_to_string (data);
-  case GNUNET_GNSRECORD_TYPE_PSEU:
+  case GNUNET_GNSRECORD_TYPE_NICK:
     return GNUNET_strndup (data, data_size);
   case GNUNET_GNSRECORD_TYPE_LEHO:
     return GNUNET_strndup (data, data_size);
@@ -157,7 +157,7 @@ gns_string_to_value (void *cls,
     *data_size = sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey);
     return GNUNET_OK;
 
-  case GNUNET_GNSRECORD_TYPE_PSEU:
+  case GNUNET_GNSRECORD_TYPE_NICK:
     *data = GNUNET_strdup (s);
     *data_size = strlen (s);
     return GNUNET_OK;
@@ -246,7 +246,7 @@ static struct {
   uint32_t number;
 } name_map[] = {
   { "PKEY",  GNUNET_GNSRECORD_TYPE_PKEY },
-  { "PSEU",  GNUNET_GNSRECORD_TYPE_PSEU },
+  { "NICK",  GNUNET_GNSRECORD_TYPE_NICK },
   { "LEHO",  GNUNET_GNSRECORD_TYPE_LEHO },
   { "VPN", GNUNET_GNSRECORD_TYPE_VPN },
   { "GNS2DNS", GNUNET_GNSRECORD_TYPE_GNS2DNS },
index 96e7e3aeed6e3b1effa9246b75c6bf3f2c386078..04a772c10eaa06c6df8c69203eee625dac908e45 100644 (file)
@@ -51,9 +51,9 @@ extern "C"
 #define GNUNET_GNSRECORD_TYPE_PKEY 65536
 
 /**
- * Record type for GNS zone transfer ("PSEU").
+ * Record type for GNS nick names ("NICK").
  */
-#define GNUNET_GNSRECORD_TYPE_PSEU 65537
+#define GNUNET_GNSRECORD_TYPE_NICK 65537
 
 /**
  * Record type for GNS legacy hostnames ("LEHO").
index 5becf0e6c9eb994f75c23d663369b754be34ccfe..f8ad83259fc7c64812898593f6e5a71c174dbba6 100644 (file)
@@ -134,6 +134,11 @@ static char *typestring;
  */
 static char *expirationstring;
 
+/**
+ * Desired nick name.
+ */
+static char *nickstring;
+
 /**
  * Global return value
  */
@@ -521,7 +526,7 @@ testservice_task (void *cls,
             "namestore");
     return;
   }
-  if (! (add|del|list|(NULL != uri)|(NULL != reverse_pkey)) )
+  if (! (add|del|list|(NULL != nickstring)|(NULL != uri)|(NULL != reverse_pkey)) )
   {
     /* nothing more to be done */
     fprintf (stderr,
@@ -705,6 +710,7 @@ testservice_task (void *cls,
       rd.expiration_time = etime_abs.abs_value_us;
     else
       rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
+
     if (1 != shadow)
       rd.flags |= GNUNET_GNSRECORD_RF_SHADOW_RECORD;
     add_qe_uri = GNUNET_NAMESTORE_records_store (ns,
@@ -715,6 +721,31 @@ testservice_task (void *cls,
                                                 &add_continuation,
                                                 &add_qe_uri);
   }
+  if (NULL != nickstring)
+  {
+    if (0 == strlen(nickstring))
+    {
+      fprintf (stderr,
+               _("Invalid nick `%s'\n"),
+               nickstring);
+      GNUNET_SCHEDULER_shutdown ();
+      ret = 1;
+      return;
+    }
+    memset (&rd, 0, sizeof (rd));
+    rd.data = nickstring;
+    rd.data_size = strlen(nickstring);
+    rd.record_type = GNUNET_GNSRECORD_TYPE_NICK;
+    rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
+    rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE;
+    add_qe_uri = GNUNET_NAMESTORE_records_store (ns,
+                                                 &zone_pkey,
+                                                 "+",
+                                                 1,
+                                                 &rd,
+                                                 &add_continuation,
+                                                 &add_qe_uri);
+  }
   if (monitor)
   {
     zm = GNUNET_NAMESTORE_zone_monitor_start (cfg,
@@ -777,6 +808,7 @@ run (void *cls, char *const *args, const char *cfgfile,
             _("You must specify which zone should be accessed\n"));
     return;
   }
+
   if ( (NULL != args[0]) && (NULL == uri) )
     uri = GNUNET_strdup (args[0]);
   GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
@@ -814,6 +846,9 @@ main (int argc, char *const *argv)
     {'e', "expiration", "TIME",
      gettext_noop ("expiration time for record to use (for adding only), \"never\" is possible"), 1,
      &GNUNET_GETOPT_set_string, &expirationstring},
+    {'i', "nick", "NICKNAME",
+     gettext_noop ("set the desired nick name for the zone"), 1,
+     &GNUNET_GETOPT_set_string, &nickstring},
     {'m', "monitor", NULL,
      gettext_noop ("monitor changes in the namestore"), 0,
      &GNUNET_GETOPT_set_one, &monitor},