[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r23338 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r23338 - gnunet/src/transport |
Date: |
Tue, 21 Aug 2012 13:15:10 +0200 |
Author: wachs
Date: 2012-08-21 13:15:10 +0200 (Tue, 21 Aug 2012)
New Revision: 23338
Modified:
gnunet/src/transport/plugin_transport_http.c
gnunet/src/transport/plugin_transport_http.h
gnunet/src/transport/test_transport_api_http_reverse_proxy.conf
Log:
mod
Modified: gnunet/src/transport/plugin_transport_http.c
===================================================================
--- gnunet/src/transport/plugin_transport_http.c 2012-08-21 11:05:44 UTC
(rev 23337)
+++ gnunet/src/transport/plugin_transport_http.c 2012-08-21 11:15:10 UTC
(rev 23338)
@@ -33,7 +33,26 @@
*/
#define LEARNED_ADDRESS_EXPIRATION GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_HOURS, 6)
+
/**
+ * Wrapper to manage addresses
+ */
+struct HttpAddressWrapper
+{
+ /**
+ * Linked list next
+ */
+ struct HttpAddressWrapper *next;
+
+ /**
+ * Linked list previous
+ */
+ struct HttpAddressWrapper *prev;
+
+ struct HttpAddress *addr;
+};
+
+/**
* Wrapper to manage IPv4 addresses
*/
struct IPv4HttpAddressWrapper
@@ -1372,7 +1391,38 @@
}
}
+/**
+ * Function called when the service shuts down. Unloads our plugins
+ * and cancels pending validations.
+ *
+ * @param cls closure, unused
+ * @param tc task context (unused)
+ */
+static void
+notify_external_hostname (void *cls, const struct GNUNET_SCHEDULER_TaskContext
*tc)
+{
+ struct Plugin *plugin = cls;
+ struct HttpAddress *eaddr;
+ size_t eaddr_len;
+ size_t uri_len;
+ plugin->notify_ext_task = GNUNET_SCHEDULER_NO_TASK;
+
+ if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+ return;
+
+ uri_len = strlen (plugin->external_hostname) + 1;
+ eaddr_len = sizeof (struct HttpAddress) + uri_len;
+ eaddr = GNUNET_malloc (eaddr_len);
+ eaddr->addr_len = htonl (strlen (plugin->external_hostname) + 1);
+ eaddr->addr = (void *) &eaddr[1];
+ memcpy (&eaddr->addr, plugin->external_hostname, uri_len);
+ plugin->env->notify_address (plugin->env->cls, GNUNET_YES, eaddr, eaddr_len);
+ plugin->ext_addr = eaddr;
+ plugin->ext_addr_len = eaddr_len;
+}
+
+
static int
configure_plugin (struct Plugin *plugin)
{
@@ -1461,7 +1511,6 @@
GNUNET_free (bind4_address);
}
-
char *bind6_address = NULL;
if ((plugin->ipv6 == GNUNET_YES) &&
@@ -1491,7 +1540,18 @@
GNUNET_free (bind6_address);
}
+ if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg,
plugin->name,
+ "EXTERNAL_HOSTNAME",
&plugin->external_hostname))
+ {
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ _("Using external hostname `%s'\n"),
plugin->external_hostname);
+ plugin->notify_ext_task = GNUNET_SCHEDULER_add_now
(¬ify_external_hostname, plugin);
+ }
+ else
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ _("No external hostname configured\n"));
+
/* Optional parameters */
unsigned long long maxneigh;
@@ -1703,6 +1763,18 @@
return NULL;
}
+ if (GNUNET_SCHEDULER_NO_TASK != plugin->notify_ext_task)
+ {
+ GNUNET_SCHEDULER_cancel (plugin->notify_ext_task);
+ plugin->notify_ext_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+
+ if (NULL != plugin->ext_addr)
+ {
+ plugin->env->notify_address (plugin->env->cls, GNUNET_NO,
plugin->ext_addr, plugin->ext_addr_len);
+ GNUNET_free (plugin->ext_addr);
+ }
+
/* Stop reporting addresses to transport service */
stop_report_addresses (plugin);
@@ -1732,6 +1804,7 @@
"Plugin `%s' unloaded\n", plugin->name);
GNUNET_free_non_null (plugin->server_addr_v4);
GNUNET_free_non_null (plugin->server_addr_v6);
+ GNUNET_free_non_null (plugin->external_hostname);
GNUNET_free (plugin);
GNUNET_free (api);
return NULL;
Modified: gnunet/src/transport/plugin_transport_http.h
===================================================================
--- gnunet/src/transport/plugin_transport_http.h 2012-08-21 11:05:44 UTC
(rev 23337)
+++ gnunet/src/transport/plugin_transport_http.h 2012-08-21 11:15:10 UTC
(rev 23338)
@@ -119,6 +119,29 @@
*/
/**
+ * External hostname the plugin can be connected to, can be different to
+ * the host's FQDN, used e.g. for reverse proxying
+ */
+ char *external_hostname;
+
+ /**
+ * External hostname the plugin can be connected to, can be different to
+ * the host's FQDN, used e.g. for reverse proxying
+ */
+ struct HttpAddress *ext_addr;
+
+ /**
+ * External address length
+ */
+ size_t ext_addr_len;
+
+ /**
+ * Task calling transport service about external address
+ */
+ GNUNET_SCHEDULER_TaskIdentifier notify_ext_task;
+
+
+ /**
* Plugin name
* Equals configuration section: transport-http, transport-https
*/
@@ -284,6 +307,22 @@
GNUNET_NETWORK_STRUCT_BEGIN
/**
+ * HTTP addresses including a full URI
+ */
+struct HttpAddress
+{
+ /**
+ * Length of the address following in NBO
+ */
+ uint32_t addr_len GNUNET_PACKED;
+
+ /**
+ * Address following
+ */
+ void *addr GNUNET_PACKED;
+};
+
+/**
* IPv4 addresses
*/
struct IPv4HttpAddress
Modified: gnunet/src/transport/test_transport_api_http_reverse_proxy.conf
===================================================================
--- gnunet/src/transport/test_transport_api_http_reverse_proxy.conf
2012-08-21 11:05:44 UTC (rev 23337)
+++ gnunet/src/transport/test_transport_api_http_reverse_proxy.conf
2012-08-21 11:15:10 UTC (rev 23338)
@@ -1,7 +1,7 @@
address@hidden@ template_cfg_peer1.conf
+INLINE@ template_cfg_peer1.conf
[PATHS]
SERVICEHOME = /tmp/test-transport/api-http-p1/
-DEFAULTCONFIG = test_transport_api_http_peer1.conf
+DEFAULTCONFIG = test_transport_api_http_reverse_proxy.conf
[transport-http]
PORT = 12080
@@ -30,6 +30,6 @@
PLUGINS = http
#BINARY = .libs/gnunet-service-transport
UNIXPATH = /tmp/gnunet-p1-service-transport.sock
-#PREFIX = valgrind --leak-check=full
+PREFIX = valgrind --leak-check=full
#PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r23338 - gnunet/src/transport,
gnunet <=