*/
#if BUILD_HTTPS
+#define PLUGIN_NAME "https_client"
#define LIBGNUNET_PLUGIN_TRANSPORT_INIT libgnunet_plugin_transport_https_client_init
#define LIBGNUNET_PLUGIN_TRANSPORT_DONE libgnunet_plugin_transport_https_client_done
#else
+#define PLUGIN_NAME "http_client"
#define LIBGNUNET_PLUGIN_TRANSPORT_INIT libgnunet_plugin_transport_http_client_init
#define LIBGNUNET_PLUGIN_TRANSPORT_DONE libgnunet_plugin_transport_http_client_done
#endif
atsi.type = htonl (GNUNET_ATS_NETWORK_TYPE);
atsi.value = s->ats_address_network_type;
GNUNET_break (s->ats_address_network_type != ntohl (GNUNET_ATS_NET_UNSPECIFIED));
-
delay = s->plugin->env->receive (plugin->env->cls, &s->target, message,
s, (const char *) s->addr, s->addrlen);
if (HTTP_OPTIONS_VERIFY_CERTIFICATE ==
(ntohl (s->addr->options) & HTTP_OPTIONS_VERIFY_CERTIFICATE))
{
- curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYPEER, 1);
- curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYHOST, 1);
+ curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYPEER, 1L);
+ curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYHOST, 2L);
}
else
{
if (HTTP_OPTIONS_VERIFY_CERTIFICATE ==
(ntohl (s->addr->options) & HTTP_OPTIONS_VERIFY_CERTIFICATE))
{
- curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYPEER, 1);
- curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYHOST, 1);
+ curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYPEER, 1L);
+ curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYHOST, 2L);
}
else
{
}
+/**
+ * Function obtain the network type for a session
+ *
+ * @param cls closure ('struct Plugin*')
+ * @param session the session
+ * @return the network type in HBO or GNUNET_SYSERR
+ */
+static enum GNUNET_ATS_Network_Type
+http_client_get_network (void *cls,
+ struct Session *session)
+{
+ GNUNET_assert (NULL != session);
+ return ntohl (session->ats_address_network_type);
+}
+
+
/**
* Creates a new outbound session the transport service will use to send data to the
* peer
//fprintf (stderr, "Address %s is in %s\n", GNUNET_a2s (sa,salen), GNUNET_ATS_print_network_type(ntohl(ats.value)));
GNUNET_free (sa);
}
+
else if (GNUNET_NO == res)
{
- ats.value = htonl (GNUNET_ATS_COST_WAN);
+ /* Cannot convert to sockaddr -> is external hostname */
+ ats.value = htonl (GNUNET_ATS_NET_WAN);
}
if (GNUNET_ATS_NET_UNSPECIFIED == ntohl(ats.value))
s->put_tmp_disconnected = GNUNET_NO;
client_start_session_timeout (s);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Created new session %p for `%s' address `%s''\n",
+ s,
+ http_common_plugin_address_to_string (NULL, plugin->protocol, s->addr, s->addrlen),
+ GNUNET_i2s (&s->target));
+
/* add new session */
GNUNET_CONTAINER_DLL_insert (plugin->head, plugin->tail, s);
{
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
"Cannot connect to peer `%s' address `%s''\n",
- http_common_plugin_address_to_string (NULL, plugin->name, s->addr, s->addrlen),
+ http_common_plugin_address_to_string (NULL, plugin->protocol, s->addr, s->addrlen),
GNUNET_i2s (&s->target));
client_delete_session (s);
return NULL;
const void *addr,
size_t addrlen)
{
- return http_common_plugin_address_to_string (cls, p->name, addr, addrlen);
+ return http_common_plugin_address_to_string (cls, PLUGIN_NAME, addr, addrlen);
}
/**
api->address_to_string = &http_plugin_address_to_string;
api->string_to_address = &http_common_plugin_string_to_address;
api->address_pretty_printer = &http_common_plugin_address_pretty_printer;
-
+ api->get_network = &http_client_get_network;
#if BUILD_HTTPS
plugin->name = "transport-https_client";