From: Matthias Wachs Date: Mon, 14 Apr 2014 09:23:07 +0000 (+0000) Subject: extended proxy support for hostlist X-Git-Tag: initial-import-from-subversion-38251~4210 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f0b98be855c4941ca246d3d13622e0d192e30eba;p=oweals%2Fgnunet.git extended proxy support for hostlist --- diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index 8271ecc0c..d556c846f 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c @@ -116,10 +116,25 @@ static struct GNUNET_STATISTICS_Handle *stats; static struct GNUNET_TRANSPORT_Handle *transport; /** - * Proxy that we are using (can be NULL). + * Proxy hostname or ip we are using (can be NULL). */ static char *proxy; +/** + * Proxy username we are using (can be NULL). + */ +static char *proxy_username; + +/** + * Proxy password we are using (can be NULL). + */ +static char *proxy_password; + +/** + * Proxy type we are using (can be NULL). + */ +static curl_proxytype proxy_type; + /** * Number of bytes valid in 'download_buffer'. */ @@ -1435,6 +1450,7 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, GNUNET_CORE_MessageCallback *msgh, int learn) { char *filename; + char *proxytype_str; int result; GNUNET_assert (NULL != st); @@ -1451,10 +1467,73 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, } cfg = c; stats = st; - if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, "HOSTLIST", "HTTP-PROXY", - &proxy)) - proxy = NULL; + + /* Read proxy configuration */ + if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, + "HOSTLIST", "PROXY", &proxy)) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Found proxy host: `%s'\n", + proxy); + /* proxy username */ + if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, + "HOSTLIST", "PROXY_USERNAME", &proxy_username)) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Found proxy username name: `%s'\n", + proxy_username); + } + + /* proxy password */ + if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, + "HOSTLIST", "PROXY_PASSWORD", &proxy_password)) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Found proxy password name: `%s'\n", + proxy_password); + } + + /* proxy type */ + if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, + "HOSTLIST", "PROXY_TYPE", &proxytype_str)) + { + GNUNET_STRINGS_utf8_toupper (proxytype_str, proxytype_str); + + if (0 == strcmp(proxytype_str, "HTTP")) + proxy_type = CURLPROXY_HTTP; + else if (0 == strcmp(proxytype_str, "HTTP_1_0")) + proxy_type = CURLPROXY_HTTP_1_0; + else if (0 == strcmp(proxytype_str, "SOCKS4")) + proxy_type = CURLPROXY_SOCKS4; + else if (0 == strcmp(proxytype_str, "SOCKS5")) + proxy_type = CURLPROXY_SOCKS5; + else if (0 == strcmp(proxytype_str, "SOCKS4A")) + proxy_type = CURLPROXY_SOCKS4A; + else if (0 == strcmp(proxytype_str, "SOCKS5_HOSTNAME ")) + proxy_type = CURLPROXY_SOCKS5_HOSTNAME ; + else + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Invalid proxy type: `%s', disabling proxy! Check configuration!\n"), + proxytype_str); + GNUNET_free (proxytype_str); + + GNUNET_free (proxy); + proxy = NULL; + GNUNET_free_non_null (proxy_username); + proxy_username = NULL; + GNUNET_free_non_null (proxy_password); + proxy_password = NULL; + + return GNUNET_SYSERR; + } + + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Found proxy type: `%s'\n", proxy_type); + } + GNUNET_free_non_null (proxytype_str); + } + stat_learning = learn; *ch = &handler_connect; *dh = &handler_disconnect; @@ -1559,6 +1638,11 @@ GNUNET_HOSTLIST_client_stop () } GNUNET_free_non_null (proxy); proxy = NULL; + GNUNET_free_non_null (proxy_username); + proxy_username = NULL; + GNUNET_free_non_null (proxy_password); + proxy_password = NULL; + cfg = NULL; } diff --git a/src/hostlist/hostlist.conf b/src/hostlist/hostlist.conf index c57a77f28..f3474b14c 100644 --- a/src/hostlist/hostlist.conf +++ b/src/hostlist/hostlist.conf @@ -12,8 +12,18 @@ BINARY = gnunet-daemon-hostlist OPTIONS = -b SERVERS = http://v10.gnunet.org/hostlist # http://ioerror.gnunet.org:65535/ -# proxy for downloading hostlists -HTTP-PROXY = # bind hostlist http server to a specific IPv4 or IPv6 # BINDTOIP = +# Hostname or IP of proxy server for downloading hostlists +# PROXY = + +# User name for proxy server +# PROXY_USERNAME = +# User password for proxy server +# PROXY_PASSWORD = + +# Type of proxy server, +# Valid values: HTTP, HTTP_1_0, SOCKS4, SOCKS5, SOCKS4A, SOCKS5_HOSTNAME +# Default: HTTP +# PROXY_TYPE = HTTP