- MHD_OPTION_CONNECTION_TIMEOUT,
- timeout,
- MHD_OPTION_CONNECTION_MEMORY_LIMIT,
- (size_t) (2 *
- GNUNET_SERVER_MAX_MESSAGE_SIZE),
- MHD_OPTION_NOTIFY_COMPLETED,
- &server_disconnect_cb, plugin,
- MHD_OPTION_EXTERNAL_LOGGER,
- &server_log, NULL, MHD_OPTION_END);
- if (plugin->server_v4 == NULL)
+ MHD_OPTION_CONNECTION_TIMEOUT,
+ timeout,
+ MHD_OPTION_CONNECTION_MEMORY_LIMIT,
+ (size_t) (2 *
+ GNUNET_MAX_MESSAGE_SIZE),
+ MHD_OPTION_NOTIFY_COMPLETED,
+ &server_disconnect_cb, plugin,
+ MHD_OPTION_NOTIFY_CONNECTION,
+ &server_connection_cb, plugin,
+ MHD_OPTION_EXTERNAL_LOGGER,
+ &server_log, NULL,
+ MHD_OPTION_END);
+#ifdef TCP_STEALTH
+ if ( (NULL != server) &&
+ (0 != (plugin->options & HTTP_OPTIONS_TCP_STEALTH)) )
+ {
+ const union MHD_DaemonInfo *di;
+
+ di = MHD_get_daemon_info (server,
+ MHD_DAEMON_INFO_LISTEN_FD,
+ NULL);
+ if ( (0 != setsockopt ((int) di->listen_fd,
+ IPPROTO_TCP,
+ TCP_STEALTH,
+ plugin->env->my_identity,
+ sizeof (struct GNUNET_PeerIdentity))) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("TCP_STEALTH not supported on this platform.\n"));
+ MHD_stop_daemon (server);
+ server = NULL;
+ }
+ }
+#endif
+ return server;
+}
+
+
+/**
+ * Start the HTTP server
+ *
+ * @param plugin the plugin handle
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
+ */
+static int
+server_start (struct HTTP_Server_Plugin *plugin)
+{
+ const char *msg;
+
+ GNUNET_assert (NULL != plugin);
+#if BUILD_HTTPS
+ if (GNUNET_SYSERR == server_load_certificate (plugin))
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ _("Could not load or create server certificate! Loading plugin failed!\n"));
+ return GNUNET_SYSERR;
+ }
+#endif
+
+
+
+ plugin->server_v4 = NULL;
+ if (GNUNET_YES == plugin->use_ipv4)
+ {
+ plugin->server_v4
+ = run_mhd_start_daemon (plugin,
+ (const struct sockaddr_in *) plugin->server_addr_v4,
+ MHD_NO_FLAG);
+
+ if (NULL == plugin->server_v4)