+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (plugin->env->cfg,
+ plugin->name,
+ "MAX_CONNECTIONS",
+ &max_requests))
+ max_requests = 128;
+ plugin->max_requests = max_requests;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ _("Maximum number of requests is %u\n"),
+ plugin->max_requests);
+
+ /* Read proxy configuration */
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg,
+ plugin->name,
+ "PROXY",
+ &plugin->proxy_hostname))
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Found proxy host: `%s'\n",
+ plugin->proxy_hostname);
+ /* proxy username */
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg,
+ plugin->name,
+ "PROXY_USERNAME",
+ &plugin->proxy_username))
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Found proxy username name: `%s'\n",
+ plugin->proxy_username);
+ }
+
+ /* proxy password */
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg,
+ plugin->name,
+ "PROXY_PASSWORD",
+ &plugin->proxy_password))
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Found proxy password name: `%s'\n",
+ plugin->proxy_password);
+ }
+
+ /* proxy type */
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg,
+ plugin->name,
+ "PROXY_TYPE",
+ &proxy_type))
+ {
+ GNUNET_STRINGS_utf8_toupper (proxy_type, proxy_type);
+
+ if (0 == strcmp(proxy_type, "HTTP"))
+ plugin->proxytype = CURLPROXY_HTTP;
+ else if (0 == strcmp(proxy_type, "SOCKS4"))
+ plugin->proxytype = CURLPROXY_SOCKS4;
+ else if (0 == strcmp(proxy_type, "SOCKS5"))
+ plugin->proxytype = CURLPROXY_SOCKS5;
+ else if (0 == strcmp(proxy_type, "SOCKS4A"))
+ plugin->proxytype = CURLPROXY_SOCKS4A;
+ else if (0 == strcmp(proxy_type, "SOCKS5_HOSTNAME "))
+ plugin->proxytype = CURLPROXY_SOCKS5_HOSTNAME ;
+ else
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ _("Invalid proxy type: `%s', disabling proxy! Check configuration!\n"),
+ proxy_type);
+
+ GNUNET_free (proxy_type);
+ GNUNET_free (plugin->proxy_hostname);
+ plugin->proxy_hostname = NULL;
+ GNUNET_free_non_null (plugin->proxy_username);
+ plugin->proxy_username = NULL;
+ GNUNET_free_non_null (plugin->proxy_password);
+ plugin->proxy_password = NULL;
+
+ return GNUNET_SYSERR;
+ }
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Found proxy type: `%s'\n",
+ proxy_type);
+ }
+
+ /* proxy http tunneling */
+ plugin->proxy_use_httpproxytunnel
+ = GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg,
+ plugin->name,
+ "PROXY_HTTP_TUNNELING");
+ if (GNUNET_SYSERR == plugin->proxy_use_httpproxytunnel)
+ plugin->proxy_use_httpproxytunnel = GNUNET_NO;
+
+ GNUNET_free_non_null (proxy_type);
+ }
+
+ /* Should we emulate an XHR client for testing? */
+ plugin->emulate_xhr
+ = GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg,
+ plugin->name,
+ "EMULATE_XHR");
+ return GNUNET_OK;
+}
+
+
+/**
+ * Function to convert an address to a human-readable string.
+ *
+ * @param cls closure
+ * @param addr address to convert
+ * @param addrlen address length
+ * @return res string if conversion was successful, NULL otherwise
+ */
+static const char *
+http_client_plugin_address_to_string (void *cls,
+ const void *addr,
+ size_t addrlen)
+{
+ return http_common_plugin_address_to_string (PLUGIN_NAME,
+ addr,
+ addrlen);
+}
+
+
+/**
+ * Function that will be called whenever the transport service wants to
+ * notify the plugin that a session is still active and in use and
+ * therefore the session timeout for this session has to be updated
+ *
+ * @param cls closure
+ * @param peer which peer was the session for
+ * @param session which session is being updated
+ */
+static void
+http_client_plugin_update_session_timeout (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ struct GNUNET_ATS_Session *session)
+{
+ client_reschedule_session_timeout (session);
+}
+
+
+/**
+ * Function that will be called whenever the transport service wants to
+ * notify the plugin that the inbound quota changed and that the plugin
+ * should update it's delay for the next receive value
+ *
+ * @param cls closure
+ * @param peer which peer was the session for
+ * @param s which session is being updated
+ * @param delay new delay to use for receiving
+ */
+static void
+http_client_plugin_update_inbound_delay (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ struct GNUNET_ATS_Session *s,
+ struct GNUNET_TIME_Relative delay)
+{
+ s->next_receive = GNUNET_TIME_relative_to_absolute (delay);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "New inbound delay %s\n",
+ GNUNET_STRINGS_relative_time_to_string (delay,
+ GNUNET_NO));
+ if (s->recv_wakeup_task != NULL)
+ {
+ GNUNET_SCHEDULER_cancel (s->recv_wakeup_task);
+ s->recv_wakeup_task
+ = GNUNET_SCHEDULER_add_delayed (delay,
+ &client_wake_up,
+ s);
+ }
+}
+
+
+/**
+ * Return information about the given session to the
+ * monitor callback.
+ *
+ * @param cls the `struct Plugin` with the monitor callback (`sic`)
+ * @param peer peer we send information about
+ * @param value our `struct GNUNET_ATS_Session` to send information about
+ * @return #GNUNET_OK (continue to iterate)
+ */
+static int
+send_session_info_iter (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ void *value)
+{
+ struct HTTP_Client_Plugin *plugin = cls;
+ struct GNUNET_ATS_Session *session = value;
+
+ notify_session_monitor (plugin,
+ session,
+ GNUNET_TRANSPORT_SS_INIT);
+ notify_session_monitor (plugin,
+ session,
+ GNUNET_TRANSPORT_SS_UP); /* FIXME: or handshake? */