commit d38f7b3de510b3edcd8a87b4b39426070a225d42
parent 101bffe8b77c629dafb9149197d5e9aec3304cac
Author: Matthias Wachs <wachs@net.in.tum.de>
Date: Fri, 28 Jun 2013 08:26:53 +0000
added: port can be automatically included in external hostname
required for testing when ports are modified automatically
Diffstat:
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
@@ -2612,7 +2612,7 @@ server_notify_external_hostname (void *cls, const struct GNUNET_SCHEDULER_TaskCo
memcpy (&plugin->ext_addr[1], url, urlen);
GNUNET_free (url);
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Notifying transport about external hostname address `%s'\n", plugin->ext_addr);
+ "Notifying transport about external hostname address `%s'\n", plugin->external_hostname);
#if BUILD_HTTPS
if (GNUNET_YES == plugin->verify_external_hostname)
@@ -2642,6 +2642,8 @@ server_configure_plugin (struct HTTP_Server_Plugin *plugin)
unsigned long long max_connections;
char *bind4_address = NULL;
char *bind6_address = NULL;
+ char *eh_tmp = NULL;
+ int external_hostname_use_port;
/* Use IPv4? */
if (GNUNET_CONFIGURATION_have_value
@@ -2692,7 +2694,7 @@ server_configure_plugin (struct HTTP_Server_Plugin *plugin)
}
plugin->port = port;
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, plugin->name,
_("Using port %u\n"), plugin->port);
if ((plugin->use_ipv4 == GNUNET_YES) &&
@@ -2765,19 +2767,42 @@ server_configure_plugin (struct HTTP_Server_Plugin *plugin)
if (GNUNET_YES == plugin->verify_external_hostname)
plugin->options |= HTTP_OPTIONS_VERIFY_CERTIFICATE;
#endif
+ external_hostname_use_port = GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg, plugin->name,
+ "EXTERNAL_HOSTNAME_USE_PORT");
+ if (GNUNET_SYSERR == external_hostname_use_port)
+ external_hostname_use_port = GNUNET_NO;
+
if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, plugin->name,
- "EXTERNAL_HOSTNAME", &plugin->external_hostname))
+ "EXTERNAL_HOSTNAME", &eh_tmp))
{
char * tmp = NULL;
- if (NULL != strstr(plugin->external_hostname, "://"))
+ char * pos = NULL;
+ char * pos_url = NULL;
+
+ if (NULL != strstr(eh_tmp, "://"))
{
- tmp = strdup(&strstr(plugin->external_hostname, "://")[3]);
- GNUNET_free (plugin->external_hostname);
- plugin->external_hostname = tmp;
+ tmp = &strstr(eh_tmp, "://")[3];
+ }
+ else
+ tmp = eh_tmp;
+ if (GNUNET_YES == external_hostname_use_port)
+ {
+ if ( (strlen (tmp) > 1) && (NULL != (pos = strchr(tmp, '/'))) )
+ {
+ pos_url = pos + 1;
+ pos[0] = '\0';
+ GNUNET_asprintf (&plugin->external_hostname, "%s:%u/%s", tmp, port, pos_url);
+ }
+ else
+ GNUNET_asprintf (&plugin->external_hostname, "%s:%u", tmp, port);
}
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ else
+ plugin->external_hostname = GNUNET_strdup (tmp);
+ GNUNET_free (eh_tmp);
+
+ GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, plugin->name,
_("Using external hostname `%s'\n"), plugin->external_hostname);
plugin->notify_ext_task = GNUNET_SCHEDULER_add_now (&server_notify_external_hostname, plugin);
diff --git a/src/transport/test_transport_api_https_peer2.conf b/src/transport/test_transport_api_https_peer2.conf
@@ -3,10 +3,12 @@
SERVICEHOME = /tmp/test-transport/api-https-p2/
[transport-https_server]
-EXTERNAL_HOSTNAME = test
-#EXTERNAL_HOSTNAME_ONLY = yes
-VERIFY_EXTERNAL_HOSTNAME = YES
-PORT = 12110
+EXTERNAL_HOSTNAME = localhost/test
+EXTERNAL_HOSTNAME_ONLY = yes
+EXTERNAL_HOSTNAME_USE_PORT = YES
+#VERIFY_EXTERNAL_HOSTNAME = YES
+#PORT = 10000
+# Does the external hostname use the same port?
USE_IPv6 = YES
#BINDTO = 127.0.0.1
KEY_FILE = $SERVICEHOME/https_key_p2.key