summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/man/gnunet-identity.18
-rw-r--r--doc/man/gnunet-namestore-fcfsd.111
-rw-r--r--src/identity/gnunet-identity.c111
-rw-r--r--src/include/gnunet_crypto_lib.h10
-rw-r--r--src/namestore/Makefile.am21
-rw-r--r--src/namestore/gnunet-namestore-fcfsd.c143
-rw-r--r--src/peerinfo/gnunet-service-peerinfo.c2
7 files changed, 224 insertions, 82 deletions
diff --git a/doc/man/gnunet-identity.1 b/doc/man/gnunet-identity.1
index be6714cda..3103791c8 100644
--- a/doc/man/gnunet-identity.1
+++ b/doc/man/gnunet-identity.1
@@ -21,6 +21,10 @@ Creates a new ego with the given NAME.
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,6 +36,10 @@ display all ouf our egos
\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
diff --git a/doc/man/gnunet-namestore-fcfsd.1 b/doc/man/gnunet-namestore-fcfsd.1
index 42b658018..e8032246b 100644
--- a/doc/man/gnunet-namestore-fcfsd.1
+++ b/doc/man/gnunet-namestore-fcfsd.1
@@ -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,9 +11,11 @@ gnunet\-namestore-fcfsd \- HTTP server for GNS domain registration
.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
@@ -34,5 +36,4 @@ Print GNUnet version number.
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <bug\-gnunet@gnu.org>
.SH SEE ALSO
-gnunet\-gns(1), gnunet\-gns\-proxy(1)
-
+gnunet\-identity(1), gnunet\-gns(1), gnunet\-gns\-proxy(1)
diff --git a/src/identity/gnunet-identity.c b/src/identity/gnunet-identity.c
index e56a05807..c1803ea1d 100644
--- a/src/identity/gnunet-identity.c
+++ b/src/identity/gnunet-identity.c
@@ -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 *create_ego;
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 @@ static void
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 @@ test_finished ()
{
if ( (NULL == create_op) &&
(NULL == delete_op) &&
+ (NULL == set_op) &&
+ (NULL == set_ego) &&
(! list) &&
(! monitor) )
GNUNET_SCHEDULER_shutdown ();
@@ -139,6 +169,25 @@ create_finished (void *cls,
/**
+ * 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 @@ print_ego (void *cls,
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 @@ static void
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 @@ main (int argc, char *const *argv)
{'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
};
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 502209b0f..033803978 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -427,11 +427,11 @@ GNUNET_CRYPTO_hash_from_string2 (const char *enc, size_t enclen,
/**
* @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
diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am
index 7784f2b5b..3c719a451 100644
--- a/src/namestore/Makefile.am
+++ b/src/namestore/Makefile.am
@@ -43,16 +43,16 @@ if HAVE_TESTING
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_SOURCES = \
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 = \
diff --git a/src/namestore/gnunet-namestore-fcfsd.c b/src/namestore/gnunet-namestore-fcfsd.c
index 90ec84bde..f655ef45c 100644
--- a/src/namestore/gnunet-namestore-fcfsd.c
+++ b/src/namestore/gnunet-namestore-fcfsd.c
@@ -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 @@ static struct GNUNET_NAMESTORE_Handle *ns;
/**
* 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 @@ serve_zoneinfo_page (struct MHD_Connection *connection)
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 @@ zone_to_name_cb (void *cls,
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 @@ lookup_result_processor (void *cls,
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_block_processor (void *cls,
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 @@ create_response (void *cls,
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 @@ do_shutdown (void *cls,
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 @@ static void
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 @@ run (void *cls, char *const *args, const char *cfgfile,
"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 @@ run (void *cls, char *const *args, const char *cfgfile,
_("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 @@ main (int argc, char *const *argv)
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 */
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c
index 42e8dad1e..b1197dc7e 100644
--- a/src/peerinfo/gnunet-service-peerinfo.c
+++ b/src/peerinfo/gnunet-service-peerinfo.c
@@ -516,7 +516,7 @@ struct DirScanContext
* @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)