aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-07-18 13:32:41 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-07-18 13:32:41 +0000
commitb11529b2bbb5f3e5c4fda5ca8054a89fe1554d1c (patch)
tree174daa55c15a5a8056d7c0de7cc1f249d4189ff0 /src/gns
parentf195d42a6b8e24b8e2f31709b49e2be72e25983f (diff)
downloadgnunet-b11529b2bbb5f3e5c4fda5ca8054a89fe1554d1c.tar.gz
gnunet-b11529b2bbb5f3e5c4fda5ca8054a89fe1554d1c.zip
-fixes, check for mhd version
Diffstat (limited to 'src/gns')
-rw-r--r--src/gns/gnunet-gns-proxy.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c
index 0768f1d78..4681c9d2e 100644
--- a/src/gns/gnunet-gns-proxy.c
+++ b/src/gns/gnunet-gns-proxy.c
@@ -34,6 +34,8 @@
34#include <gnutls/crypto.h> 34#include <gnutls/crypto.h>
35#include <time.h> 35#include <time.h>
36 36
37#define HAVE_MHD_NO_LISTEN_SOCKET MHD_VERSION >= 0x00091401
38
37#define GNUNET_GNS_PROXY_PORT 7777 39#define GNUNET_GNS_PROXY_PORT 7777
38#define MHD_MAX_CONNECTIONS 300 40#define MHD_MAX_CONNECTIONS 300
39#define MAX_HTTP_URI_LENGTH 2048 41#define MAX_HTTP_URI_LENGTH 2048
@@ -1256,6 +1258,9 @@ curl_download_cb (void *ptr, size_t size, size_t nmemb, void* ctx)
1256 "CURL: Got %d. %d free in buffer\n", 1258 "CURL: Got %d. %d free in buffer\n",
1257 total, buf_space); 1259 total, buf_space);
1258 1260
1261 if (BUF_WAIT_FOR_CURL != ctask->buf_status)
1262 return CURL_WRITEFUNC_PAUSE;
1263
1259 if (total > (buf_space - CURL_BUF_PADDING)) 1264 if (total > (buf_space - CURL_BUF_PADDING))
1260 { 1265 {
1261 if (ctask->buf_status == BUF_WAIT_FOR_CURL) 1266 if (ctask->buf_status == BUF_WAIT_FOR_CURL)
@@ -1442,8 +1447,8 @@ curl_task_download (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1442 { 1447 {
1443 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1448 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1444 "Shutdown requested while trying to download\n"); 1449 "Shutdown requested while trying to download\n");
1445 //TODO cleanup 1450 //TODO cleanup
1446 return; 1451 return;
1447 } 1452 }
1448 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1453 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1449 "Ready to dl\n"); 1454 "Ready to dl\n");
@@ -1529,10 +1534,7 @@ curl_task_download (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1529 if (NULL == ctask->curl) 1534 if (NULL == ctask->curl)
1530 continue; 1535 continue;
1531 1536
1532 if (memcmp (msg->easy_handle, ctask->curl, sizeof (CURL)) != 0) 1537 if (0 != memcmp (msg->easy_handle, ctask->curl, sizeof (CURL)))
1533 continue;
1534
1535 if (ctask->buf_status != BUF_WAIT_FOR_CURL)
1536 continue; 1538 continue;
1537 1539
1538 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1540 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1826,7 +1828,10 @@ create_response (void *cls,
1826 ctask->buffer_read_ptr = ctask->buffer; 1828 ctask->buffer_read_ptr = ctask->buffer;
1827 ctask->buffer_write_ptr = ctask->buffer; 1829 ctask->buffer_write_ptr = ctask->buffer;
1828 ctask->pp_task = GNUNET_SCHEDULER_NO_TASK; 1830 ctask->pp_task = GNUNET_SCHEDULER_NO_TASK;
1829 ctask->port = HTTP_PORT; 1831 if (ctask->mhd->is_ssl)
1832 ctask->port = HTTPS_PORT;
1833 else
1834 ctask->port = HTTP_PORT;
1830 1835
1831 MHD_get_connection_values (con, 1836 MHD_get_connection_values (con,
1832 MHD_HEADER_KIND, 1837 MHD_HEADER_KIND,
@@ -2487,13 +2492,15 @@ add_handle_to_ssl_mhd (struct GNUNET_NETWORK_Handle *h, const char* domain)
2487 domain); 2492 domain);
2488 hd->daemon = MHD_start_daemon (MHD_USE_DEBUG 2493 hd->daemon = MHD_start_daemon (MHD_USE_DEBUG
2489 | MHD_USE_SSL 2494 | MHD_USE_SSL
2490#if MHD_USE_NO_LISTEN_SOCKET 2495#if HAVE_MHD_NO_LISTEN_SOCKET
2491 | MHD_USE_NO_LISTEN_SOCKET, 2496 | MHD_USE_NO_LISTEN_SOCKET,
2497 0,
2498#else
2499 , 4444, //Dummy
2492#endif 2500#endif
2493 , 4444,
2494 &accept_cb, NULL, 2501 &accept_cb, NULL,
2495 &create_response, hd, 2502 &create_response, hd,
2496#ifndef MHD_USE_NO_LISTEN_SOCKET 2503#if !HAVE_MHD_NO_LISTEN_SOCKET
2497 MHD_OPTION_LISTEN_SOCKET, GNUNET_NETWORK_get_fd (mhd_unix_socket), 2504 MHD_OPTION_LISTEN_SOCKET, GNUNET_NETWORK_get_fd (mhd_unix_socket),
2498#endif 2505#endif
2499 MHD_OPTION_CONNECTION_LIMIT, 2506 MHD_OPTION_CONNECTION_LIMIT,
@@ -3095,11 +3102,13 @@ run (void *cls, char *const *args, const char *cfgfile,
3095{ 3102{
3096 struct sockaddr_in sa; 3103 struct sockaddr_in sa;
3097 struct MhdHttpList *hd; 3104 struct MhdHttpList *hd;
3098 struct sockaddr_un mhd_unix_sock_addr;
3099 size_t len;
3100 char* proxy_sockfile;
3101 char* cafile_cfg = NULL; 3105 char* cafile_cfg = NULL;
3102 char* cafile; 3106 char* cafile;
3107#if !HAVE_MHD_NO_LISTEN_SOCKET
3108 size_t len;
3109 char* proxy_sockfile;
3110 struct sockaddr_un mhd_unix_sock_addr;
3111#endif
3103 3112
3104 curl_multi = curl_multi_init (); 3113 curl_multi = curl_multi_init ();
3105 3114
@@ -3216,7 +3225,7 @@ run (void *cls, char *const *args, const char *cfgfile,
3216 mhd_httpd_head = NULL; 3225 mhd_httpd_head = NULL;
3217 mhd_httpd_tail = NULL; 3226 mhd_httpd_tail = NULL;
3218 total_mhd_connections = 0; 3227 total_mhd_connections = 0;
3219 3228#ifndef HAVE_MHD_NO_LISTEN_SOCKET
3220 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns-proxy", 3229 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns-proxy",
3221 "PROXY_UNIXPATH", 3230 "PROXY_UNIXPATH",
3222 &proxy_sockfile)) 3231 &proxy_sockfile))
@@ -3226,7 +3235,6 @@ run (void *cls, char *const *args, const char *cfgfile,
3226 return; 3235 return;
3227 } 3236 }
3228 3237
3229#ifndef MHD_USE_NO_LISTEN_SOCKET
3230 mhd_unix_socket = GNUNET_NETWORK_socket_create (AF_UNIX, 3238 mhd_unix_socket = GNUNET_NETWORK_socket_create (AF_UNIX,
3231 SOCK_STREAM, 3239 SOCK_STREAM,
3232 0); 3240 0);
@@ -3274,13 +3282,15 @@ run (void *cls, char *const *args, const char *cfgfile,
3274 hd->is_ssl = GNUNET_NO; 3282 hd->is_ssl = GNUNET_NO;
3275 strcpy (hd->domain, ""); 3283 strcpy (hd->domain, "");
3276 httpd = MHD_start_daemon (MHD_USE_DEBUG 3284 httpd = MHD_start_daemon (MHD_USE_DEBUG
3277#if MHD_USE_NO_LISTEN_SOCKET 3285#if HAVE_MHD_NO_LISTEN_SOCKET
3278 | MHD_USE_NO_LISTEN_SOCKET, 3286 | MHD_USE_NO_LISTEN_SOCKET,
3279#endif 3287 0,
3288#else
3280 , 4444, //Dummy port 3289 , 4444, //Dummy port
3290#endif
3281 &accept_cb, NULL, 3291 &accept_cb, NULL,
3282 &create_response, hd, 3292 &create_response, hd,
3283#ifndef MHD_USE_NO_LISTEN_SOCKET 3293#if !HAVE_MHD_NO_LISTEN_SOCKET
3284 MHD_OPTION_LISTEN_SOCKET, GNUNET_NETWORK_get_fd (mhd_unix_socket), 3294 MHD_OPTION_LISTEN_SOCKET, GNUNET_NETWORK_get_fd (mhd_unix_socket),
3285#endif 3295#endif
3286 MHD_OPTION_CONNECTION_LIMIT, MHD_MAX_CONNECTIONS, 3296 MHD_OPTION_CONNECTION_LIMIT, MHD_MAX_CONNECTIONS,