[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r22773 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r22773 - gnunet/src/transport |
Date: |
Thu, 19 Jul 2012 14:22:55 +0200 |
Author: wachs
Date: 2012-07-19 14:22:55 +0200 (Thu, 19 Jul 2012)
New Revision: 22773
Modified:
gnunet/src/transport/gnunet-service-transport.c
Log:
- issues with multiple services accessing one hostkey
Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c 2012-07-19 08:54:25 UTC
(rev 22772)
+++ gnunet/src/transport/gnunet-service-transport.c 2012-07-19 12:22:55 UTC
(rev 22773)
@@ -61,20 +61,7 @@
*/
struct GNUNET_PEERINFO_Handle *GST_peerinfo;
-
/**
- * Hostkey generation context
- */
-struct GNUNET_CRYPTO_RsaKeyGenerationContext *GST_keygen;
-
-/**
- * Closure for hostkey generation
- */
-
-struct KeyGenerationContext *GST_keygen_cls;
-
-
-/**
* Our public key.
*/
struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded GST_my_public_key;
@@ -95,13 +82,6 @@
static int connections;
-struct KeyGenerationContext
-{
- struct GNUNET_SERVER_Handle *server;
- const struct GNUNET_CONFIGURATION_Handle *c;
-};
-
-
/**
* Transmit our HELLO message to the given (connected) neighbour.
*
@@ -291,7 +271,7 @@
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK:
GST_neighbours_handle_session_ack (message, peer, &address, session, ats,
- ats_count);
+ ats_count);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT:
GST_neighbours_handle_disconnect_message (peer, message);
@@ -558,18 +538,6 @@
static void
shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- if (NULL != GST_keygen)
- {
- GNUNET_CRYPTO_rsa_key_create_stop (GST_keygen);
- GST_keygen = NULL;
- }
-
- if (NULL != GST_keygen_cls)
- {
- GNUNET_free (GST_keygen_cls);
- GST_keygen_cls = NULL;
- }
-
GST_neighbours_stop ();
GST_validation_stop ();
GST_plugins_unload ();
@@ -597,34 +565,43 @@
}
}
+
/**
- * Callback for hostkey read/generation
- * @param cls NULL
- * @param pk the privatekey
- * @param emsg error message
+ * Initiate transport service.
+ *
+ * @param cls closure
+ * @param server the initialized server
+ * @param c configuration to use
*/
static void
-key_generation_cb (void *cls,
- struct GNUNET_CRYPTO_RsaPrivateKey *pk,
- const char *emsg)
+run (void *cls, struct GNUNET_SERVER_Handle *server,
+ const struct GNUNET_CONFIGURATION_Handle *c)
{
+ char *keyfile;
struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded tmp;
- GNUNET_assert (NULL != GST_keygen_cls);
- GST_keygen = NULL;
- if (NULL == pk)
+ /* setup globals */
+ GST_cfg = c;
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY",
+ &keyfile))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Transport service could not access hostkey: %s.
Exiting.\n"),
- emsg);
- GNUNET_free (GST_keygen_cls);
- GST_keygen_cls = NULL;
+ _
+ ("Transport service is lacking key configuration settings.
Exiting.\n"));
GNUNET_SCHEDULER_shutdown ();
return;
}
- GST_my_private_key = pk;
-
- GST_stats = GNUNET_STATISTICS_create ("transport", GST_keygen_cls->c);
- GST_peerinfo = GNUNET_PEERINFO_connect (GST_keygen_cls->c);
+ GST_my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
+ GNUNET_free (keyfile);
+ if (GST_my_private_key == NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Transport service could not access hostkey. Exiting.\n"));
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ GST_stats = GNUNET_STATISTICS_create ("transport", c);
+ GST_peerinfo = GNUNET_PEERINFO_connect (c);
memset (&GST_my_public_key, '\0', sizeof (GST_my_public_key));
memset (&tmp, '\0', sizeof (tmp));
GNUNET_CRYPTO_rsa_key_get_public (GST_my_private_key, &GST_my_public_key);
@@ -647,7 +624,7 @@
/* start subsystems */
GST_hello_start (&process_hello_update, NULL);
GNUNET_assert (NULL != GST_hello_get());
- GST_blacklist_start (GST_keygen_cls->server);
+ GST_blacklist_start (server);
GST_ats =
GNUNET_ATS_scheduling_init (GST_cfg, &ats_request_address_change, NULL);
GST_plugins_load (&plugin_env_receive_callback,
@@ -658,54 +635,12 @@
&neighbours_connect_notification,
&neighbours_disconnect_notification,
&neighbours_address_notification);
- GST_clients_start (GST_keygen_cls->server);
+ GST_clients_start (server);
GST_validation_start ();
- GNUNET_free (GST_keygen_cls);
- GST_keygen_cls = NULL;
}
/**
- * Initiate transport service.
- *
- * @param cls closure
- * @param server the initialized server
- * @param c configuration to use
- */
-static void
-run (void *cls, struct GNUNET_SERVER_Handle *server,
- const struct GNUNET_CONFIGURATION_Handle *c)
-{
- char *keyfile;
-
- /* setup globals */
- GST_cfg = c;
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY",
- &keyfile))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _
- ("Transport service is lacking key configuration settings.
Exiting.\n"));
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- GST_keygen_cls = GNUNET_malloc (sizeof (struct KeyGenerationContext));
- GST_keygen_cls->c = c;
- GST_keygen_cls->server = server;
-
- GST_keygen = GNUNET_CRYPTO_rsa_key_create_start (keyfile, key_generation_cb,
GST_keygen_cls);
- GNUNET_free (keyfile);
- if (NULL == GST_keygen)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Transport service is unable to access hostkey.
Exiting.\n"));
- GNUNET_SCHEDULER_shutdown ();
- }
-}
-
-
-/**
* The main function for the transport service.
*
* @param argc number of arguments from the command line
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r22773 - gnunet/src/transport,
gnunet <=