aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/man/gnunet-namestore.13
-rw-r--r--src/namestore/gnunet-namestore.c58
2 files changed, 60 insertions, 1 deletions
diff --git a/doc/man/gnunet-namestore.1 b/doc/man/gnunet-namestore.1
index 4ecdbb0a6..f05db0a80 100644
--- a/doc/man/gnunet-namestore.1
+++ b/doc/man/gnunet-namestore.1
@@ -40,6 +40,9 @@ Name of the record to add/delete/display
40.IP "\-t TYPE, \-\-type=TYPE" 40.IP "\-t TYPE, \-\-type=TYPE"
41Type of the record to add/delete/display (i.e. "A", "AAAA", "NS", "PKEY", "MX" etc.) 41Type of the record to add/delete/display (i.e. "A", "AAAA", "NS", "PKEY", "MX" etc.)
42.B 42.B
43.IP "\-u URI, \-\-uri=URI"
44Add PKEY record from gnunet://gns/-URI to our zone; the record type is always PKEY, if no expiration is given FOREVER is used
45.B
43.IP "\-v, \-\-version" 46.IP "\-v, \-\-version"
44Print GNUnet version number. 47Print GNUnet version number.
45.B 48.B
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index a79178aba..f839df3f5 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -104,6 +104,11 @@ static char *name;
104static char *value; 104static char *value;
105 105
106/** 106/**
107 * URI to import.
108 */
109static char *uri;
110
111/**
107 * Type of the record to add/remove, NULL to remove all. 112 * Type of the record to add/remove, NULL to remove all.
108 */ 113 */
109static char *typestring; 114static char *typestring;
@@ -134,6 +139,11 @@ do_shutdown (void *cls,
134 GNUNET_CRYPTO_rsa_key_free (zone_pkey); 139 GNUNET_CRYPTO_rsa_key_free (zone_pkey);
135 zone_pkey = NULL; 140 zone_pkey = NULL;
136 } 141 }
142 if (NULL != uri)
143 {
144 GNUNET_free (uri);
145 uri = NULL;
146 }
137} 147}
138 148
139 149
@@ -287,7 +297,7 @@ run (void *cls, char *const *args, const char *cfgfile,
287 zone_pkey = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); 297 zone_pkey = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
288 GNUNET_free (keyfile); 298 GNUNET_free (keyfile);
289 keyfile = NULL; 299 keyfile = NULL;
290 if (! (add|del|list)) 300 if (! (add|del|list|(NULL != uri)))
291 { 301 {
292 /* nothing more to be done */ 302 /* nothing more to be done */
293 fprintf (stderr, 303 fprintf (stderr,
@@ -469,6 +479,49 @@ run (void *cls, char *const *args, const char *cfgfile,
469 &display_record, 479 &display_record,
470 NULL); 480 NULL);
471 } 481 }
482 if (NULL != uri)
483 {
484 char sh[53];
485 char name[64];
486 struct GNUNET_CRYPTO_ShortHashCode sc;
487
488 if ( (2 != (sscanf (uri,
489 "gnunet://gns/%52s/%63s",
490 sh,
491 name)) ) ||
492 (GNUNET_OK !=
493 GNUNET_CRYPTO_short_hash_from_string (sh, &sc)) )
494 {
495 fprintf (stderr,
496 _("Invalid URI `%s'"),
497 uri);
498 GNUNET_SCHEDULER_shutdown ();
499 return;
500 }
501
502
503 rd.data = ≻
504 rd.data_size = sizeof (struct GNUNET_CRYPTO_ShortHashCode);
505 rd.record_type = GNUNET_NAMESTORE_TYPE_PKEY;
506 if (GNUNET_YES == etime_is_rel)
507 {
508 rd.expiration_time = etime_rel.rel_value;
509 rd.flags |= GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION;
510 }
511 else if (GNUNET_NO == etime_is_rel)
512 rd.expiration_time = etime_abs.abs_value;
513 else
514 rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value;
515 if (1 != nonauthority)
516 rd.flags |= GNUNET_NAMESTORE_RF_AUTHORITY;
517
518 add_qe = GNUNET_NAMESTORE_record_create (ns,
519 zone_pkey,
520 name,
521 &rd,
522 &add_continuation,
523 NULL);
524 }
472 GNUNET_free_non_null (data); 525 GNUNET_free_non_null (data);
473} 526}
474 527
@@ -505,6 +558,9 @@ main (int argc, char *const *argv)
505 {'t', "type", "TYPE", 558 {'t', "type", "TYPE",
506 gettext_noop ("type of the record to add/delete/display"), 1, 559 gettext_noop ("type of the record to add/delete/display"), 1,
507 &GNUNET_GETOPT_set_string, &typestring}, 560 &GNUNET_GETOPT_set_string, &typestring},
561 {'u', "uri", "URI",
562 gettext_noop ("URI to import into our zone"), 1,
563 &GNUNET_GETOPT_set_string, &uri},
508 {'V', "value", "VALUE", 564 {'V', "value", "VALUE",
509 gettext_noop ("value of the record to add/delete"), 1, 565 gettext_noop ("value of the record to add/delete"), 1,
510 &GNUNET_GETOPT_set_string, &value}, 566 &GNUNET_GETOPT_set_string, &value},