diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-06-28 08:26:53 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-06-28 08:26:53 +0000 |
commit | d38f7b3de510b3edcd8a87b4b39426070a225d42 (patch) | |
tree | 2c585f1aecbbae4772412da66fa9818b7844b90c /src | |
parent | 101bffe8b77c629dafb9149197d5e9aec3304cac (diff) | |
download | gnunet-d38f7b3de510b3edcd8a87b4b39426070a225d42.tar.gz gnunet-d38f7b3de510b3edcd8a87b4b39426070a225d42.zip |
added: port can be automatically included in external hostname
required for testing when ports are modified automatically
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/plugin_transport_http_server.c | 41 | ||||
-rw-r--r-- | src/transport/test_transport_api_https_peer2.conf | 10 |
2 files changed, 39 insertions, 12 deletions
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index 5ae16ca98..a332804ef 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c | |||
@@ -2612,7 +2612,7 @@ server_notify_external_hostname (void *cls, const struct GNUNET_SCHEDULER_TaskCo | |||
2612 | memcpy (&plugin->ext_addr[1], url, urlen); | 2612 | memcpy (&plugin->ext_addr[1], url, urlen); |
2613 | GNUNET_free (url); | 2613 | GNUNET_free (url); |
2614 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 2614 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
2615 | "Notifying transport about external hostname address `%s'\n", plugin->ext_addr); | 2615 | "Notifying transport about external hostname address `%s'\n", plugin->external_hostname); |
2616 | 2616 | ||
2617 | #if BUILD_HTTPS | 2617 | #if BUILD_HTTPS |
2618 | if (GNUNET_YES == plugin->verify_external_hostname) | 2618 | if (GNUNET_YES == plugin->verify_external_hostname) |
@@ -2642,6 +2642,8 @@ server_configure_plugin (struct HTTP_Server_Plugin *plugin) | |||
2642 | unsigned long long max_connections; | 2642 | unsigned long long max_connections; |
2643 | char *bind4_address = NULL; | 2643 | char *bind4_address = NULL; |
2644 | char *bind6_address = NULL; | 2644 | char *bind6_address = NULL; |
2645 | char *eh_tmp = NULL; | ||
2646 | int external_hostname_use_port; | ||
2645 | 2647 | ||
2646 | /* Use IPv4? */ | 2648 | /* Use IPv4? */ |
2647 | if (GNUNET_CONFIGURATION_have_value | 2649 | if (GNUNET_CONFIGURATION_have_value |
@@ -2692,7 +2694,7 @@ server_configure_plugin (struct HTTP_Server_Plugin *plugin) | |||
2692 | } | 2694 | } |
2693 | plugin->port = port; | 2695 | plugin->port = port; |
2694 | 2696 | ||
2695 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 2697 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, plugin->name, |
2696 | _("Using port %u\n"), plugin->port); | 2698 | _("Using port %u\n"), plugin->port); |
2697 | 2699 | ||
2698 | if ((plugin->use_ipv4 == GNUNET_YES) && | 2700 | if ((plugin->use_ipv4 == GNUNET_YES) && |
@@ -2765,19 +2767,42 @@ server_configure_plugin (struct HTTP_Server_Plugin *plugin) | |||
2765 | if (GNUNET_YES == plugin->verify_external_hostname) | 2767 | if (GNUNET_YES == plugin->verify_external_hostname) |
2766 | plugin->options |= HTTP_OPTIONS_VERIFY_CERTIFICATE; | 2768 | plugin->options |= HTTP_OPTIONS_VERIFY_CERTIFICATE; |
2767 | #endif | 2769 | #endif |
2770 | external_hostname_use_port = GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg, plugin->name, | ||
2771 | "EXTERNAL_HOSTNAME_USE_PORT"); | ||
2772 | if (GNUNET_SYSERR == external_hostname_use_port) | ||
2773 | external_hostname_use_port = GNUNET_NO; | ||
2774 | |||
2768 | 2775 | ||
2769 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, plugin->name, | 2776 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, plugin->name, |
2770 | "EXTERNAL_HOSTNAME", &plugin->external_hostname)) | 2777 | "EXTERNAL_HOSTNAME", &eh_tmp)) |
2771 | { | 2778 | { |
2772 | char * tmp = NULL; | 2779 | char * tmp = NULL; |
2773 | if (NULL != strstr(plugin->external_hostname, "://")) | 2780 | char * pos = NULL; |
2781 | char * pos_url = NULL; | ||
2782 | |||
2783 | if (NULL != strstr(eh_tmp, "://")) | ||
2774 | { | 2784 | { |
2775 | tmp = strdup(&strstr(plugin->external_hostname, "://")[3]); | 2785 | tmp = &strstr(eh_tmp, "://")[3]; |
2776 | GNUNET_free (plugin->external_hostname); | 2786 | } |
2777 | plugin->external_hostname = tmp; | 2787 | else |
2788 | tmp = eh_tmp; | ||
2778 | 2789 | ||
2790 | if (GNUNET_YES == external_hostname_use_port) | ||
2791 | { | ||
2792 | if ( (strlen (tmp) > 1) && (NULL != (pos = strchr(tmp, '/'))) ) | ||
2793 | { | ||
2794 | pos_url = pos + 1; | ||
2795 | pos[0] = '\0'; | ||
2796 | GNUNET_asprintf (&plugin->external_hostname, "%s:%u/%s", tmp, port, pos_url); | ||
2797 | } | ||
2798 | else | ||
2799 | GNUNET_asprintf (&plugin->external_hostname, "%s:%u", tmp, port); | ||
2779 | } | 2800 | } |
2780 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 2801 | else |
2802 | plugin->external_hostname = GNUNET_strdup (tmp); | ||
2803 | GNUNET_free (eh_tmp); | ||
2804 | |||
2805 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, plugin->name, | ||
2781 | _("Using external hostname `%s'\n"), plugin->external_hostname); | 2806 | _("Using external hostname `%s'\n"), plugin->external_hostname); |
2782 | plugin->notify_ext_task = GNUNET_SCHEDULER_add_now (&server_notify_external_hostname, plugin); | 2807 | plugin->notify_ext_task = GNUNET_SCHEDULER_add_now (&server_notify_external_hostname, plugin); |
2783 | 2808 | ||
diff --git a/src/transport/test_transport_api_https_peer2.conf b/src/transport/test_transport_api_https_peer2.conf index 19cd16959..89bef2b20 100644 --- a/src/transport/test_transport_api_https_peer2.conf +++ b/src/transport/test_transport_api_https_peer2.conf | |||
@@ -3,10 +3,12 @@ | |||
3 | SERVICEHOME = /tmp/test-transport/api-https-p2/ | 3 | SERVICEHOME = /tmp/test-transport/api-https-p2/ |
4 | 4 | ||
5 | [transport-https_server] | 5 | [transport-https_server] |
6 | EXTERNAL_HOSTNAME = test | 6 | EXTERNAL_HOSTNAME = localhost/test |
7 | #EXTERNAL_HOSTNAME_ONLY = yes | 7 | EXTERNAL_HOSTNAME_ONLY = yes |
8 | VERIFY_EXTERNAL_HOSTNAME = YES | 8 | EXTERNAL_HOSTNAME_USE_PORT = YES |
9 | PORT = 12110 | 9 | #VERIFY_EXTERNAL_HOSTNAME = YES |
10 | #PORT = 10000 | ||
11 | # Does the external hostname use the same port? | ||
10 | USE_IPv6 = YES | 12 | USE_IPv6 = YES |
11 | #BINDTO = 127.0.0.1 | 13 | #BINDTO = 127.0.0.1 |
12 | KEY_FILE = $SERVICEHOME/https_key_p2.key | 14 | KEY_FILE = $SERVICEHOME/https_key_p2.key |