aboutsummaryrefslogtreecommitdiff
path: root/src/hostlist
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-04-14 09:23:07 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-04-14 09:23:07 +0000
commitf0b98be855c4941ca246d3d13622e0d192e30eba (patch)
tree1ad382af54846ed622a3286e0f48c4d287cde48c /src/hostlist
parent9f81887ff049bf44f210114fa5976941d148b142 (diff)
downloadgnunet-f0b98be855c4941ca246d3d13622e0d192e30eba.tar.gz
gnunet-f0b98be855c4941ca246d3d13622e0d192e30eba.zip
extended proxy support for hostlist
Diffstat (limited to 'src/hostlist')
-rw-r--r--src/hostlist/hostlist-client.c94
-rw-r--r--src/hostlist/hostlist.conf14
2 files changed, 101 insertions, 7 deletions
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,11 +116,26 @@ static struct GNUNET_STATISTICS_Handle *stats;
116static struct GNUNET_TRANSPORT_Handle *transport; 116static struct GNUNET_TRANSPORT_Handle *transport;
117 117
118/** 118/**
119 * Proxy that we are using (can be NULL). 119 * Proxy hostname or ip we are using (can be NULL).
120 */ 120 */
121static char *proxy; 121static char *proxy;
122 122
123/** 123/**
124 * Proxy username we are using (can be NULL).
125 */
126static char *proxy_username;
127
128/**
129 * Proxy password we are using (can be NULL).
130 */
131static char *proxy_password;
132
133/**
134 * Proxy type we are using (can be NULL).
135 */
136static curl_proxytype proxy_type;
137
138/**
124 * Number of bytes valid in 'download_buffer'. 139 * Number of bytes valid in 'download_buffer'.
125 */ 140 */
126static size_t download_pos; 141static size_t download_pos;
@@ -1435,6 +1450,7 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c,
1435 GNUNET_CORE_MessageCallback *msgh, int learn) 1450 GNUNET_CORE_MessageCallback *msgh, int learn)
1436{ 1451{
1437 char *filename; 1452 char *filename;
1453 char *proxytype_str;
1438 int result; 1454 int result;
1439 1455
1440 GNUNET_assert (NULL != st); 1456 GNUNET_assert (NULL != st);
@@ -1451,10 +1467,73 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c,
1451 } 1467 }
1452 cfg = c; 1468 cfg = c;
1453 stats = st; 1469 stats = st;
1454 if (GNUNET_OK != 1470
1455 GNUNET_CONFIGURATION_get_value_string (cfg, "HOSTLIST", "HTTP-PROXY", 1471 /* Read proxy configuration */
1456 &proxy)) 1472 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg,
1457 proxy = NULL; 1473 "HOSTLIST", "PROXY", &proxy))
1474 {
1475 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1476 "Found proxy host: `%s'\n",
1477 proxy);
1478 /* proxy username */
1479 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg,
1480 "HOSTLIST", "PROXY_USERNAME", &proxy_username))
1481 {
1482 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1483 "Found proxy username name: `%s'\n",
1484 proxy_username);
1485 }
1486
1487 /* proxy password */
1488 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg,
1489 "HOSTLIST", "PROXY_PASSWORD", &proxy_password))
1490 {
1491 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1492 "Found proxy password name: `%s'\n",
1493 proxy_password);
1494 }
1495
1496 /* proxy type */
1497 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg,
1498 "HOSTLIST", "PROXY_TYPE", &proxytype_str))
1499 {
1500 GNUNET_STRINGS_utf8_toupper (proxytype_str, proxytype_str);
1501
1502 if (0 == strcmp(proxytype_str, "HTTP"))
1503 proxy_type = CURLPROXY_HTTP;
1504 else if (0 == strcmp(proxytype_str, "HTTP_1_0"))
1505 proxy_type = CURLPROXY_HTTP_1_0;
1506 else if (0 == strcmp(proxytype_str, "SOCKS4"))
1507 proxy_type = CURLPROXY_SOCKS4;
1508 else if (0 == strcmp(proxytype_str, "SOCKS5"))
1509 proxy_type = CURLPROXY_SOCKS5;
1510 else if (0 == strcmp(proxytype_str, "SOCKS4A"))
1511 proxy_type = CURLPROXY_SOCKS4A;
1512 else if (0 == strcmp(proxytype_str, "SOCKS5_HOSTNAME "))
1513 proxy_type = CURLPROXY_SOCKS5_HOSTNAME ;
1514 else
1515 {
1516 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1517 _("Invalid proxy type: `%s', disabling proxy! Check configuration!\n"),
1518 proxytype_str);
1519 GNUNET_free (proxytype_str);
1520
1521 GNUNET_free (proxy);
1522 proxy = NULL;
1523 GNUNET_free_non_null (proxy_username);
1524 proxy_username = NULL;
1525 GNUNET_free_non_null (proxy_password);
1526 proxy_password = NULL;
1527
1528 return GNUNET_SYSERR;
1529 }
1530
1531 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1532 "Found proxy type: `%s'\n", proxy_type);
1533 }
1534 GNUNET_free_non_null (proxytype_str);
1535 }
1536
1458 stat_learning = learn; 1537 stat_learning = learn;
1459 *ch = &handler_connect; 1538 *ch = &handler_connect;
1460 *dh = &handler_disconnect; 1539 *dh = &handler_disconnect;
@@ -1559,6 +1638,11 @@ GNUNET_HOSTLIST_client_stop ()
1559 } 1638 }
1560 GNUNET_free_non_null (proxy); 1639 GNUNET_free_non_null (proxy);
1561 proxy = NULL; 1640 proxy = NULL;
1641 GNUNET_free_non_null (proxy_username);
1642 proxy_username = NULL;
1643 GNUNET_free_non_null (proxy_password);
1644 proxy_password = NULL;
1645
1562 cfg = NULL; 1646 cfg = NULL;
1563} 1647}
1564 1648
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
12OPTIONS = -b 12OPTIONS = -b
13SERVERS = http://v10.gnunet.org/hostlist 13SERVERS = http://v10.gnunet.org/hostlist
14# http://ioerror.gnunet.org:65535/ 14# http://ioerror.gnunet.org:65535/
15# proxy for downloading hostlists
16HTTP-PROXY =
17# bind hostlist http server to a specific IPv4 or IPv6 15# bind hostlist http server to a specific IPv4 or IPv6
18# BINDTOIP = 16# BINDTOIP =
19 17
18# Hostname or IP of proxy server for downloading hostlists
19# PROXY =
20
21# User name for proxy server
22# PROXY_USERNAME =
23# User password for proxy server
24# PROXY_PASSWORD =
25
26# Type of proxy server,
27# Valid values: HTTP, HTTP_1_0, SOCKS4, SOCKS5, SOCKS4A, SOCKS5_HOSTNAME
28# Default: HTTP
29# PROXY_TYPE = HTTP