gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r22319 - in gnunet: doc/man src/namestore
Date: Tue, 26 Jun 2012 22:44:32 +0200

Author: grothoff
Date: 2012-06-26 22:44:32 +0200 (Tue, 26 Jun 2012)
New Revision: 22319

Modified:
   gnunet/doc/man/gnunet-namestore.1
   gnunet/src/namestore/gnunet-namestore.c
Log:
-adding support for importing PKEY records from URIs

Modified: gnunet/doc/man/gnunet-namestore.1
===================================================================
--- gnunet/doc/man/gnunet-namestore.1   2012-06-26 20:00:50 UTC (rev 22318)
+++ gnunet/doc/man/gnunet-namestore.1   2012-06-26 20:44:32 UTC (rev 22319)
@@ -40,6 +40,9 @@
 .IP "\-t TYPE, \-\-type=TYPE"
 Type of the record to add/delete/display (i.e. "A", "AAAA", "NS", "PKEY", "MX" 
etc.)
 .B
+.IP "\-u URI, \-\-uri=URI"
+Add PKEY record from gnunet://gns/-URI to our zone; the record type is always 
PKEY, if no expiration is given FOREVER is used
+.B
 .IP "\-v, \-\-version"
 Print GNUnet version number.
 .B

Modified: gnunet/src/namestore/gnunet-namestore.c
===================================================================
--- gnunet/src/namestore/gnunet-namestore.c     2012-06-26 20:00:50 UTC (rev 
22318)
+++ gnunet/src/namestore/gnunet-namestore.c     2012-06-26 20:44:32 UTC (rev 
22319)
@@ -104,6 +104,11 @@
 static char *value;
 
 /**
+ * URI to import.
+ */
+static char *uri;
+
+/**
  * Type of the record to add/remove, NULL to remove all.
  */
 static char *typestring;
@@ -134,6 +139,11 @@
     GNUNET_CRYPTO_rsa_key_free (zone_pkey);
     zone_pkey = NULL;
   }
+  if (NULL != uri)
+  {
+    GNUNET_free (uri);
+    uri = NULL;
+  }
 }
 
 
@@ -287,7 +297,7 @@
   zone_pkey = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
   GNUNET_free (keyfile);
   keyfile = NULL;
-  if (! (add|del|list))
+  if (! (add|del|list|(NULL != uri)))
   {
     /* nothing more to be done */  
     fprintf (stderr,
@@ -469,6 +479,49 @@
                                                     &display_record,
                                                     NULL);
   }
+  if (NULL != uri)
+  {
+    char sh[53];
+    char name[64];
+    struct GNUNET_CRYPTO_ShortHashCode sc;
+
+    if ( (2 != (sscanf (uri,
+                       "gnunet://gns/%52s/%63s",
+                       sh,
+                       name)) ) ||
+        (GNUNET_OK !=
+         GNUNET_CRYPTO_short_hash_from_string (sh, &sc)) )
+    {
+      fprintf (stderr, 
+              _("Invalid URI `%s'"),
+              uri);
+      GNUNET_SCHEDULER_shutdown ();
+      return;
+    }
+
+
+    rd.data = ≻
+    rd.data_size = sizeof (struct GNUNET_CRYPTO_ShortHashCode);
+    rd.record_type = GNUNET_NAMESTORE_TYPE_PKEY;
+    if (GNUNET_YES == etime_is_rel)
+    {
+      rd.expiration_time = etime_rel.rel_value;
+      rd.flags |= GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION;
+    }
+    else if (GNUNET_NO == etime_is_rel)
+      rd.expiration_time = etime_abs.abs_value;
+    else    
+      rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value;
+    if (1 != nonauthority)
+      rd.flags |= GNUNET_NAMESTORE_RF_AUTHORITY;
+
+    add_qe = GNUNET_NAMESTORE_record_create (ns,
+                                            zone_pkey,
+                                            name,
+                                            &rd,
+                                            &add_continuation,
+                                            NULL);
+  }
   GNUNET_free_non_null (data);
 }
 
@@ -505,6 +558,9 @@
     {'t', "type", "TYPE",
      gettext_noop ("type of the record to add/delete/display"), 1,
      &GNUNET_GETOPT_set_string, &typestring},   
+    {'u', "uri", "URI",
+     gettext_noop ("URI to import into our zone"), 1,
+     &GNUNET_GETOPT_set_string, &uri},   
     {'V', "value", "VALUE",
      gettext_noop ("value of the record to add/delete"), 1,
      &GNUNET_GETOPT_set_string, &value},   




reply via email to

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