From 21ac0fa547fee3def262d94ba4dd62e5960e3d9f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 4 Mar 2012 16:19:07 +0000 Subject: -adding options to gnunet-gns --- doc/man/gnunet-gns.1 | 25 ++++++++++++++++++++-- src/gns/gnunet-gns.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 80 insertions(+), 4 deletions(-) diff --git a/doc/man/gnunet-gns.1 b/doc/man/gnunet-gns.1 index 12fd5e316..8fd4b33e4 100644 --- a/doc/man/gnunet-gns.1 +++ b/doc/man/gnunet-gns.1 @@ -13,20 +13,41 @@ gnunet\-gns \- manipulate GNUnet GNS zones .SH OPTIONS .B -.IP "\-z FILENAME, \-\-zonekey=FILENAME" -Specifies the filename with the private key for the zone (mandatory option) +.IP "\-a, \-\-add" +Desired operation is adding a record .B .IP "\-c FILENAME, \-\-config=FILENAME" Use the configuration file FILENAME. .B +.IP "\-d, \-\-delete" +Desired operation is deleting a record +.B +.IP "\-D, \-\-display" +Desired operation is listing of matching records +.B +.IP "\-e TIME, \-\-expiration=TIME" +Specifies expiration time of record to add; format is relative time, i.e "1 h" or "7 d 30 m". Supported units are "ms", "s", "min" or "minutes", "h" (hours), "d" (days) and "a" (years). +.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 "\-n NAME, \-\-name=NAME" +Name of the record to add/delete/display +.B +.IP "\-t TYPE, \-\-type=TYPE" +Type of the record to add/delete/display (i.e. "A", "AAAA", "NS", "PKEY", "MX" etc.) +.B .IP "\-v, \-\-version" Print GNUnet version number. +.B +.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) .SH BUGS diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c index a56b229b5..b56423c04 100644 --- a/src/gns/gnunet-gns.c +++ b/src/gns/gnunet-gns.c @@ -48,6 +48,41 @@ static struct GNUNET_CRYPTO_RsaPrivateKey *zone_pkey; * Keyfile to manipulate. */ static char *keyfile; + +/** + * Desired action is to add a record. + */ +static int add; + +/** + * Desired action is to list records. + */ +static int list; + +/** + * Desired action is to remove a record. + */ +static int del; + +/** + * Name of the records to add/list/remove. + */ +static char *name; + +/** + * Value of the record to add/remove. + */ +static char *value; + +/** + * Type of the record to add/remove, NULL to remove all. + */ +static char *typestring; + +/** + * Desired expiration time. + */ +static char *expirationstring; /** @@ -113,8 +148,7 @@ run (void *cls, char *const *args, const char *cfgfile, _("Failed to connect to namestore\n")); return; } - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &do_shutdown, NULL); + GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); } @@ -129,6 +163,27 @@ int main (int argc, char *const *argv) { static const struct GNUNET_GETOPT_CommandLineOption options[] = { + {'a', "add", NULL, + gettext_noop ("add record"), 0, + &GNUNET_GETOPT_set_one, &add}, + {'d', "delete", NULL, + gettext_noop ("delete record"), 0, + &GNUNET_GETOPT_set_one, &del}, + {'D', "display", NULL, + gettext_noop ("display records"), 0, + &GNUNET_GETOPT_set_one, &list}, + {'e', "expiration", "TIME", + gettext_noop ("expiration time to use (for adding only)"), 1, + &GNUNET_GETOPT_set_string, &expirationstring}, + {'n', "name", "NAME", + gettext_noop ("name of the record to add/delete/display"), 1, + &GNUNET_GETOPT_set_string, &name}, + {'t', "type", "TYPE", + gettext_noop ("type of the record to add/delete/display"), 1, + &GNUNET_GETOPT_set_string, &typestring}, + {'V', "value", "VALUE", + gettext_noop ("value of the record to add/delete"), 1, + &GNUNET_GETOPT_set_string, &value}, {'z', "zonekey", "FILENAME", gettext_noop ("filename with the zone key"), 1, &GNUNET_GETOPT_set_string, &keyfile}, -- cgit v1.2.3