From 3519fc71001af482dcfeb34209d6c42cd126dbec Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Fri, 16 Jul 2010 15:31:37 +0000 Subject: [PATCH] --- src/transport/Makefile.am | 5 +++ src/transport/plugin_transport_http.c | 41 ++++++++----------- .../test_plugin_transport_data_http.conf | 3 +- .../test_transport_api_http_peer1.conf | 8 ++-- .../test_transport_api_http_peer2.conf | 8 ++-- .../test_transport_api_rel_http_peer1.conf | 5 +-- .../test_transport_api_rel_http_peer2.conf | 6 +-- .../test_transport_api_reliability.c | 4 +- 8 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 2fe57c9db..4560782d2 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am @@ -146,6 +146,7 @@ TESTS = \ test_transport_api_udp_nat \ test_plugin_transport_http \ test_transport_api_http \ + test_transport_api_reliability_http \ test_transport_api_reliability_tcp \ test_transport_api_reliability_tcp_nat @@ -224,4 +225,8 @@ EXTRA_DIST = \ test_transport_api_tcp_nat_peer1.conf \ test_transport_api_tcp_nat_peer2.conf \ test_plugin_transport_data.conf \ + test_transport_api_http_peer1.conf \ + test_transport_api_http_peer2.conf \ + test_transport_api_rel_http_peer1.conf \ + test_transport_api_rel_http_peer2.conf \ test_plugin_transport_data_http.conf diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 55a4e4251..5cd611d1f 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -40,7 +40,7 @@ #include "microhttpd.h" #include -#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 @@ -360,6 +360,7 @@ struct Plugin struct sockaddr_in6 * bind6_address; char * bind_hostname; int use_ipv6; + int use_ipv4; }; @@ -545,10 +546,9 @@ process_interfaces (void *cls, 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)) @@ -572,7 +572,7 @@ process_interfaces (void *cls, } 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)); @@ -602,7 +602,6 @@ process_interfaces (void *cls, } GNUNET_free (t6); } - //return GNUNET_NO; return GNUNET_OK; } @@ -2258,6 +2257,7 @@ libgnunet_plugin_transport_http_init (void *cls) 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; @@ -2277,9 +2277,14 @@ libgnunet_plugin_transport_http_init (void *cls) 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 != @@ -2298,8 +2303,8 @@ libgnunet_plugin_transport_http_init (void *cls) } /* 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, @@ -2310,8 +2315,6 @@ libgnunet_plugin_transport_http_init (void *cls) 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, @@ -2326,8 +2329,8 @@ libgnunet_plugin_transport_http_init (void *cls) } /* 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, @@ -2339,8 +2342,6 @@ libgnunet_plugin_transport_http_init (void *cls) 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, @@ -2351,13 +2352,7 @@ libgnunet_plugin_transport_http_init (void *cls) 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)); @@ -2383,7 +2378,7 @@ libgnunet_plugin_transport_http_init (void *cls) 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 diff --git a/src/transport/test_plugin_transport_data_http.conf b/src/transport/test_plugin_transport_data_http.conf index d03f4e840..0c5bbcf26 100644 --- a/src/transport/test_plugin_transport_data_http.conf +++ b/src/transport/test_plugin_transport_data_http.conf @@ -8,8 +8,9 @@ WEAKRANDOM = YES [transport-http] PORT = 12389 DEBUG = NO -USE_IPv6 = YES +#USE_IPv4 = NO #USE_IPv6 = NO +USE_IPv6 = YES #BINDTO4 = 127.0.0.1 #BINDTO6 = ::1 diff --git a/src/transport/test_transport_api_http_peer1.conf b/src/transport/test_transport_api_http_peer1.conf index b7e8fb536..18513d8fc 100644 --- a/src/transport/test_transport_api_http_peer1.conf +++ b/src/transport/test_transport_api_http_peer1.conf @@ -1,8 +1,9 @@ [transport-http] PORT = 12389 DEBUG = NO -USE_IPv6 = NO -BINDTO4 = 127.0.0.1 +USE_IPv6 = YES +USE_IPv4 = YES +#BINDTO4 = 127.0.0.1 #BINDTO6 = ::1 @@ -37,7 +38,7 @@ MINIMUM-FRIENDS = 0 [transport] PLUGINS = http #PLUGINS = tcp http -DEBUG = NO +DEBUG = YES ACCEPT_FROM6 = ::1; ACCEPT_FROM = 127.0.0.1; NEIGHBOUR_LIMIT = 50 @@ -106,6 +107,5 @@ WEAKRANDOM = YES HOSTKEY = $SERVICEHOME/.hostkey [PATHS] -DEFAULTCONFIG = test_transport_api_http_peer1.conf SERVICEHOME = /tmp/test-gnunetd-transport-peer-1/ diff --git a/src/transport/test_transport_api_http_peer2.conf b/src/transport/test_transport_api_http_peer2.conf index 6cdd84fe7..940931b4a 100644 --- a/src/transport/test_transport_api_http_peer2.conf +++ b/src/transport/test_transport_api_http_peer2.conf @@ -1,8 +1,9 @@ [transport-http] PORT = 22368 DEBUG = NO -USE_IPv6 = NO -BINDTO4 = 127.0.0.1 +USE_IPv6 = YES +USE_IPv4 = YES +#BINDTO4 = 127.0.0.1 #BINDTO6 = ::1 [fs] @@ -36,7 +37,7 @@ MINIMUM-FRIENDS = 0 [transport] PLUGINS = http #PLUGINS = tcp http -DEBUG = NO +DEBUG = YES ACCEPT_FROM6 = ::1; ACCEPT_FROM = 127.0.0.1; NEIGHBOUR_LIMIT = 50 @@ -110,6 +111,5 @@ WEAKRANDOM = YES HOSTKEY = $SERVICEHOME/.hostkey [PATHS] -DEFAULTCONFIG = test_transport_api_http_peer2.conf SERVICEHOME = /tmp/test-gnunetd-transport-peer-2/ diff --git a/src/transport/test_transport_api_rel_http_peer1.conf b/src/transport/test_transport_api_rel_http_peer1.conf index b7e8fb536..807e49149 100644 --- a/src/transport/test_transport_api_rel_http_peer1.conf +++ b/src/transport/test_transport_api_rel_http_peer1.conf @@ -1,11 +1,11 @@ [transport-http] PORT = 12389 DEBUG = NO +USE_IPv4 = YES USE_IPv6 = NO BINDTO4 = 127.0.0.1 #BINDTO6 = ::1 - [fs] AUTOSTART = NO @@ -37,7 +37,7 @@ MINIMUM-FRIENDS = 0 [transport] PLUGINS = http #PLUGINS = tcp http -DEBUG = NO +DEBUG = YES ACCEPT_FROM6 = ::1; ACCEPT_FROM = 127.0.0.1; NEIGHBOUR_LIMIT = 50 @@ -106,6 +106,5 @@ WEAKRANDOM = YES HOSTKEY = $SERVICEHOME/.hostkey [PATHS] -DEFAULTCONFIG = test_transport_api_http_peer1.conf SERVICEHOME = /tmp/test-gnunetd-transport-peer-1/ diff --git a/src/transport/test_transport_api_rel_http_peer2.conf b/src/transport/test_transport_api_rel_http_peer2.conf index 6cdd84fe7..7d14e3987 100644 --- a/src/transport/test_transport_api_rel_http_peer2.conf +++ b/src/transport/test_transport_api_rel_http_peer2.conf @@ -1,6 +1,7 @@ [transport-http] -PORT = 22368 +PORT = 22389 DEBUG = NO +USE_IPv4 = YES USE_IPv6 = NO BINDTO4 = 127.0.0.1 #BINDTO6 = ::1 @@ -36,7 +37,7 @@ MINIMUM-FRIENDS = 0 [transport] PLUGINS = http #PLUGINS = tcp http -DEBUG = NO +DEBUG = YES ACCEPT_FROM6 = ::1; ACCEPT_FROM = 127.0.0.1; NEIGHBOUR_LIMIT = 50 @@ -110,6 +111,5 @@ WEAKRANDOM = YES HOSTKEY = $SERVICEHOME/.hostkey [PATHS] -DEFAULTCONFIG = test_transport_api_http_peer2.conf SERVICEHOME = /tmp/test-gnunetd-transport-peer-2/ diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c index a7ab6407d..dc4867f84 100644 --- a/src/transport/test_transport_api_reliability.c +++ b/src/transport/test_transport_api_reliability.c @@ -446,8 +446,8 @@ run (void *cls, } else if (is_http) { - setup_peer (&p1, "test_transport_api_http_peer1.conf"); - setup_peer (&p2, "test_transport_api_http_peer2.conf"); + setup_peer (&p1, "test_transport_api_rel_http_peer1.conf"); + setup_peer (&p2, "test_transport_api_rel_http_peer2.conf"); } else if (is_udp) { -- 2.25.1