gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r20241 - in gnunet: doc/man src/gns


From: gnunet
Subject: [GNUnet-SVN] r20241 - in gnunet: doc/man src/gns
Date: Sun, 4 Mar 2012 16:02:08 +0100

Author: grothoff
Date: 2012-03-04 16:02:08 +0100 (Sun, 04 Mar 2012)
New Revision: 20241

Added:
   gnunet/doc/man/gnunet-gns.1
   gnunet/src/gns/gnunet-gns.c
Modified:
   gnunet/doc/man/Makefile.am
   gnunet/src/gns/Makefile.am
Log:
adding gnunet-gns, a new tool for zone manipulations

Modified: gnunet/doc/man/Makefile.am
===================================================================
--- gnunet/doc/man/Makefile.am  2012-03-04 14:43:14 UTC (rev 20240)
+++ gnunet/doc/man/Makefile.am  2012-03-04 15:02:08 UTC (rev 20241)
@@ -4,6 +4,7 @@
   gnunet-download.1 \
   gnunet-download-manager.1 \
   gnunet-fs.1 \
+  gnunet-gns.1 \
   gnunet-nat-server.1 \
   gnunet-peerinfo.1 \
   gnunet-pseudonym.1 \

Added: gnunet/doc/man/gnunet-gns.1
===================================================================
--- gnunet/doc/man/gnunet-gns.1                         (rev 0)
+++ gnunet/doc/man/gnunet-gns.1 2012-03-04 15:02:08 UTC (rev 20241)
@@ -0,0 +1,34 @@
+.TH GNUNET\-GNS 1 "Jan 4, 2012" "GNUnet"
+
+.SH NAME
+gnunet\-gns \- manipulate GNUnet GNS zones
+
+.SH SYNOPSIS
+.B gnunet\-gns
+.RI [ options ] -z ZONEFILE
+.br
+
+.SH DESCRIPTION
+\fBgnunet\-gns\fP can be used to create and manipulate a GNS zone.  
+
+.SH OPTIONS
+.B
+.IP "\-z FILENAME, \-\-zonekey=FILENAME"
+Specifies the filename with the private key for the zone (mandatory option)
+.B
+.IP "\-c FILENAME,  \-\-config=FILENAME"
+Use the configuration file FILENAME.
+.B
+.IP "\-h, \-\-help"
+Print short help on options.
+.B
+.IP "\-L LOGLEVEL, \-\-loglevel=LOGLEVEL"
+Use LOGLEVEL for logging.  Valid values are DEBUG, INFO, WARNING and ERROR.
+.B
+.IP "\-v, \-\-version"
+Print GNUnet version number.
+
+
+.SH BUGS
+Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending 
electronic mail to <address@hidden>
+

Modified: gnunet/src/gns/Makefile.am
===================================================================
--- gnunet/src/gns/Makefile.am  2012-03-04 14:43:14 UTC (rev 20240)
+++ gnunet/src/gns/Makefile.am  2012-03-04 15:02:08 UTC (rev 20241)
@@ -20,7 +20,8 @@
 
 bin_PROGRAMS = \
   gnunet-service-gns \
-  gnunet-gns-fcfsd
+  gnunet-gns-fcfsd \
+  gnunet-gns
 
 #noinst_PROGRAMS = \
 #  gnunet-gns-lookup
@@ -118,10 +119,21 @@
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la \
   $(GN_LIBINTL)
-gnunet_service_gns_DEPENDENCIES = \
+gnunet_gns_fcfsd_DEPENDENCIES = \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la
 
+
+gnunet_gns_SOURCES = \
+ gnunet-gns.c 
+gnunet_gns_LDADD = \
+  $(top_builddir)/src/util/libgnunetutil.la \
+  $(top_builddir)/src/namestore/libgnunetnamestore.la \
+  $(GN_LIBINTL)
+gnunet_gns_DEPENDENCIES = \
+  $(top_builddir)/src/util/libgnunetutil.la \
+  $(top_builddir)/src/namestore/libgnunetnamestore.la
+
 libgnunetgns_la_SOURCES = \
  gns_api.c gns.h
 libgnunetgns_la_LIBADD = \

Added: gnunet/src/gns/gnunet-gns.c
===================================================================
--- gnunet/src/gns/gnunet-gns.c                         (rev 0)
+++ gnunet/src/gns/gnunet-gns.c 2012-03-04 15:02:08 UTC (rev 20241)
@@ -0,0 +1,151 @@
+/*
+     This file is part of GNUnet.
+     (C) 2012 Christian Grothoff (and other contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file gnunet-gns.c
+ * @brief command line tool to manipulate the local zone
+ * @author Christian Grothoff
+ *
+ * TODO:
+ * - everything
+ */
+#include "platform.h"
+#include <gnunet_util_lib.h>
+#include <gnunet_namestore_service.h>
+
+/**
+ * Handle to the namestore.
+ */
+static struct GNUNET_NAMESTORE_Handle *ns;
+
+/**
+ * Hash of the public key of our zone.
+ */
+static GNUNET_HashCode zone;
+
+/**
+ * Private key for the our zone.
+ */
+static struct GNUNET_CRYPTO_RsaPrivateKey *zone_pkey;
+
+/**
+ * Keyfile to manipulate.
+ */
+static char *keyfile;  
+               
+
+/**
+ * Task run on shutdown.  Cleans up everything.
+ *
+ * @param cls unused
+ * @param tc scheduler context
+ */
+static void
+do_shutdown (void *cls,
+            const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  if (NULL != ns)
+  {
+    GNUNET_NAMESTORE_disconnect (ns, GNUNET_NO);
+    ns = NULL;
+  }
+  if (NULL != zone_pkey)
+  {
+    GNUNET_CRYPTO_rsa_key_free (zone_pkey);
+    zone_pkey = NULL;
+  }
+}
+
+
+/**
+ * Main function that will be run.
+ *
+ * @param cls closure
+ * @param args remaining command-line arguments
+ * @param cfgfile name of the configuration file used (for saving, can be 
NULL!)
+ * @param cfg configuration
+ */
+static void
+run (void *cls, char *const *args, const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub;
+
+  if (NULL == keyfile)
+  {
+    fprintf (stderr,
+            _("Option `%s' not given, but I need a zone key file!\n"),
+            "z");
+    return;
+  }
+  zone_pkey = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
+  GNUNET_free (keyfile);
+  keyfile = NULL;
+  if (NULL == zone_pkey)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+               _("Failed to read or create private zone key\n"));
+    return;
+  }
+  GNUNET_CRYPTO_rsa_key_get_public (zone_pkey,
+                                   &pub);
+  GNUNET_CRYPTO_hash (&pub, sizeof (pub), &zone);
+  ns = GNUNET_NAMESTORE_connect (cfg);
+  if (NULL == ns)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                 _("Failed to connect to namestore\n"));
+      return;
+    }
+  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+                               &do_shutdown, NULL);
+}
+
+
+/**
+ * The main function for gnunet-gns.
+ *
+ * @param argc number of arguments from the command line
+ * @param argv command line arguments
+ * @return 0 ok, 1 on error
+ */
+int
+main (int argc, char *const *argv)
+{
+  static const struct GNUNET_GETOPT_CommandLineOption options[] = {
+    {'z', "zonekey", "FILENAME",
+     gettext_noop ("filename with the zone key"), 1,
+     &GNUNET_GETOPT_set_string, &keyfile},   
+    GNUNET_GETOPT_OPTION_END
+  };
+
+  int ret;
+
+  GNUNET_log_setup ("gnunet-gns", "WARNING", NULL);
+  ret =
+      (GNUNET_OK ==
+       GNUNET_PROGRAM_run (argc, argv, "gnunet-gns",
+                           _("GNUnet GNS zone manipulation tool"), 
+                          options,
+                           &run, NULL)) ? 0 : 1;
+
+  return ret;
+}
+
+/* end of gnunet-gns.c */




reply via email to

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