/**
* Address
*/
- void *addr;
-
- /**
- * Address length
- */
- size_t addrlen;
+ struct GNUNET_HELLO_Address *address;
/**
* Unique HTTP/S connection tag for this connection
* 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;
+ struct GNUNET_HELLO_Address *ext_addr;
/**
* Notify transport only about external address
*/
unsigned int external_only;
- /**
- * External address length
- */
- size_t ext_addr_len;
-
/**
* use IPv6
*/
server_reschedule (session->plugin,
session->server_send->mhd_daemon,
GNUNET_YES);
- server_reschedule_session_timeout (session);
}
return bytes_sent;
}
if ((NULL != plugin->ext_addr) &&
GNUNET_YES == (http_common_cmp_addresses (addr, addrlen,
- plugin->ext_addr,
- plugin->ext_addr_len)))
+ plugin->ext_addr->address,
+ plugin->ext_addr->address_length)))
{
/* Checking HTTP_OPTIONS_VERIFY_CERTIFICATE option for external hostname */
if ((ntohl (haddr->options) & HTTP_OPTIONS_VERIFY_CERTIFICATE) !=
GNUNET_SERVER_mst_destroy (s->msg_tk);
s->msg_tk = NULL;
}
- GNUNET_free (s->addr);
+ GNUNET_HELLO_address_free (s->address);
GNUNET_free_non_null (s->server_recv);
GNUNET_free_non_null (s->server_send);
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
return 3;
}
+static void
+http_server_plugin_update_session_timeout (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ struct Session *session)
+{
+ struct HTTP_Server_Plugin *plugin = cls;
+
+ if (GNUNET_NO == server_exist_session (plugin, session))
+ return;
+
+ server_reschedule_session_timeout (session);
+}
+
/**
* Tell MHD that the connection should timeout after @a to seconds.
struct Session *s = NULL;
struct ServerConnection *sc = NULL;
const union MHD_ConnectionInfo *conn_info;
- struct GNUNET_ATS_Information ats;
struct HttpAddress *addr;
- size_t addr_len;
+
+ struct GNUNET_ATS_Information ats;
struct GNUNET_PeerIdentity target;
+ size_t addr_len;
uint32_t tag = 0;
int direction = GNUNET_SYSERR;
unsigned int to;
else
{
/* create new session */
+ addr = NULL;
switch (conn_info->client_addr->sa_family)
{
case (AF_INET):
s = GNUNET_new (struct Session);
memcpy (&s->target, &target, sizeof (struct GNUNET_PeerIdentity));
s->plugin = plugin;
- s->addr = addr;
- s->addrlen = addr_len;
+ s->address = GNUNET_HELLO_address_allocate (&s->target, PLUGIN_NAME,
+ addr, addr_len, GNUNET_HELLO_ADDRESS_INFO_INBOUND);
s->ats_address_network_type = ats.value;
s->next_receive = GNUNET_TIME_UNIT_ZERO_ABS;
s->tag = tag;
http_common_plugin_address_to_string (NULL,
plugin->protocol,
addr, addr_len));
+ GNUNET_free_non_null (addr);
}
sc = GNUNET_new (struct ServerConnection);
if (conn_info->client_addr->sa_family == AF_INET)
if ((NULL != s->server_send) && (NULL != s->server_recv))
{
s->connect_in_progress = GNUNET_NO; /* PUT and GET are connected */
- plugin->env->session_start (NULL, &s->target, PLUGIN_NAME, NULL, 0 ,s, NULL, 0);
+ plugin->env->session_start (NULL, s->address ,s, NULL, 0);
}
if ((NULL == s->server_recv) || (NULL == s->server_send))
atsi.value = s->ats_address_network_type;
GNUNET_break (s->ats_address_network_type != ntohl (GNUNET_ATS_NET_UNSPECIFIED));
-
- delay = plugin->env->receive (plugin->env->cls,
- &s->target,
- message,
- s, NULL, 0);
-
- plugin->env->update_address_metrics (plugin->env->cls,
- &s->target,
- NULL, 0, s, &atsi, 1);
+ delay = plugin->env->receive (plugin->env->cls, s->address, s, message);
+ plugin->env->update_address_metrics (plugin->env->cls, s->address, s, &atsi, 1);
GNUNET_asprintf (&stat_txt, "# bytes received via %s_server", plugin->protocol);
GNUNET_STATISTICS_update (plugin->env->stats,
"Peer `%s' address `%s' next read delayed for %s\n",
GNUNET_i2s (&s->target),
http_common_plugin_address_to_string (NULL,
- plugin->protocol,
- s->addr, s->addrlen),
+ plugin->protocol, s->address->address,
+ s->address->address_length),
GNUNET_STRINGS_relative_time_to_string (delay,
GNUNET_YES));
}
s, sc,
GNUNET_i2s (&s->target),
http_common_plugin_address_to_string (NULL,
- plugin->protocol,
- s->addr,
- s->addrlen));
+ plugin->protocol, s->address->address,
+ s->address->address_length));
sc->connected = GNUNET_YES;
return MHD_YES;
}
s, sc,
GNUNET_i2s (&s->target),
http_common_plugin_address_to_string (NULL,
- plugin->protocol,
- s->addr,
- s->addrlen));
+ plugin->protocol, s->address->address,
+ s->address->address_length));
sc->connected = GNUNET_NO;
/* Sent HTTP/1.1: 200 OK as PUT Response\ */
response = MHD_create_response_from_data (strlen ("Thank you!"),
s, sc,
GNUNET_i2s (&s->target),
http_common_plugin_address_to_string (NULL,
- plugin->protocol,
- s->addr,
- s->addrlen),
+ plugin->protocol, s->address->address,
+ s->address->address_length),
*upload_data_size);
struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
"Peer `%s' connection %p, GET on address `%s' disconnected\n",
GNUNET_i2s (&s->target), s->server_send,
http_common_plugin_address_to_string (NULL,
- plugin->protocol,
- s->addr, s->addrlen));
+ plugin->protocol, s->address->address,
+ s->address->address_length));
s->server_send = NULL;
if (NULL != (s->server_recv))
{
"Peer `%s' connection %p PUT on address `%s' disconnected\n",
GNUNET_i2s (&s->target), s->server_recv,
http_common_plugin_address_to_string (NULL,
- plugin->protocol,
- s->addr, s->addrlen));
+ plugin->protocol, s->address->address,
+ s->address->address_length));
s->server_recv = NULL;
/* Do not terminate session when PUT disconnects
if (NULL != (s->server_send))
"Peer `%s' on address `%s' disconnected\n",
GNUNET_i2s (&s->target),
http_common_plugin_address_to_string (NULL,
- plugin->protocol,
- s->addr, s->addrlen));
+ plugin->protocol, s->address->address,
+ s->address->address_length));
if ((GNUNET_YES == s->session_passed) && (GNUNET_NO == s->session_ended))
{
/* Notify transport immediately that this session is invalid */
s->session_ended = GNUNET_YES;
- plugin->env->session_end (plugin->env->cls, &s->target, s);
+ plugin->env->session_end (plugin->env->cls, s->address, s);
}
server_delete_session (plugin, s);
}
"No usable TLS certificate found, creating certificate\n");
errno = 0;
cert_creation =
- GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL,
+ GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+ NULL, NULL, NULL,
"gnunet-transport-certificate-creation",
"gnunet-transport-certificate-creation",
key_file, cert_file, NULL);
socklen_t addrlen)
{
struct HTTP_Server_Plugin *plugin = cls;
+ struct GNUNET_HELLO_Address *address;
struct HttpAddressWrapper *w = NULL;
- w = GNUNET_malloc (sizeof (struct HttpAddressWrapper));
+ w = GNUNET_new (struct HttpAddressWrapper);
w->address = http_common_address_from_socket (plugin->protocol, addr, addrlen);
if (NULL == w->address)
{
http_common_plugin_address_to_string (NULL,
plugin->protocol,
w->address, w->addrlen));
+ /* modify our published address list */
#if BUILD_HTTPS
- plugin->env->notify_address (plugin->env->cls, add_remove, w->address, w->addrlen, "https_client");
+ address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
+ "https_client", w->address, w->addrlen, GNUNET_HELLO_ADDRESS_INFO_NONE);
#else
- plugin->env->notify_address (plugin->env->cls, add_remove, w->address, w->addrlen, "http_client");
+ address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
+ "http_client", w->address, w->addrlen, GNUNET_HELLO_ADDRESS_INFO_NONE);
#endif
+
+ plugin->env->notify_address (plugin->env->cls, add_remove, address);
+ GNUNET_HELLO_address_free (address);
}
socklen_t addrlen)
{
struct HTTP_Server_Plugin *plugin = cls;
+ struct GNUNET_HELLO_Address *address;
struct HttpAddressWrapper *w = plugin->addr_head;
size_t saddr_len;
void * saddr = http_common_address_from_socket (plugin->protocol, addr, addrlen);
http_common_plugin_address_to_string (NULL,
plugin->protocol,
w->address, w->addrlen));
+
+
GNUNET_CONTAINER_DLL_remove (plugin->addr_head, plugin->addr_tail, w);
+
+ /* modify our published address list */
#if BUILD_HTTPS
- plugin->env->notify_address (plugin->env->cls, add_remove, w->address, w->addrlen, "https_client");
+ address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
+ "https_client", w->address, w->addrlen, GNUNET_HELLO_ADDRESS_INFO_NONE);
#else
- plugin->env->notify_address (plugin->env->cls, add_remove, w->address, w->addrlen, "http_client");
+ address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
+ "http_client", w->address, w->addrlen, GNUNET_HELLO_ADDRESS_INFO_NONE);
#endif
+ plugin->env->notify_address (plugin->env->cls, add_remove, address);
+ GNUNET_HELLO_address_free (address);
GNUNET_free (w->address);
GNUNET_free (w);
}
server_notify_external_hostname (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct HTTP_Server_Plugin *plugin = cls;
+ struct HttpAddress *ext_addr;
+ size_t ext_addr_len;
unsigned int urlen;
char *url;
GNUNET_asprintf(&url, "%s://%s", plugin->protocol, plugin->external_hostname);
urlen = strlen (url) + 1;
- plugin->ext_addr = GNUNET_malloc (sizeof (struct HttpAddress) + urlen);
- plugin->ext_addr->options = htonl(plugin->options);
- plugin->ext_addr->urlen = htonl (urlen);
- plugin->ext_addr_len = sizeof (struct HttpAddress) + urlen;
- memcpy (&plugin->ext_addr[1], url, urlen);
+ ext_addr = GNUNET_malloc (sizeof (struct HttpAddress) + urlen);
+ ext_addr->options = htonl(plugin->options);
+ ext_addr->urlen = htonl (urlen);
+ ext_addr_len = sizeof (struct HttpAddress) + urlen;
+ memcpy (&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->external_hostname);
#if BUILD_HTTPS
if (GNUNET_YES == plugin->verify_external_hostname)
- GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, plugin->name,
- "Enabling SSL verification for external hostname address `%s'\n", plugin->external_hostname);
- plugin->env->notify_address (plugin->env->cls, GNUNET_YES,
- plugin->ext_addr, plugin->ext_addr_len,
- "https_client");
+ GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, plugin->name,
+ "Enabling SSL verification for external hostname address `%s'\n",
+ plugin->external_hostname);
+ plugin->ext_addr = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
+ "https_client", ext_addr, ext_addr_len, GNUNET_HELLO_ADDRESS_INFO_NONE );
+ plugin->env->notify_address (plugin->env->cls, GNUNET_YES, plugin->ext_addr);
+ GNUNET_free (ext_addr);
#else
- plugin->env->notify_address (plugin->env->cls, GNUNET_YES,
- plugin->ext_addr, plugin->ext_addr_len,
- "http_client");
+ plugin->ext_addr = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
+ "http_client", ext_addr, ext_addr_len, GNUNET_HELLO_ADDRESS_INFO_NONE );
+ plugin->env->notify_address (plugin->env->cls, GNUNET_YES, plugin->ext_addr);
+ GNUNET_free (ext_addr);
#endif
}
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Binding %s plugin to specific IPv4 address: `%s'\n",
plugin->protocol, bind4_address);
- plugin->server_addr_v4 = GNUNET_malloc (sizeof (struct sockaddr_in));
+ plugin->server_addr_v4 = GNUNET_new (struct sockaddr_in);
if (1 != inet_pton (AF_INET, bind4_address,
&plugin->server_addr_v4->sin_addr))
{
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Binding %s plugin to specific IPv6 address: `%s'\n",
plugin->protocol, bind6_address);
- plugin->server_addr_v6 = GNUNET_malloc (sizeof (struct sockaddr_in6));
+ plugin->server_addr_v6 = GNUNET_new (struct sockaddr_in6);
if (1 !=
inet_pton (AF_INET6, bind6_address, &plugin->server_addr_v6->sin6_addr))
{
"Notifying transport to remove address `%s'\n",
http_common_plugin_address_to_string (NULL,
plugin->protocol,
- plugin->ext_addr,
- plugin->ext_addr_len));
+ plugin->ext_addr->address,
+ plugin->ext_addr->address_length));
#if BUILD_HTTPS
plugin->env->notify_address (plugin->env->cls,
GNUNET_NO,
- plugin->ext_addr,
- plugin->ext_addr_len,
- "https_client");
+ plugin->ext_addr);
#else
plugin->env->notify_address (plugin->env->cls,
GNUNET_NO,
- plugin->ext_addr,
- plugin->ext_addr_len,
- "http_client");
+ plugin->ext_addr);
#endif
+ GNUNET_HELLO_address_free (plugin->ext_addr);
+ plugin->ext_addr = NULL;
}
/* Stop to report addresses to transport service */
{
/* Notify transport immediately that this session is invalid */
pos->session_ended = GNUNET_YES;
- plugin->env->session_end (plugin->env->cls, &pos->target, pos);
+ plugin->env->session_end (plugin->env->cls, pos->address, pos);
}
server_delete_session (plugin, pos);
}
api->string_to_address = &http_common_plugin_string_to_address;
api->address_pretty_printer = &http_common_plugin_address_pretty_printer;
api->get_network = &http_server_get_network;
-
+ api->update_session_timeout = &http_server_plugin_update_session_timeout;
#if BUILD_HTTPS
plugin->name = "transport-https_server";
plugin->protocol = "https";