#include "microhttpd.h"
#include <curl/curl.h>
-#define DEBUG_HTTP GNUNET_YES
+#define DEBUG_HTTP GNUNET_NO
#define DEBUG_CURL GNUNET_NO
#define DEBUG_CONNECTIONS GNUNET_NO
#define DEBUG_SESSION_SELECTION GNUNET_NO
struct sockaddr_in6 * bind6_address;
char * bind_hostname;
int use_ipv6;
+ int use_ipv4;
};
GNUNET_assert(cls !=NULL);
af = addr->sa_family;
- if ((af == AF_INET) && (plugin->bind6_address == NULL))
+ if ((af == AF_INET) && (plugin->use_ipv4 == GNUNET_YES) && (plugin->bind6_address == NULL))
{
struct in_addr bnd_cmp = ((struct sockaddr_in *) addr)->sin_addr;
-
t4 = GNUNET_malloc(sizeof(struct IPv4HttpAddress));
/* Not skipping loopback addresses
if (INADDR_LOOPBACK == ntohl(((struct sockaddr_in *) addr)->sin_addr.s_addr))
}
GNUNET_free (t4);
}
- else if ((af == AF_INET6) && (plugin->use_ipv6==GNUNET_YES) && (plugin->bind4_address == NULL))
+ else if ((af == AF_INET6) && (plugin->use_ipv6 == GNUNET_YES) && (plugin->bind4_address == NULL))
{
struct in6_addr bnd_cmp6 = ((struct sockaddr_in6 *) addr)->sin6_addr;
t6 = GNUNET_malloc(sizeof(struct IPv6HttpAddress));
}
GNUNET_free (t6);
}
- //return GNUNET_NO;
return GNUNET_OK;
}
plugin->peers = NULL;
plugin->bind4_address = NULL;
plugin->use_ipv6 = GNUNET_YES;
+ plugin->use_ipv4 = GNUNET_YES;
api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
api->cls = plugin;
plugin->use_ipv6 = GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
"transport-http",
"USE_IPv6");
-
-
-
+ }
+ /* Reading port number from config file */
+ if (GNUNET_CONFIGURATION_have_value (env->cfg,
+ "transport-http", "USE_IPv4"))
+ {
+ plugin->use_ipv4 = GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
+ "transport-http",
+ "USE_IPv4");
}
/* Reading port number from config file */
if ((GNUNET_OK !=
}
/* Reading ipv4 addresse to bind to from config file */
- if (GNUNET_CONFIGURATION_have_value (env->cfg,
- "transport-http", "BINDTO4"))
+ if ((plugin->use_ipv4==GNUNET_YES) && (GNUNET_CONFIGURATION_have_value (env->cfg,
+ "transport-http", "BINDTO4")))
{
GNUNET_break (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string (env->cfg,
plugin->bind4_address->sin_family = AF_INET;
plugin->bind4_address->sin_port = htons (port);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"v4 Hostname `%s'!\n",plugin->bind_hostname);
-
if (inet_pton(AF_INET,plugin->bind_hostname, &plugin->bind4_address->sin_addr)<=0)
{
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
}
/* Reading ipv4 addresse to bind to from config file */
- if (GNUNET_CONFIGURATION_have_value (env->cfg,
- "transport-http", "BINDTO6"))
+ if ((plugin->use_ipv6==GNUNET_YES) && (GNUNET_CONFIGURATION_have_value (env->cfg,
+ "transport-http", "BINDTO6")))
{
GNUNET_break (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string (env->cfg,
plugin->bind6_address->sin6_family = AF_INET6;
plugin->bind6_address->sin6_port = htons (port);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"v6 Hostname `%s'!\n",plugin->bind_hostname);
-
if (inet_pton(AF_INET6,plugin->bind_hostname, &plugin->bind6_address->sin6_addr)<=0)
{
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
GNUNET_free(plugin->bind_hostname);
plugin->bind_hostname = NULL;
plugin->bind6_address = NULL;
-
}
-
- char * tmp = GNUNET_malloc(50);
- inet_ntop(AF_INET6,&plugin->bind6_address->sin6_addr,tmp,50);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"v6 Hostname reverse `%s'!\n",tmp);
- GNUNET_free(tmp);
}
GNUNET_assert ((port > 0) && (port <= 65535));
MHD_OPTION_NOTIFY_COMPLETED, &mhd_termination_cb, NULL,
MHD_OPTION_END);
}
- if ((plugin->http_server_daemon_v4 == NULL) && (port != 0))
+ if ((plugin->http_server_daemon_v4 == NULL) && (plugin->use_ipv4 == GNUNET_YES) && (port != 0))
{
plugin->http_server_daemon_v4 = MHD_start_daemon (
#if DEBUG_CONNECTIONS