"Freeing context for peer `%s'\n",
GNUNET_i2s(&pc->identity));
#endif
- GNUNET_CONTAINER_multihashmap_remove (plugin->peers, &pc->identity.hashPubKey, pc);
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_remove (plugin->peers,
+ &pc->identity.hashPubKey,
+ pc));
while (ps!=NULL)
{
plugin->env->session_end(plugin, &pc->identity, ps);
const struct GNUNET_MessageHeader *message)
{
struct Session *ps = cls;
- struct HTTP_PeerContext *pc = ps->peercontext;
+ struct HTTP_PeerContext *pc;
struct GNUNET_TIME_Relative delay;
GNUNET_assert(ps != NULL);
+ pc = ps->peercontext;
GNUNET_assert(pc != NULL);
#if DEBUG_HTTP
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
ps->send_force_disconnect = GNUNET_NO;
ps->pending_msgs_head = NULL;
ps->pending_msgs_tail = NULL;
- ps->peercontext=pc;
+ ps->peercontext = pc;
ps->session_id = pc->session_id_counter;
ps->queue_length_cur = 0;
ps->queue_length_max = GNUNET_SERVER_MAX_MESSAGE_SIZE;
}
}
-#if 0
-/**
- * Notify transport service about address
- *
- * @param cls the plugin
- * @param tc unused
- */
-static void
-address_notification (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- struct Plugin *plugin = cls;
-
- GNUNET_OS_network_interfaces_list (&process_interfaces, plugin);
-}
-#endif
-
/**
* Exit point from the plugin.
*/
GNUNET_free_non_null (plugin->bind4_address);
GNUNET_free_non_null (plugin->bind6_address);
- GNUNET_free_non_null(plugin->bind_hostname);
+ GNUNET_free_non_null (plugin->bind_hostname);
#if BUILD_HTTPS
GNUNET_free_non_null (plugin->crypto_init);
GNUNET_free_non_null (plugin->cert);
struct stat fstat;
char * text = NULL;
- if (0!=STAT(file, &fstat))
- return NULL;
+ if (0 != STAT(file, &fstat))
+ return NULL;
text = GNUNET_malloc (fstat.st_size+1);
gn_file = GNUNET_DISK_file_open(file, GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_USER_READ);
if (gn_file==NULL)
GNUNET_free(text);
return NULL;
}
- if (GNUNET_SYSERR == GNUNET_DISK_file_read(gn_file, text, fstat.st_size))
+ if (GNUNET_SYSERR == GNUNET_DISK_file_read (gn_file, text, fstat.st_size))
{
- GNUNET_free(text);
- GNUNET_DISK_file_close(gn_file);
+ GNUNET_free (text);
+ GNUNET_DISK_file_close (gn_file);
return NULL;
}
text[fstat.st_size] = '\0';
- GNUNET_DISK_file_close(gn_file);
+ GNUNET_DISK_file_close (gn_file);
return text;
}
#endif
&plugin->my_ascii_hash_ident);
- if (GNUNET_CONFIGURATION_have_value (env->cfg, "TRANSPORT", "NEIGHBOUR_LIMIT"))
- {
- GNUNET_CONFIGURATION_get_value_number (env->cfg,
- "TRANSPORT",
- "NEIGHBOUR_LIMIT",
- &tneigh);
- }
- else
- {
- tneigh = -1;
- }
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (env->cfg,
+ component_name,
+ "MAX_CONNECTIONS",
+ &tneigh))
+ tneigh = 128;
plugin->max_connect_per_transport = tneigh;
#if BUILD_HTTPS
/* Reading HTTPS crypto related configuration */
- /* Get crypto init string from config */
- if (GNUNET_CONFIGURATION_have_value (env->cfg,
- "transport-https", "CRYPTO_INIT"))
- {
- GNUNET_CONFIGURATION_get_value_string (env->cfg,
- "transport-https",
- "CRYPTO_INIT",
- &plugin->crypto_init);
- }
- else
- {
- GNUNET_asprintf(&plugin->crypto_init,"NORMAL");
- }
-
- /* Get private key file from config */
- if (GNUNET_CONFIGURATION_have_value (env->cfg,
- "transport-https", "KEY_FILE"))
+ /* Get crypto init string from config */
+ if ( (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (env->cfg,
+ "transport-https",
+ "CRYPTO_INIT",
+ &plugin->crypto_init)) ||
+ (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_filename (env->cfg,
+ "transport-https",
+ "KEY_FILE",
+ &key_file)) ||
+ (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_filename (env->cfg,
+ "transport-https",
+ "CERT_FILE",
+ &cert_file)) )
{
- GNUNET_CONFIGURATION_get_value_filename (env->cfg,
- "transport-https",
- "KEY_FILE",
- &key_file);
- }
- if (key_file==NULL)
- GNUNET_asprintf(&key_file,"https.key");
-
- /* Get private key file from config */
- if (GNUNET_CONFIGURATION_have_value (env->cfg,"transport-https", "CERT_FILE"))
- {
- GNUNET_CONFIGURATION_get_value_filename (env->cfg,
- "transport-https",
- "CERT_FILE",
- &cert_file);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
+ "https",
+ _("Required configuration options missing in section `%s'\n"),
+ "transport-https");
+ GNUNET_free (component_name);
+ GNUNET_free_non_null (key_file);
+ GNUNET_free_non_null (cert_file);
+ LIBGNUNET_PLUGIN_TRANSPORT_DONE (api);
+ return NULL;
}
- if (cert_file==NULL)
- GNUNET_asprintf(&cert_file,"https.cert");
-
+
/* read key & certificates from file */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Loading TLS certificate `%s' `%s'\n",
key_file, cert_file);
- plugin->key = load_certificate( key_file );
- plugin->cert = load_certificate( cert_file );
+ plugin->key = load_certificate (key_file);
+ plugin->cert = load_certificate (cert_file);
- if ((plugin->key==NULL) || (plugin->cert==NULL))
+ if ( (plugin->key==NULL) || (plugin->cert==NULL) )
{
- char * cmd;
- int ret = 0;
- GNUNET_asprintf(&cmd,
- "gnunet-transport-certificate-creation %s %s",
- key_file, cert_file);
+ struct GNUNET_OS_Process *certcreation;
+
+ GNUNET_free_non_null (plugin->key);
+ plugin->key = NULL;
+ GNUNET_free_non_null (plugin->cert);
+ plugin->cert = NULL;
+#if DEBUG_HTTP
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "No usable TLS certificate found, creating certificate \n");
- ret = system(cmd);
- if (ret != 0)
- {
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
- "https",
- _("Could not create a new TLS certificate, shell script `%s' failed!\n"),cmd,
- "transport-https");
- GNUNET_free (key_file);
- GNUNET_free (cert_file);
- GNUNET_free (component_name);
- LIBGNUNET_PLUGIN_TRANSPORT_DONE(api);
- GNUNET_free (cmd);
- return NULL;
- }
- GNUNET_free (cmd);
- plugin->key = load_certificate( key_file );
- plugin->cert = load_certificate( cert_file );
- if ((plugin->key==NULL) || (plugin->cert==NULL))
+ "No usable TLS certificate found, creating certificate\n");
+#endif
+ errno = 0;
+ certcreation = GNUNET_OS_start_process (NULL, NULL,
+ "gnunet-transport-certificate-creation",
+ "gnunet-transport-certificate-creation",
+ key_file, cert_file,
+ NULL);
+ if (certcreation == NULL)
{
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
"https",
- _("No usable TLS certificate found and creating one failed! \n"),
- "transport-https");
+ _("Could not create a new TLS certificate, program `gnunet-transport-certificate-creation' could not be started!\n"));
GNUNET_free (key_file);
GNUNET_free (cert_file);
GNUNET_free (component_name);
-
- LIBGNUNET_PLUGIN_TRANSPORT_DONE(api);
+ LIBGNUNET_PLUGIN_TRANSPORT_DONE (api);
return NULL;
}
+ GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (certcreation));
+ GNUNET_OS_process_close (certcreation);
+ plugin->key = load_certificate (key_file);
+ plugin->cert = load_certificate (cert_file);
}
+ if ( (plugin->key==NULL) || (plugin->cert==NULL) )
+ {
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
+ "https",
+ _("No usable TLS certificate found and creating one failed!\n"),
+ "transport-https");
+ GNUNET_free (key_file);
+ GNUNET_free (cert_file);
+ GNUNET_free (component_name);
+ LIBGNUNET_PLUGIN_TRANSPORT_DONE (api);
+ return NULL;
+ }
GNUNET_free (key_file);
GNUNET_free (cert_file);
-
- GNUNET_assert((plugin->key!=NULL) && (plugin->cert!=NULL));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TLS certificate loaded\n");
+#if DEBUG_HTTP
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "TLS certificate loaded\n");
+#endif
#endif
GNUNET_assert ((port > 0) && (port <= 65535));