gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r28710 - in gnunet: doc/man src/namestore


From: gnunet
Subject: [GNUnet-SVN] r28710 - in gnunet: doc/man src/namestore
Date: Mon, 19 Aug 2013 20:56:26 +0200

Author: grothoff
Date: 2013-08-19 20:56:26 +0200 (Mon, 19 Aug 2013)
New Revision: 28710

Modified:
   gnunet/doc/man/gnunet-namestore.1
   gnunet/src/namestore/Makefile.am
   gnunet/src/namestore/gnunet-namestore.c
Log:
-implementing #2990: integration of gnunet-namestore with identity service

Modified: gnunet/doc/man/gnunet-namestore.1
===================================================================
--- gnunet/doc/man/gnunet-namestore.1   2013-08-19 16:26:52 UTC (rev 28709)
+++ gnunet/doc/man/gnunet-namestore.1   2013-08-19 18:56:26 UTC (rev 28710)
@@ -52,8 +52,8 @@
 .IP "\-V VALUE, \-\-value=VALUE"
 Value to store or remove from the GNS zone.  Specific format depends on the 
record type.  A records expect a dotted decimal IPv4 address, AAAA records an 
IPv6 address, PKEY a public key in GNUnet's printable format, and CNAME and NS 
records should be a domain name.
 .B
-.IP "\-z FILENAME, \-\-zonekey=FILENAME"
-Specifies the filename with the private key for the zone (mandatory option)
+.IP "\-z EGO, \-\-zone=EGO"
+Specifies the name of the ego controlling the private key for the zone 
(mandatory option)
 
 
 .SH BUGS

Modified: gnunet/src/namestore/Makefile.am
===================================================================
--- gnunet/src/namestore/Makefile.am    2013-08-19 16:26:52 UTC (rev 28709)
+++ gnunet/src/namestore/Makefile.am    2013-08-19 18:56:26 UTC (rev 28710)
@@ -103,9 +103,11 @@
  gnunet-namestore.c 
 gnunet_namestore_LDADD = \
   $(top_builddir)/src/util/libgnunetutil.la \
+  $(top_builddir)/src/identity/libgnunetidentity.la \
   libgnunetnamestore.la \
   $(GN_LIBINTL)
 gnunet_namestore_DEPENDENCIES = \
+  $(top_builddir)/src/identity/libgnunetidentity.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   libgnunetnamestore.la
 

Modified: gnunet/src/namestore/gnunet-namestore.c
===================================================================
--- gnunet/src/namestore/gnunet-namestore.c     2013-08-19 16:26:52 UTC (rev 
28709)
+++ gnunet/src/namestore/gnunet-namestore.c     2013-08-19 18:56:26 UTC (rev 
28710)
@@ -30,6 +30,7 @@
 #include "platform.h"
 #include <gnunet_util_lib.h>
 #include <gnunet_dnsparser_lib.h>
+#include <gnunet_identity_service.h>
 #include <gnunet_namestore_service.h>
 
 
@@ -41,14 +42,19 @@
 /**
  * Private key for the our zone.
  */
-static struct GNUNET_CRYPTO_EccPrivateKey *zone_pkey;
+static struct GNUNET_CRYPTO_EccPrivateKey zone_pkey;
 
 /**
- * Keyfile to manipulate.  FIXME: change to ego's name!
+ * Handle to identity service.
  */
-static char *keyfile;  
+static struct GNUNET_IDENTITY_Handle *identity;
 
 /**
+ * Name of the ego controlling the zone.
+ */
+static char *ego_name; 
+
+/**
  * Desired action is to add a record.
  */
 static int add;
@@ -204,11 +210,7 @@
     GNUNET_NAMESTORE_disconnect (ns);
     ns = NULL;
   }
-  if (NULL != zone_pkey)
-  {
-    GNUNET_CRYPTO_ecc_key_free (zone_pkey);
-    zone_pkey = NULL;
-  }
+  memset (&zone_pkey, 0, sizeof (zone_pkey));
   if (NULL != uri)
   {
     GNUNET_free (uri);
@@ -396,7 +398,7 @@
     rde->flags |= GNUNET_NAMESTORE_RF_PRIVATE;
   GNUNET_assert (NULL != name);
   add_qe = GNUNET_NAMESTORE_records_store (ns,
-                                          zone_pkey,
+                                          &zone_pkey,
                                           name,
                                           rd_count + 1,
                                           rde,
@@ -429,37 +431,14 @@
             "namestore");
     return;
   }
-  if (NULL == keyfile)
-  {
-    if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
-                                                              "ZONEKEY", 
&keyfile))
-    {
-      GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
-                                "gns", "ZONEKEY");
-      return;
-    }
-    fprintf (stderr,
-             _("Using default zone file `%s'\n"),
-             keyfile);
-  }
-  zone_pkey = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile);
-
   if (! (add|del|list|(NULL != uri)))
   {
     /* nothing more to be done */  
     fprintf (stderr,
              _("No options given\n"));
-    GNUNET_CRYPTO_ecc_key_free (zone_pkey);
-    zone_pkey = NULL;
     return; 
   }
-  if (NULL == zone_pkey)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                _("Failed to read or create private zone key\n"));
-    return;
-  }
-  GNUNET_CRYPTO_ecc_key_get_public (zone_pkey,
+  GNUNET_CRYPTO_ecc_key_get_public (&zone_pkey,
                                     &pub);
 
   ns = GNUNET_NAMESTORE_connect (cfg);
@@ -557,7 +536,7 @@
       return;     
     }
     add_zit = GNUNET_NAMESTORE_zone_iteration_start (ns,
-                                                    zone_pkey,
+                                                    &zone_pkey,
                                                     &get_existing_record,
                                                     NULL);
   }
@@ -573,7 +552,7 @@
       return;     
     }
     del_qe = GNUNET_NAMESTORE_records_store (ns,
-                                            zone_pkey,
+                                            &zone_pkey,
                                             name,
                                             0, NULL,
                                             &del_continuation,
@@ -582,7 +561,7 @@
   if (list)
   {
     list_it = GNUNET_NAMESTORE_zone_iteration_start (ns,
-                                                     zone_pkey,
+                                                     &zone_pkey,
                                                      &display_record,
                                                      NULL);
   }
@@ -622,7 +601,7 @@
     if (1 != nonauthority)
       rd.flags |= GNUNET_NAMESTORE_RF_AUTHORITY;
     add_qe_uri = GNUNET_NAMESTORE_records_store (ns,
-                                                zone_pkey,
+                                                &zone_pkey,
                                                 sname,
                                                 1,
                                                 &rd,
@@ -632,7 +611,7 @@
   if (monitor)
   {
     zm = GNUNET_NAMESTORE_zone_monitor_start (cfg,
-                                             zone_pkey,
+                                             &zone_pkey,
                                              &display_record,
                                              &sync_cb,
                                              NULL);
@@ -641,6 +620,52 @@
 
 
 /**
+ * Callback invoked from identity service with ego information.
+ * An @a ego of NULL and a @a name of NULL indicate the end of
+ * the initial iteration over known egos.
+ *
+ * @param cls closure with the configuration
+ * @param ego an ego known to identity service, or NULL 
+ * @param ctx per-ego user context (unused)
+ * @param name name of the ego, or NULL
+ */
+static void
+identity_cb (void *cls,
+            struct GNUNET_IDENTITY_Ego *ego,
+            void **ctx,
+            const char *name)
+{
+  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
+
+  if ( (NULL != ego_name) &&
+       (0 == strcmp (name,
+                    ego_name)) )
+  {
+    zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego);
+    GNUNET_free (ego_name);
+    ego_name = NULL;
+    GNUNET_CLIENT_service_test ("namestore", cfg,
+                               GNUNET_TIME_UNIT_SECONDS,
+                               &testservice_task,
+                               (void *) cfg);
+    GNUNET_IDENTITY_disconnect (identity);
+    identity = NULL;
+  }
+  if ( (NULL != ego_name) &&
+       (NULL == name) &&
+       (NULL == ego) )
+  {
+    fprintf (stderr, 
+            _("Ego `%s' not known to identity service\n"),
+            ego_name);
+    GNUNET_IDENTITY_disconnect (identity);
+    identity = NULL;
+    return;
+  }
+}
+
+
+/**
  * Main function that will be run.
  *
  * @param cls closure
@@ -652,14 +677,17 @@
 run (void *cls, char *const *args, const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
-
+  if (NULL == ego_name)
+  {
+    fprintf (stderr, 
+            _("You must specify which zone should be accessed\n"));
+    return;
+  }
   if ( (NULL != args[0]) && (NULL == uri) )
     uri = GNUNET_strdup (args[0]);
-
-  GNUNET_CLIENT_service_test ("namestore", cfg,
-                             GNUNET_TIME_UNIT_SECONDS,
-                             &testservice_task,
-                             (void *) cfg);
+  identity = GNUNET_IDENTITY_connect (cfg,
+                                     &identity_cb,
+                                     (void *) cfg);
 }
 
 
@@ -710,9 +738,9 @@
     {'N', "non-authority", NULL,
      gettext_noop ("create or list non-authority record"), 0,
      &GNUNET_GETOPT_set_one, &nonauthority},
-    {'z', "zonekey", "FILENAME",
-     gettext_noop ("filename with the zone key"), 1,
-     &GNUNET_GETOPT_set_string, &keyfile},   
+    {'z', "zone", "EGO",
+     gettext_noop ("name of the ego controlling the zone"), 1,
+     &GNUNET_GETOPT_set_string, &ego_name},   
     GNUNET_GETOPT_OPTION_END
   };
 




reply via email to

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