diff options
Diffstat (limited to 'src/transport/plugin_transport_http.c')
-rw-r--r-- | src/transport/plugin_transport_http.c | 41 |
1 files changed, 18 insertions, 23 deletions
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 @@ | |||
40 | #include "microhttpd.h" | 40 | #include "microhttpd.h" |
41 | #include <curl/curl.h> | 41 | #include <curl/curl.h> |
42 | 42 | ||
43 | #define DEBUG_HTTP GNUNET_YES | 43 | #define DEBUG_HTTP GNUNET_NO |
44 | #define DEBUG_CURL GNUNET_NO | 44 | #define DEBUG_CURL GNUNET_NO |
45 | #define DEBUG_CONNECTIONS GNUNET_NO | 45 | #define DEBUG_CONNECTIONS GNUNET_NO |
46 | #define DEBUG_SESSION_SELECTION GNUNET_NO | 46 | #define DEBUG_SESSION_SELECTION GNUNET_NO |
@@ -360,6 +360,7 @@ struct Plugin | |||
360 | struct sockaddr_in6 * bind6_address; | 360 | struct sockaddr_in6 * bind6_address; |
361 | char * bind_hostname; | 361 | char * bind_hostname; |
362 | int use_ipv6; | 362 | int use_ipv6; |
363 | int use_ipv4; | ||
363 | }; | 364 | }; |
364 | 365 | ||
365 | 366 | ||
@@ -545,10 +546,9 @@ process_interfaces (void *cls, | |||
545 | 546 | ||
546 | GNUNET_assert(cls !=NULL); | 547 | GNUNET_assert(cls !=NULL); |
547 | af = addr->sa_family; | 548 | af = addr->sa_family; |
548 | if ((af == AF_INET) && (plugin->bind6_address == NULL)) | 549 | if ((af == AF_INET) && (plugin->use_ipv4 == GNUNET_YES) && (plugin->bind6_address == NULL)) |
549 | { | 550 | { |
550 | struct in_addr bnd_cmp = ((struct sockaddr_in *) addr)->sin_addr; | 551 | struct in_addr bnd_cmp = ((struct sockaddr_in *) addr)->sin_addr; |
551 | |||
552 | t4 = GNUNET_malloc(sizeof(struct IPv4HttpAddress)); | 552 | t4 = GNUNET_malloc(sizeof(struct IPv4HttpAddress)); |
553 | /* Not skipping loopback addresses | 553 | /* Not skipping loopback addresses |
554 | if (INADDR_LOOPBACK == ntohl(((struct sockaddr_in *) addr)->sin_addr.s_addr)) | 554 | if (INADDR_LOOPBACK == ntohl(((struct sockaddr_in *) addr)->sin_addr.s_addr)) |
@@ -572,7 +572,7 @@ process_interfaces (void *cls, | |||
572 | } | 572 | } |
573 | GNUNET_free (t4); | 573 | GNUNET_free (t4); |
574 | } | 574 | } |
575 | else if ((af == AF_INET6) && (plugin->use_ipv6==GNUNET_YES) && (plugin->bind4_address == NULL)) | 575 | else if ((af == AF_INET6) && (plugin->use_ipv6 == GNUNET_YES) && (plugin->bind4_address == NULL)) |
576 | { | 576 | { |
577 | struct in6_addr bnd_cmp6 = ((struct sockaddr_in6 *) addr)->sin6_addr; | 577 | struct in6_addr bnd_cmp6 = ((struct sockaddr_in6 *) addr)->sin6_addr; |
578 | t6 = GNUNET_malloc(sizeof(struct IPv6HttpAddress)); | 578 | t6 = GNUNET_malloc(sizeof(struct IPv6HttpAddress)); |
@@ -602,7 +602,6 @@ process_interfaces (void *cls, | |||
602 | } | 602 | } |
603 | GNUNET_free (t6); | 603 | GNUNET_free (t6); |
604 | } | 604 | } |
605 | //return GNUNET_NO; | ||
606 | return GNUNET_OK; | 605 | return GNUNET_OK; |
607 | } | 606 | } |
608 | 607 | ||
@@ -2258,6 +2257,7 @@ libgnunet_plugin_transport_http_init (void *cls) | |||
2258 | plugin->peers = NULL; | 2257 | plugin->peers = NULL; |
2259 | plugin->bind4_address = NULL; | 2258 | plugin->bind4_address = NULL; |
2260 | plugin->use_ipv6 = GNUNET_YES; | 2259 | plugin->use_ipv6 = GNUNET_YES; |
2260 | plugin->use_ipv4 = GNUNET_YES; | ||
2261 | 2261 | ||
2262 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); | 2262 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); |
2263 | api->cls = plugin; | 2263 | api->cls = plugin; |
@@ -2277,9 +2277,14 @@ libgnunet_plugin_transport_http_init (void *cls) | |||
2277 | plugin->use_ipv6 = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, | 2277 | plugin->use_ipv6 = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, |
2278 | "transport-http", | 2278 | "transport-http", |
2279 | "USE_IPv6"); | 2279 | "USE_IPv6"); |
2280 | 2280 | } | |
2281 | 2281 | /* Reading port number from config file */ | |
2282 | 2282 | if (GNUNET_CONFIGURATION_have_value (env->cfg, | |
2283 | "transport-http", "USE_IPv4")) | ||
2284 | { | ||
2285 | plugin->use_ipv4 = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, | ||
2286 | "transport-http", | ||
2287 | "USE_IPv4"); | ||
2283 | } | 2288 | } |
2284 | /* Reading port number from config file */ | 2289 | /* Reading port number from config file */ |
2285 | if ((GNUNET_OK != | 2290 | if ((GNUNET_OK != |
@@ -2298,8 +2303,8 @@ libgnunet_plugin_transport_http_init (void *cls) | |||
2298 | } | 2303 | } |
2299 | 2304 | ||
2300 | /* Reading ipv4 addresse to bind to from config file */ | 2305 | /* Reading ipv4 addresse to bind to from config file */ |
2301 | if (GNUNET_CONFIGURATION_have_value (env->cfg, | 2306 | if ((plugin->use_ipv4==GNUNET_YES) && (GNUNET_CONFIGURATION_have_value (env->cfg, |
2302 | "transport-http", "BINDTO4")) | 2307 | "transport-http", "BINDTO4"))) |
2303 | { | 2308 | { |
2304 | GNUNET_break (GNUNET_OK == | 2309 | GNUNET_break (GNUNET_OK == |
2305 | GNUNET_CONFIGURATION_get_value_string (env->cfg, | 2310 | GNUNET_CONFIGURATION_get_value_string (env->cfg, |
@@ -2310,8 +2315,6 @@ libgnunet_plugin_transport_http_init (void *cls) | |||
2310 | plugin->bind4_address->sin_family = AF_INET; | 2315 | plugin->bind4_address->sin_family = AF_INET; |
2311 | plugin->bind4_address->sin_port = htons (port); | 2316 | plugin->bind4_address->sin_port = htons (port); |
2312 | 2317 | ||
2313 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"v4 Hostname `%s'!\n",plugin->bind_hostname); | ||
2314 | |||
2315 | if (inet_pton(AF_INET,plugin->bind_hostname, &plugin->bind4_address->sin_addr)<=0) | 2318 | if (inet_pton(AF_INET,plugin->bind_hostname, &plugin->bind4_address->sin_addr)<=0) |
2316 | { | 2319 | { |
2317 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | 2320 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, |
@@ -2326,8 +2329,8 @@ libgnunet_plugin_transport_http_init (void *cls) | |||
2326 | } | 2329 | } |
2327 | 2330 | ||
2328 | /* Reading ipv4 addresse to bind to from config file */ | 2331 | /* Reading ipv4 addresse to bind to from config file */ |
2329 | if (GNUNET_CONFIGURATION_have_value (env->cfg, | 2332 | if ((plugin->use_ipv6==GNUNET_YES) && (GNUNET_CONFIGURATION_have_value (env->cfg, |
2330 | "transport-http", "BINDTO6")) | 2333 | "transport-http", "BINDTO6"))) |
2331 | { | 2334 | { |
2332 | GNUNET_break (GNUNET_OK == | 2335 | GNUNET_break (GNUNET_OK == |
2333 | GNUNET_CONFIGURATION_get_value_string (env->cfg, | 2336 | GNUNET_CONFIGURATION_get_value_string (env->cfg, |
@@ -2339,8 +2342,6 @@ libgnunet_plugin_transport_http_init (void *cls) | |||
2339 | plugin->bind6_address->sin6_family = AF_INET6; | 2342 | plugin->bind6_address->sin6_family = AF_INET6; |
2340 | plugin->bind6_address->sin6_port = htons (port); | 2343 | plugin->bind6_address->sin6_port = htons (port); |
2341 | 2344 | ||
2342 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"v6 Hostname `%s'!\n",plugin->bind_hostname); | ||
2343 | |||
2344 | if (inet_pton(AF_INET6,plugin->bind_hostname, &plugin->bind6_address->sin6_addr)<=0) | 2345 | if (inet_pton(AF_INET6,plugin->bind_hostname, &plugin->bind6_address->sin6_addr)<=0) |
2345 | { | 2346 | { |
2346 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | 2347 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, |
@@ -2351,13 +2352,7 @@ libgnunet_plugin_transport_http_init (void *cls) | |||
2351 | GNUNET_free(plugin->bind_hostname); | 2352 | GNUNET_free(plugin->bind_hostname); |
2352 | plugin->bind_hostname = NULL; | 2353 | plugin->bind_hostname = NULL; |
2353 | plugin->bind6_address = NULL; | 2354 | plugin->bind6_address = NULL; |
2354 | |||
2355 | } | 2355 | } |
2356 | |||
2357 | char * tmp = GNUNET_malloc(50); | ||
2358 | inet_ntop(AF_INET6,&plugin->bind6_address->sin6_addr,tmp,50); | ||
2359 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"v6 Hostname reverse `%s'!\n",tmp); | ||
2360 | GNUNET_free(tmp); | ||
2361 | } | 2356 | } |
2362 | 2357 | ||
2363 | GNUNET_assert ((port > 0) && (port <= 65535)); | 2358 | GNUNET_assert ((port > 0) && (port <= 65535)); |
@@ -2383,7 +2378,7 @@ libgnunet_plugin_transport_http_init (void *cls) | |||
2383 | MHD_OPTION_NOTIFY_COMPLETED, &mhd_termination_cb, NULL, | 2378 | MHD_OPTION_NOTIFY_COMPLETED, &mhd_termination_cb, NULL, |
2384 | MHD_OPTION_END); | 2379 | MHD_OPTION_END); |
2385 | } | 2380 | } |
2386 | if ((plugin->http_server_daemon_v4 == NULL) && (port != 0)) | 2381 | if ((plugin->http_server_daemon_v4 == NULL) && (plugin->use_ipv4 == GNUNET_YES) && (port != 0)) |
2387 | { | 2382 | { |
2388 | plugin->http_server_daemon_v4 = MHD_start_daemon ( | 2383 | plugin->http_server_daemon_v4 = MHD_start_daemon ( |
2389 | #if DEBUG_CONNECTIONS | 2384 | #if DEBUG_CONNECTIONS |