gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r29013 - in gnunet: doc/man src/identity src/include src/na


From: gnunet
Subject: [GNUnet-SVN] r29013 - in gnunet: doc/man src/identity src/include src/namestore src/peerinfo
Date: Thu, 5 Sep 2013 12:52:30 +0200

Author: grothoff
Date: 2013-09-05 12:52:29 +0200 (Thu, 05 Sep 2013)
New Revision: 29013

Modified:
   gnunet/doc/man/gnunet-identity.1
   gnunet/doc/man/gnunet-namestore-fcfsd.1
   gnunet/src/identity/gnunet-identity.c
   gnunet/src/include/gnunet_crypto_lib.h
   gnunet/src/namestore/Makefile.am
   gnunet/src/namestore/gnunet-namestore-fcfsd.c
   gnunet/src/peerinfo/gnunet-service-peerinfo.c
Log:
-improving gnunet-identity command line options and man pages

Modified: gnunet/doc/man/gnunet-identity.1
===================================================================
--- gnunet/doc/man/gnunet-identity.1    2013-09-05 10:18:40 UTC (rev 29012)
+++ gnunet/doc/man/gnunet-identity.1    2013-09-05 10:52:29 UTC (rev 29013)
@@ -21,6 +21,10 @@
 Delete the ego with the given NAME.
 
 .TP
+\fB\-e NAME\fR, \fB\-\-ego=NAME\fR
+Perform "set" operation with the respective ego.  Needs to be used together 
with option \-s.
+
+.TP
 \fB\-h\fR, \fB\-\-help\fR
 Print help page.
 
@@ -32,7 +36,11 @@
 \fB\-m\fR, \fB\-\-monitor\fR
 run in monitor mode, listing all ouf our egos until CTRL-C is pressed. Each 
ego is listed together with a unique pointer value; if egos are renamed, that 
pointer value remains the same; if egos are deleted, they are listed one more 
time with a name of "<null>".
 
+.TP
+\fB\-s SUBSYSTEM\fR, \fB\-\-set=SUBSYSTEM\fR
+Perform "set" operation for the specified SUBSYSTEM with the respective ego.  
Needs to be used together with option \-e.  After this, the given SUBSYSTEM 
will use the ego with the specified NAME.  This will fail if NAME does not yet 
exist.
 
+
 .SH FILES
 .TP
 ~/.gnunet/egos/

Modified: gnunet/doc/man/gnunet-namestore-fcfsd.1
===================================================================
--- gnunet/doc/man/gnunet-namestore-fcfsd.1     2013-09-05 10:18:40 UTC (rev 
29012)
+++ gnunet/doc/man/gnunet-namestore-fcfsd.1     2013-09-05 10:52:29 UTC (rev 
29013)
@@ -1,7 +1,7 @@
 .TH GNUNET\-NAMESTORE-FCFSD 1 "Oct 25, 2012" "GNUnet"
 
 .SH NAME
-gnunet\-namestore-fcfsd \- HTTP server for GNS domain registration
+gnunet\-namestore-fcfsd \- HTTP server for GNU Name System 
First-Come-First-Served name registration
 
 .SH SYNOPSIS
 .B gnunet\-namestore-fcfsd
@@ -11,10 +11,12 @@
 .SH DESCRIPTION
 Most users will not want to run an FCFS\-zone and thus will not need this 
program.
 
-\fBgnunet\-gns-fcfsd\fP runs a web server where users can register names to be 
mapped to their GADS zone.  Names are made available on a First Come First 
Served basis (hence fcfs).  Registered names do not expire.  The HTTP server is 
run on the port that is specified in the configuration file in section 
"[fcfsd]" under the name "HTTPPORT".  The key of the zone in which the names 
are registered must be specified under the name "ZONEKEY" in the same section.  
It is possible to manage gnunet\-gns\-fcfsd using gnunet\-(service\-arm) by 
starting the daemon using "gnunet\-arm -i fcfsd" or by adding "fcfds" to the 
"DEFAULTSERVICES" option.
+\fBgnunet\-gns-fcfsd\fP runs a web server where users can register names to be 
mapped to their GNS zone.  Names are made available on a First Come First 
Served basis (hence fcfs).  Registered names do not expire.  The HTTP server is 
run on the port that is specified in the configuration file in section 
"[fcfsd]" under the name "HTTPPORT".  The key of the zone in which the names 
are registered must be specified under the name "ZONEKEY" in the same section.  
It is possible to manage gnunet\-gns\-fcfsd using gnunet\-(service\-arm) by 
starting the daemon using "gnunet\-arm \-i fcfsd" or by adding "fcfds" to the 
"DEFAULTSERVICES" option.
 
-An FCFS\-zone is run at http://gnunet.org/fcfs/.  The respective zone key can 
be imported into an individual user's zone using "gnunet-gns-import.sh".  GADS 
users are encouraged to register their zone with the gnunet.org FCFS authority.
+An FCFS\-zone is run at http://gnunet.org/fcfs/.  The respective zone key can 
be imported into an individual user's zone using "gnunet-gns-import.sh".  GNS 
users are encouraged to register their zone with the gnunet.org FCFS authority.
 
+If you want to run your own FCFS registrar, you need to first create a 
pseudonym (using "gnunet\-identity \-C NAME"), and then assign it to be used 
for the "fcfsd" service using "gnunet\-identity \-e NAME \-s fcfsd".  After 
that, you can start the FCFSD service (possibly using gnunet\-arm).
+
 .SH OPTIONS
 .B
 .IP "\-c FILENAME,  \-\-config=FILENAME"
@@ -34,5 +36,4 @@
 Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending 
electronic mail to <address@hidden>
 
 .SH SEE ALSO
-gnunet\-gns(1), gnunet\-gns\-proxy(1)
-
+gnunet\-identity(1), gnunet\-gns(1), gnunet\-gns\-proxy(1)

Modified: gnunet/src/identity/gnunet-identity.c
===================================================================
--- gnunet/src/identity/gnunet-identity.c       2013-09-05 10:18:40 UTC (rev 
29012)
+++ gnunet/src/identity/gnunet-identity.c       2013-09-05 10:52:29 UTC (rev 
29013)
@@ -23,8 +23,7 @@
  * @author Christian Grothoff
  *
  * Todo:
- * - add options to get/set default egos
- * - print short hashes of egos when printing
+ * - add options to get default egos
  */
 #include "platform.h"
 #include "gnunet_util_lib.h"
@@ -56,6 +55,21 @@
 static char *delete_ego;
 
 /**
+ * -s option.
+ */
+static char *set_ego;
+
+/**
+ * -S option.
+ */
+static char *set_subsystem;
+
+/**
+ * Operation handle for set operation.
+ */
+static struct GNUNET_IDENTITY_Operation *set_op;
+
+/**
  * Handle for create operation.
  */
 static struct GNUNET_IDENTITY_Operation *create_op;
@@ -76,12 +90,26 @@
 shutdown_task (void *cls,
               const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
+  if (NULL != set_op)
+  {
+    GNUNET_IDENTITY_cancel (set_op);
+    set_op = NULL;
+  }
+  if (NULL != create_op)
+  {
+    GNUNET_IDENTITY_cancel (create_op);
+    create_op = NULL;
+  }
+  if (NULL != delete_op)
+  {
+    GNUNET_IDENTITY_cancel (delete_op);
+    delete_op = NULL;
+  }  
   GNUNET_IDENTITY_disconnect (sh);
   sh = NULL;
 }
 
 
-
 /**
  * Test if we are finished yet.
  */
@@ -90,6 +118,8 @@
 {
   if ( (NULL == create_op) &&
        (NULL == delete_op) &&
+       (NULL == set_op) &&
+       (NULL == set_ego) &&
        (! list) &&
        (! monitor) )  
     GNUNET_SCHEDULER_shutdown ();
@@ -139,6 +169,25 @@
 
 
 /**
+ * Function called by #GNUNET_IDENTITY_set up on completion.
+ *
+ * @param cls NULL
+ * @param emsg error message (NULL on success)
+ */
+static void
+set_done (void *cls,
+         const char *emsg)
+{
+  set_op = NULL;
+  if (NULL != emsg)
+    fprintf (stderr,
+            _("Failed to set default ego: %s\n"),
+            emsg);
+  test_finished ();
+}
+
+
+/**
  * If listing is enabled, prints information about the egos.
  *
  * This function is initially called for all egos and then again
@@ -177,17 +226,48 @@
           void **ctx,
           const char *identifier)
 {
-  if (! (list | monitor))
-    return;
+  struct GNUNET_CRYPTO_EccPublicKey pk;
+  char *s;
+
+  if ( (NULL != set_ego) &&
+       (NULL != ego) &&
+       (NULL != identifier) &&
+       (0 == strcmp (identifier, 
+                    set_ego)) )
+    {
+      set_op = GNUNET_IDENTITY_set (sh,
+                                   set_subsystem,
+                                   ego,
+                                   &set_done,
+                                   NULL);
+      GNUNET_free (set_subsystem);
+      set_subsystem = NULL;
+      GNUNET_free (set_ego);
+      set_ego = NULL;
+    }
+  if ( (NULL == ego) &&
+       (NULL != set_ego) )
+  {
+    fprintf (stderr,
+            "Could not set ego to `%s' for subsystem `%s', ego not known\n",
+            set_ego,
+            set_subsystem);
+    GNUNET_free (set_subsystem);
+    set_subsystem = NULL;
+    GNUNET_free (set_ego);
+    set_ego = NULL;
+  }
   if ( (NULL == ego) && (! monitor) )
   {
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  if (monitor)
-    fprintf (stderr, "%s - %p\n", identifier, ego);
-  else if (NULL != identifier)
-    fprintf (stderr, "%s\n", identifier);
+  if (! (list | monitor))
+    return;
+  GNUNET_IDENTITY_ego_get_public_key (ego, &pk);
+  s = GNUNET_CRYPTO_ecc_public_key_to_string (&pk);
+  if ( (monitor) || (NULL != identifier) )
+    fprintf (stderr, "%s - %s\n", identifier, s);
 }
 
 
@@ -203,6 +283,13 @@
 run (void *cls, char *const *args, const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
+  if ( (NULL == set_subsystem) ^
+       (NULL == set_ego) )
+  {
+    fprintf (stderr,
+            "Options -e and -s must always be specified together\n");
+    return;
+  }
   sh = GNUNET_IDENTITY_connect (cfg, &print_ego, NULL);
   if (NULL != delete_ego)
     delete_op = GNUNET_IDENTITY_delete (sh,
@@ -242,9 +329,15 @@
     {'d', "display", NULL,
      gettext_noop ("display all egos"),
      0, &GNUNET_GETOPT_set_one, &list},
+    {'e', "ego", "NAME",
+     gettext_noop ("set default identity to EGO for a subsystem SUBSYSTEM (use 
together with -s)"),
+     1, &GNUNET_GETOPT_set_string, &set_ego},
     {'m', "monitor", NULL,
      gettext_noop ("run in monitor mode egos"),
      0, &GNUNET_GETOPT_set_one, &monitor},
+    {'s', "set", "SUBSYSYSTEM",
+     gettext_noop ("set default identity to EGO for a subsystem SUBSYSTEM (use 
together with -e)"),
+     1, &GNUNET_GETOPT_set_string, &set_subsystem},
     GNUNET_GETOPT_OPTION_END
   };
 

Modified: gnunet/src/include/gnunet_crypto_lib.h
===================================================================
--- gnunet/src/include/gnunet_crypto_lib.h      2013-09-05 10:18:40 UTC (rev 
29012)
+++ gnunet/src/include/gnunet_crypto_lib.h      2013-09-05 10:52:29 UTC (rev 
29013)
@@ -427,12 +427,12 @@
 
 /**
  * @ingroup hash
- * Compute the distance between 2 hashcodes.
- * The computation must be fast, not involve
- * a.a or a.e (they're used elsewhere), and
- * be somewhat consistent. And of course, the
- * result should be a positive number.
  *
+ * Compute the distance between 2 hashcodes.  The
+ * computation must be fast, not involve a[0] or a[4] (they're used
+ * elsewhere), and be somewhat consistent. And of course, the result
+ * should be a positive number.
+ *
  * @param a some hash code
  * @param b some hash code
  * @return number between 0 and UINT32_MAX

Modified: gnunet/src/namestore/Makefile.am
===================================================================
--- gnunet/src/namestore/Makefile.am    2013-09-05 10:18:40 UTC (rev 29012)
+++ gnunet/src/namestore/Makefile.am    2013-09-05 10:52:29 UTC (rev 29013)
@@ -43,16 +43,16 @@
 TESTING_TESTS = \
  test_namestore_api \
  test_namestore_api_remove
- #test_namestore_api_lookup \
- #test_namestore_api_lookup_specific_type \
- #test_namestore_api_create \
- #test_namestore_api_create_update \ 
- #test_namestore_api_remove_not_existing_record \
- #test_namestore_api_zone_to_name \
- #test_namestore_api_monitoring \
- #test_namestore_api_zone_iteration \
- #test_namestore_api_zone_iteration_specific_zone \
- #test_namestore_api_zone_iteration_stop
+#test_namestore_api_lookup
+#test_namestore_api_lookup_specific_type
+#test_namestore_api_create 
+#test_namestore_api_create_update
+#test_namestore_api_remove_not_existing_record 
+#test_namestore_api_zone_to_name 
+#test_namestore_api_monitoring 
+#test_namestore_api_zone_iteration 
+#test_namestore_api_zone_iteration_specific_zone 
+#test_namestore_api_zone_iteration_stop
 endif
 
 if HAVE_SQLITE
@@ -115,6 +115,7 @@
  gnunet-namestore-fcfsd.c 
 gnunet_namestore_fcfsd_LDADD = -lmicrohttpd \
   $(top_builddir)/src/util/libgnunetutil.la \
+  $(top_builddir)/src/identity/libgnunetidentity.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la \
   $(GN_LIBINTL)
 gnunet_namestore_fcfsd_DEPENDENCIES = \

Modified: gnunet/src/namestore/gnunet-namestore-fcfsd.c
===================================================================
--- gnunet/src/namestore/gnunet-namestore-fcfsd.c       2013-09-05 10:18:40 UTC 
(rev 29012)
+++ gnunet/src/namestore/gnunet-namestore-fcfsd.c       2013-09-05 10:52:29 UTC 
(rev 29013)
@@ -31,6 +31,7 @@
 #include "platform.h"
 #include <microhttpd.h>
 #include "gnunet_util_lib.h"
+#include "gnunet_identity_service.h"
 #include "gnunet_namestore_service.h"
 
 /**
@@ -63,7 +64,7 @@
 /**
  * Name of our cookie.
  */
-#define COOKIE_NAME "gns-fcfs"
+#define COOKIE_NAME "namestore-fcfsd"
 
 #define DEFAULT_ZONEINFO_BUFSIZE 2048
 
@@ -193,7 +194,22 @@
 /**
  * Private key for the fcfsd zone.
  */
-static struct GNUNET_CRYPTO_EccPrivateKey *fcfs_zone_pkey;
+static struct GNUNET_CRYPTO_EccPrivateKey fcfs_zone_pkey;
+
+/**
+ * Connection to identity service.
+ */
+static struct GNUNET_IDENTITY_Handle *identity;
+
+/**
+ * Request for our ego.
+ */
+static struct GNUNET_IDENTITY_Operation *id_op;
+
+/**
+ * Port we use for the HTTP server.
+ */
+static unsigned long long port;
                        
 
 /**
@@ -315,7 +331,7 @@
   zr->connection = connection;
   zr->write_offset = 0;
   zr->list_it = GNUNET_NAMESTORE_zone_iteration_start (ns,
-                                                      fcfs_zone_pkey,
+                                                      &fcfs_zone_pkey,
                                                       &iterate_cb,
                                                       zr);
   return MHD_YES;
@@ -511,7 +527,7 @@
   r.record_type = GNUNET_NAMESTORE_TYPE_PKEY;
   r.flags = GNUNET_NAMESTORE_RF_AUTHORITY;
   request->qe = GNUNET_NAMESTORE_records_store (ns,
-                                               fcfs_zone_pkey,
+                                               &fcfs_zone_pkey,
                                                request->domain_name,
                                                1, &r,
                                                &put_continuation,
@@ -557,7 +573,7 @@
     return;
   }
   request->qe = GNUNET_NAMESTORE_zone_to_name (ns,
-                                              fcfs_zone_pkey,
+                                              &fcfs_zone_pkey,
                                               &pub,
                                               &zone_to_name_cb,
                                               request);
@@ -584,7 +600,7 @@
     lookup_result_processor (request, 0, NULL);
     return;
   }
-  GNUNET_CRYPTO_ecc_key_get_public (fcfs_zone_pkey,
+  GNUNET_CRYPTO_ecc_key_get_public (&fcfs_zone_pkey,
                                    &pub);
   if (GNUNET_OK != 
       GNUNET_NAMESTORE_block_decrypt (block,
@@ -715,7 +731,7 @@
                                 request, connection);
          }
          request->phase = RP_LOOKUP;
-         GNUNET_CRYPTO_ecc_key_get_public (fcfs_zone_pkey,
+         GNUNET_CRYPTO_ecc_key_get_public (&fcfs_zone_pkey,
                                            &pub);
          GNUNET_NAMESTORE_query_from_public_key (&pub,
                                                  request->domain_name,
@@ -867,14 +883,73 @@
     MHD_stop_daemon (httpd);
     httpd = NULL;
   }
-  if (NULL != fcfs_zone_pkey)
+  if (NULL != id_op)
   {
-    GNUNET_free (fcfs_zone_pkey);
-    fcfs_zone_pkey = NULL;
+    GNUNET_IDENTITY_cancel (id_op);
+    id_op = NULL;
   }
+  if (NULL != identity)
+  {
+    GNUNET_IDENTITY_disconnect (identity);
+    identity = NULL;
+  }
 }
 
 
+/** 
+ * Method called to inform about the egos of this peer.
+ *
+ * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get,
+ * this function is only called ONCE, and 'NULL' being passed in
+ * @a ego does indicate an error (i.e. name is taken or no default
+ * value is known).  If @a ego is non-NULL and if '*ctx'
+ * is set in those callbacks, the value WILL be passed to a subsequent
+ * call to the identity callback of #GNUNET_IDENTITY_connect (if 
+ * that one was not NULL).
+ *
+ * @param cls closure, NULL
+ * @param ego ego handle
+ * @param ctx context for application to store data for this ego
+ *                 (during the lifetime of this process, initially NULL)
+ * @param name name assigned by the user for this ego,
+ *                   NULL if the user just deleted the ego and it
+ *                   must thus no longer be used
+ */
+static void
+identity_cb (void *cls,
+            struct GNUNET_IDENTITY_Ego *ego,
+            void **ctx,
+            const char *name)
+{
+  id_op = NULL;
+  if (NULL == ego)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+               _("No ego configured for `fcfsd` subsystem\n"));
+    return;
+  }
+  fcfs_zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego);
+  httpd = MHD_start_daemon (MHD_USE_DUAL_STACK | MHD_USE_DEBUG,
+                           (uint16_t) port,
+                           NULL, NULL, 
+                           &create_response, NULL, 
+                           MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 128,
+                           MHD_OPTION_PER_IP_CONNECTION_LIMIT, (unsigned int) 
1,
+                           MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16,
+                           MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (4 * 
1024), 
+                           MHD_OPTION_NOTIFY_COMPLETED, 
&request_completed_callback, NULL,
+                           MHD_OPTION_END);
+  if (NULL == httpd)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+               _("Failed to start HTTP server\n"));
+    GNUNET_SCHEDULER_shutdown ();
+    return;
+  }
+  run_httpd ();
+}
+
+
 /**
  * Main function that will be run.
  *
@@ -887,9 +962,6 @@
 run (void *cls, char *const *args, const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
-  char *keyfile;
-  unsigned long long port;
-
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_number (cfg,
                                             "fcfsd",
@@ -900,24 +972,6 @@
                               "fcfsd", "HTTPPORT");
     return;
   }
-  if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_filename (cfg,
-                                              "fcfsd",
-                                              "ZONEKEY",
-                                              &keyfile))
-  {
-    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
-                              "fcfsd", "ZONEKEY");
-    return;
-  }
-  fcfs_zone_pkey = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile);
-  GNUNET_free (keyfile);
-  if (NULL == fcfs_zone_pkey)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-               _("Failed to read or create private zone key\n"));
-    return;
-  }
   ns = GNUNET_NAMESTORE_connect (cfg);
   if (NULL == ns)
     {
@@ -925,25 +979,10 @@
                  _("Failed to connect to namestore\n"));
       return;
     }
-  httpd = MHD_start_daemon (MHD_USE_DEBUG,
-                           (uint16_t) port,
-                           NULL, NULL, 
-                           &create_response, NULL, 
-                           MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 128,
-                           MHD_OPTION_PER_IP_CONNECTION_LIMIT, (unsigned int) 
1,
-                           MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16,
-                           MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (4 * 
1024), 
-                           MHD_OPTION_NOTIFY_COMPLETED, 
&request_completed_callback, NULL,
-                           MHD_OPTION_END);
-  if (NULL == httpd)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-               _("Failed to start HTTP server\n"));
-    GNUNET_NAMESTORE_disconnect (ns);
-    ns = NULL;
-    return;
-  }
-  run_httpd ();
+  identity = GNUNET_IDENTITY_connect (cfg,
+                                     NULL, NULL);
+  id_op = GNUNET_IDENTITY_get (identity, "fcfsd",
+                              &identity_cb, NULL);
   GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
                                &do_shutdown, NULL);
 }
@@ -972,11 +1011,11 @@
   ret =
       (GNUNET_OK ==
        GNUNET_PROGRAM_run (argc, argv, "fcfsd",
-                           _("GNUnet GNS first come first serve registration 
service"), 
+                           _("GNU Name System First Come First Serve name 
registration service"), 
                           options,
                            &run, NULL)) ? 0 : 1;
   GNUNET_free ((void*) argv);
   return ret;
 }
 
-/* end of gnunet-gns-fcfsd.c */
+/* end of gnunet-namestore-fcfsd.c */

Modified: gnunet/src/peerinfo/gnunet-service-peerinfo.c
===================================================================
--- gnunet/src/peerinfo/gnunet-service-peerinfo.c       2013-09-05 10:18:40 UTC 
(rev 29012)
+++ gnunet/src/peerinfo/gnunet-service-peerinfo.c       2013-09-05 10:52:29 UTC 
(rev 29013)
@@ -516,7 +516,7 @@
  * @param cls pointer to 'unsigned int' to increment for each file, or NULL
  *            if the file is from a read-only, read-once resource directory
  * @param fullname name of the file to parse
- * @return GNUNET_OK (continue iteration)
+ * @return #GNUNET_OK (continue iteration)
  */
 static int
 hosts_directory_scan_callback (void *cls, const char *fullname)




reply via email to

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