aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-24 14:54:22 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-24 14:54:22 +0000
commitb7e1636fb0a053199b1574c9176e0b39c0b0c7d8 (patch)
tree68d9b449e6caf89475593bc6106e4537f1839734 /src
parent84123de1ed06270c74a771ec7f91627adc79c404 (diff)
downloadgnunet-b7e1636fb0a053199b1574c9176e0b39c0b0c7d8.tar.gz
gnunet-b7e1636fb0a053199b1574c9176e0b39c0b0c7d8.zip
-fix http fix
Diffstat (limited to 'src')
-rw-r--r--src/transport/plugin_transport_http_server.c111
1 files changed, 69 insertions, 42 deletions
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c
index e542c29b8..5088f2e77 100644
--- a/src/transport/plugin_transport_http_server.c
+++ b/src/transport/plugin_transport_http_server.c
@@ -578,7 +578,9 @@ server_delete_session (struct GNUNET_ATS_Session *s)
578 MHD_set_connection_option (s->server_send->mhd_conn, 578 MHD_set_connection_option (s->server_send->mhd_conn,
579 MHD_CONNECTION_OPTION_TIMEOUT, 579 MHD_CONNECTION_OPTION_TIMEOUT,
580 1 /* 0 = no timeout, so this is MIN */); 580 1 /* 0 = no timeout, so this is MIN */);
581 server_reschedule (plugin, s->server_send->mhd_daemon, GNUNET_YES); 581 server_reschedule (plugin,
582 s->server_send->mhd_daemon,
583 GNUNET_YES);
582 } 584 }
583 585
584 if (NULL != s->server_recv) 586 if (NULL != s->server_recv)
@@ -590,7 +592,9 @@ server_delete_session (struct GNUNET_ATS_Session *s)
590 MHD_set_connection_option (s->server_recv->mhd_conn, 592 MHD_set_connection_option (s->server_recv->mhd_conn,
591 MHD_CONNECTION_OPTION_TIMEOUT, 593 MHD_CONNECTION_OPTION_TIMEOUT,
592 1 /* 0 = no timeout, so this is MIN */); 594 1 /* 0 = no timeout, so this is MIN */);
593 server_reschedule (plugin, s->server_recv->mhd_daemon, GNUNET_YES); 595 server_reschedule (plugin,
596 s->server_recv->mhd_daemon,
597 GNUNET_YES);
594 } 598 }
595 notify_session_monitor (plugin, 599 notify_session_monitor (plugin,
596 s, 600 s,
@@ -611,7 +615,6 @@ server_delete_session (struct GNUNET_ATS_Session *s)
611 LOG (GNUNET_ERROR_TYPE_DEBUG, 615 LOG (GNUNET_ERROR_TYPE_DEBUG,
612 "Session %p destroyed\n", 616 "Session %p destroyed\n",
613 s); 617 s);
614
615 GNUNET_free (s); 618 GNUNET_free (s);
616} 619}
617 620
@@ -784,13 +787,15 @@ destroy_session_shutdown_cb (void *cls,
784 sc_send = s->server_send; 787 sc_send = s->server_send;
785 sc_recv = s->server_recv; 788 sc_recv = s->server_recv;
786 server_delete_session (s); 789 server_delete_session (s);
787 790 if (NULL != sc_send)
788 GNUNET_free_non_null (sc_send); 791 sc_send->session = NULL;
789 GNUNET_free_non_null (sc_recv); 792 if (NULL != sc_recv)
793 sc_recv->session = NULL;
790 794
791 return GNUNET_OK; 795 return GNUNET_OK;
792} 796}
793 797
798
794/** 799/**
795 * Terminate session. 800 * Terminate session.
796 * 801 *
@@ -810,6 +815,7 @@ destroy_session_cb (void *cls,
810 return GNUNET_OK; 815 return GNUNET_OK;
811} 816}
812 817
818
813/** 819/**
814 * Function that can be used to force the plugin to disconnect 820 * Function that can be used to force the plugin to disconnect
815 * from the given peer and cancel all previous transmissions 821 * from the given peer and cancel all previous transmissions
@@ -1648,7 +1654,9 @@ server_receive_mst_cb (void *cls,
1648 "# bytes received via %s_server", 1654 "# bytes received via %s_server",
1649 plugin->protocol); 1655 plugin->protocol);
1650 GNUNET_STATISTICS_update (plugin->env->stats, 1656 GNUNET_STATISTICS_update (plugin->env->stats,
1651 stat_txt, ntohs (message->size), GNUNET_NO); 1657 stat_txt,
1658 ntohs (message->size),
1659 GNUNET_NO);
1652 GNUNET_free (stat_txt); 1660 GNUNET_free (stat_txt);
1653 s->next_receive = GNUNET_TIME_relative_to_absolute (delay); 1661 s->next_receive = GNUNET_TIME_relative_to_absolute (delay);
1654 if (delay.rel_value_us > 0) 1662 if (delay.rel_value_us > 0)
@@ -2752,7 +2760,8 @@ server_start_report_addresses (struct HTTP_Server_Plugin *plugin)
2752 plugin->port, 2760 plugin->port,
2753 (unsigned int) res, 2761 (unsigned int) res,
2754 (const struct sockaddr **) addrs, addrlens, 2762 (const struct sockaddr **) addrs, addrlens,
2755 &server_nat_port_map_callback, NULL, plugin, NULL); 2763 &server_nat_port_map_callback, NULL,
2764 plugin, NULL);
2756 while (res > 0) 2765 while (res > 0)
2757 { 2766 {
2758 res--; 2767 res--;
@@ -2806,13 +2815,18 @@ server_check_ipv6_support (struct HTTP_Server_Plugin *plugin)
2806 int res = GNUNET_NO; 2815 int res = GNUNET_NO;
2807 2816
2808 /* Probe IPv6 support */ 2817 /* Probe IPv6 support */
2809 desc = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0); 2818 desc = GNUNET_NETWORK_socket_create (PF_INET6,
2819 SOCK_STREAM,
2820 0);
2810 if (NULL == desc) 2821 if (NULL == desc)
2811 { 2822 {
2812 if ((errno == ENOBUFS) || (errno == ENOMEM) || (errno == ENFILE) || 2823 if ( (errno == ENOBUFS) ||
2813 (errno == EACCES)) 2824 (errno == ENOMEM) ||
2825 (errno == ENFILE) ||
2826 (errno == EACCES) )
2814 { 2827 {
2815 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); 2828 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
2829 "socket");
2816 } 2830 }
2817 LOG (GNUNET_ERROR_TYPE_WARNING, 2831 LOG (GNUNET_ERROR_TYPE_WARNING,
2818 _("Disabling IPv6 since it is not supported on this system!\n")); 2832 _("Disabling IPv6 since it is not supported on this system!\n"));
@@ -2820,7 +2834,8 @@ server_check_ipv6_support (struct HTTP_Server_Plugin *plugin)
2820 } 2834 }
2821 else 2835 else
2822 { 2836 {
2823 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (desc)); 2837 GNUNET_break (GNUNET_OK ==
2838 GNUNET_NETWORK_socket_close (desc));
2824 desc = NULL; 2839 desc = NULL;
2825 res = GNUNET_YES; 2840 res = GNUNET_YES;
2826 } 2841 }
@@ -2867,21 +2882,23 @@ server_notify_external_hostname (void *cls)
2867 LOG (GNUNET_ERROR_TYPE_INFO, 2882 LOG (GNUNET_ERROR_TYPE_INFO,
2868 "Enabling SSL verification for external hostname address `%s'\n", 2883 "Enabling SSL verification for external hostname address `%s'\n",
2869 plugin->external_hostname); 2884 plugin->external_hostname);
2870 plugin->ext_addr = GNUNET_HELLO_address_allocate (plugin->env->my_identity, 2885 plugin->ext_addr
2871 "https_client", 2886 = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
2872 ext_addr, 2887 "https_client",
2873 ext_addr_len, 2888 ext_addr,
2874 GNUNET_HELLO_ADDRESS_INFO_NONE); 2889 ext_addr_len,
2890 GNUNET_HELLO_ADDRESS_INFO_NONE);
2875 plugin->env->notify_address (plugin->env->cls, 2891 plugin->env->notify_address (plugin->env->cls,
2876 GNUNET_YES, 2892 GNUNET_YES,
2877 plugin->ext_addr); 2893 plugin->ext_addr);
2878 GNUNET_free (ext_addr); 2894 GNUNET_free (ext_addr);
2879#else 2895#else
2880 plugin->ext_addr = GNUNET_HELLO_address_allocate (plugin->env->my_identity, 2896 plugin->ext_addr
2881 "http_client", 2897 = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
2882 ext_addr, 2898 "http_client",
2883 ext_addr_len, 2899 ext_addr,
2884 GNUNET_HELLO_ADDRESS_INFO_NONE); 2900 ext_addr_len,
2901 GNUNET_HELLO_ADDRESS_INFO_NONE);
2885 plugin->env->notify_address (plugin->env->cls, 2902 plugin->env->notify_address (plugin->env->cls,
2886 GNUNET_YES, 2903 GNUNET_YES,
2887 plugin->ext_addr); 2904 plugin->ext_addr);
@@ -2958,15 +2975,20 @@ server_configure_plugin (struct HTTP_Server_Plugin *plugin)
2958 LOG (GNUNET_ERROR_TYPE_INFO, 2975 LOG (GNUNET_ERROR_TYPE_INFO,
2959 _("Using port %u\n"), plugin->port); 2976 _("Using port %u\n"), plugin->port);
2960 2977
2961 if ((plugin->use_ipv4 == GNUNET_YES) && 2978 if ( (plugin->use_ipv4 == GNUNET_YES) &&
2962 (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, 2979 (GNUNET_YES ==
2963 plugin->name, "BINDTO", &bind4_address))) 2980 GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg,
2981 plugin->name,
2982 "BINDTO",
2983 &bind4_address)))
2964 { 2984 {
2965 LOG (GNUNET_ERROR_TYPE_DEBUG, 2985 LOG (GNUNET_ERROR_TYPE_DEBUG,
2966 "Binding %s plugin to specific IPv4 address: `%s'\n", 2986 "Binding %s plugin to specific IPv4 address: `%s'\n",
2967 plugin->protocol, bind4_address); 2987 plugin->protocol,
2988 bind4_address);
2968 plugin->server_addr_v4 = GNUNET_new (struct sockaddr_in); 2989 plugin->server_addr_v4 = GNUNET_new (struct sockaddr_in);
2969 if (1 != inet_pton (AF_INET, bind4_address, 2990 if (1 != inet_pton (AF_INET,
2991 bind4_address,
2970 &plugin->server_addr_v4->sin_addr)) 2992 &plugin->server_addr_v4->sin_addr))
2971 { 2993 {
2972 LOG (GNUNET_ERROR_TYPE_ERROR, 2994 LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -2980,7 +3002,7 @@ server_configure_plugin (struct HTTP_Server_Plugin *plugin)
2980 else 3002 else
2981 { 3003 {
2982 LOG (GNUNET_ERROR_TYPE_DEBUG, 3004 LOG (GNUNET_ERROR_TYPE_DEBUG,
2983 _("Binding to IPv4 address %s\n"), 3005 "Binding to IPv4 address %s\n",
2984 bind4_address); 3006 bind4_address);
2985 plugin->server_addr_v4->sin_family = AF_INET; 3007 plugin->server_addr_v4->sin_family = AF_INET;
2986 plugin->server_addr_v4->sin_port = htons (plugin->port); 3008 plugin->server_addr_v4->sin_port = htons (plugin->port);
@@ -2992,14 +3014,17 @@ server_configure_plugin (struct HTTP_Server_Plugin *plugin)
2992 (GNUNET_YES == 3014 (GNUNET_YES ==
2993 GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, 3015 GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg,
2994 plugin->name, 3016 plugin->name,
2995 "BINDTO6", &bind6_address))) 3017 "BINDTO6",
3018 &bind6_address)))
2996 { 3019 {
2997 LOG (GNUNET_ERROR_TYPE_DEBUG, 3020 LOG (GNUNET_ERROR_TYPE_DEBUG,
2998 "Binding %s plugin to specific IPv6 address: `%s'\n", 3021 "Binding %s plugin to specific IPv6 address: `%s'\n",
2999 plugin->protocol, bind6_address); 3022 plugin->protocol, bind6_address);
3000 plugin->server_addr_v6 = GNUNET_new (struct sockaddr_in6); 3023 plugin->server_addr_v6 = GNUNET_new (struct sockaddr_in6);
3001 if (1 != 3024 if (1 !=
3002 inet_pton (AF_INET6, bind6_address, &plugin->server_addr_v6->sin6_addr)) 3025 inet_pton (AF_INET6,
3026 bind6_address,
3027 &plugin->server_addr_v6->sin6_addr))
3003 { 3028 {
3004 LOG (GNUNET_ERROR_TYPE_ERROR, 3029 LOG (GNUNET_ERROR_TYPE_ERROR,
3005 _("Specific IPv6 address `%s' in configuration file is invalid!\n"), 3030 _("Specific IPv6 address `%s' in configuration file is invalid!\n"),
@@ -3012,7 +3037,7 @@ server_configure_plugin (struct HTTP_Server_Plugin *plugin)
3012 else 3037 else
3013 { 3038 {
3014 LOG (GNUNET_ERROR_TYPE_DEBUG, 3039 LOG (GNUNET_ERROR_TYPE_DEBUG,
3015 _("Binding to IPv6 address %s\n"), 3040 "Binding to IPv6 address %s\n",
3016 bind6_address); 3041 bind6_address);
3017 plugin->server_addr_v6->sin6_family = AF_INET6; 3042 plugin->server_addr_v6->sin6_family = AF_INET6;
3018 plugin->server_addr_v6->sin6_port = htons (plugin->port); 3043 plugin->server_addr_v6->sin6_port = htons (plugin->port);
@@ -3022,17 +3047,19 @@ server_configure_plugin (struct HTTP_Server_Plugin *plugin)
3022 3047
3023 plugin->verify_external_hostname = GNUNET_NO; 3048 plugin->verify_external_hostname = GNUNET_NO;
3024#if BUILD_HTTPS 3049#if BUILD_HTTPS
3025 plugin->verify_external_hostname = GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg, 3050 plugin->verify_external_hostname
3026 plugin->name, 3051 = GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg,
3027 "VERIFY_EXTERNAL_HOSTNAME"); 3052 plugin->name,
3053 "VERIFY_EXTERNAL_HOSTNAME");
3028 if (GNUNET_SYSERR == plugin->verify_external_hostname) 3054 if (GNUNET_SYSERR == plugin->verify_external_hostname)
3029 plugin->verify_external_hostname = GNUNET_NO; 3055 plugin->verify_external_hostname = GNUNET_NO;
3030 if (GNUNET_YES == plugin->verify_external_hostname) 3056 if (GNUNET_YES == plugin->verify_external_hostname)
3031 plugin->options |= HTTP_OPTIONS_VERIFY_CERTIFICATE; 3057 plugin->options |= HTTP_OPTIONS_VERIFY_CERTIFICATE;
3032#endif 3058#endif
3033 external_hostname_use_port = GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg, 3059 external_hostname_use_port
3034 plugin->name, 3060 = GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg,
3035 "EXTERNAL_HOSTNAME_USE_PORT"); 3061 plugin->name,
3062 "EXTERNAL_HOSTNAME_USE_PORT");
3036 if (GNUNET_SYSERR == external_hostname_use_port) 3063 if (GNUNET_SYSERR == external_hostname_use_port)
3037 external_hostname_use_port = GNUNET_NO; 3064 external_hostname_use_port = GNUNET_NO;
3038 3065
@@ -3434,12 +3461,12 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
3434 } 3461 }
3435 3462
3436 /* Compile URL regex */ 3463 /* Compile URL regex */
3437 if (regcomp(&plugin->url_regex, 3464 if (regcomp (&plugin->url_regex,
3438 URL_REGEX, 3465 URL_REGEX,
3439 REG_EXTENDED)) 3466 REG_EXTENDED))
3440 { 3467 {
3441 LOG (GNUNET_ERROR_TYPE_ERROR, 3468 LOG (GNUNET_ERROR_TYPE_ERROR,
3442 _("Unable to compile URL regex\n")); 3469 _("Unable to compile URL regex\n"));
3443 LIBGNUNET_PLUGIN_TRANSPORT_DONE (api); 3470 LIBGNUNET_PLUGIN_TRANSPORT_DONE (api);
3444 return NULL; 3471 return NULL;
3445 } 3472 }