aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbartpolot <bartpolot@140774ce-b5e7-0310-ab8b-a85725594a96>2011-09-19 19:25:44 +0000
committerbartpolot <bartpolot@140774ce-b5e7-0310-ab8b-a85725594a96>2011-09-19 19:25:44 +0000
commit32b429c0db757e3ed0057736f7c7165031019c4c (patch)
tree61fa4c9840d8f980a74e2e20701d6d052c2b2576 /src
parente83ceaf70f317382e62df985db6530fe974b5870 (diff)
Changed own id handling
git-svn-id: https://gnunet.org/svn/gnunet@16958 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src')
-rw-r--r--src/mesh/gnunet-service-mesh.c67
1 files changed, 56 insertions, 11 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 48edad2cf7..966b7c0976 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -553,6 +553,16 @@ static GNUNET_PEER_Id myid;
static struct GNUNET_PeerIdentity my_full_id;
/**
+ * Own private key
+ */
+static struct GNUNET_CRYPTO_RsaPrivateKey* my_private_key;
+
+/**
+ * Own public key.
+ */
+static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded my_public_key;
+
+/**
* Tunnel ID for the next created tunnel (global tunnel number)
*/
static MESH_TunnelNumber next_tid;
@@ -3345,17 +3355,11 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server,
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Core init\n");
core_handle = server;
- my_full_id = *identity;
- myid = GNUNET_PEER_intern (identity);
- peer_info_get(identity);
- announce_id_task = GNUNET_SCHEDULER_add_now (&announce_id, cls);
- GNUNET_SERVER_add_handlers (server_handle, client_handlers);
- nc = GNUNET_SERVER_notification_context_create (server_handle,
- LOCAL_QUEUE_SIZE);
- GNUNET_SERVER_disconnect_notify (server_handle,
- &handle_local_client_disconnect,
- NULL);
-
+ if (0 != memcmp(identity, &my_full_id, sizeof(my_full_id)) || NULL == server)
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("MESH: Wrong CORE service\n"));
+ GNUNET_SCHEDULER_shutdown();
+ }
return;
}
@@ -3479,6 +3483,8 @@ static void
run (void *cls, struct GNUNET_SERVER_Handle *server,
const struct GNUNET_CONFIGURATION_Handle *c)
{
+ char *keyfile;
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: starting to run\n");
server_handle = server;
core_handle = GNUNET_CORE_connect (c, /* Main configuration */
@@ -3496,7 +3502,38 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
if (core_handle == NULL)
{
GNUNET_break (0);
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY",
+ &keyfile))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _
+ ("Mesh service is lacking key configuration settings. Exiting.\n"));
+ GNUNET_SCHEDULER_shutdown ();
+ return;
}
+ my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
+ GNUNET_free (keyfile);
+ if (my_private_key == NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Mesh service could not access hostkey. Exiting.\n"));
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key);
+ GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key),
+ &my_full_id.hashPubKey);
+ myid = GNUNET_PEER_intern (&my_full_id);
+ /* Create a peer_info for the local peer */
+ peer_info_get(&my_full_id);
+
+ announce_id_task = GNUNET_SCHEDULER_add_now (&announce_id, cls);
+
dht_handle = GNUNET_DHT_connect (c, 64);
if (dht_handle == NULL)
{
@@ -3514,6 +3551,14 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
applications = GNUNET_CONTAINER_multihashmap_create (32);
types = GNUNET_CONTAINER_multihashmap_create (32);
+ GNUNET_SERVER_add_handlers (server_handle, client_handlers);
+ nc = GNUNET_SERVER_notification_context_create (server_handle,
+ LOCAL_QUEUE_SIZE);
+ GNUNET_SERVER_disconnect_notify (server_handle,
+ &handle_local_client_disconnect,
+ NULL);
+
+
clients = NULL;
clients_tail = NULL;
#if MESH_DEBUG