diff options
Diffstat (limited to 'src/gns/gnunet-gns-proxy.c')
-rw-r--r-- | src/gns/gnunet-gns-proxy.c | 88 |
1 files changed, 71 insertions, 17 deletions
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index 0d7d83b4b..fcd69599b 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c | |||
@@ -626,6 +626,11 @@ struct Socks5Request | |||
626 | * Did we suspend MHD processing? | 626 | * Did we suspend MHD processing? |
627 | */ | 627 | */ |
628 | int suspended; | 628 | int suspended; |
629 | |||
630 | /** | ||
631 | * Did we pause CURL processing? | ||
632 | */ | ||
633 | int curl_paused; | ||
629 | }; | 634 | }; |
630 | 635 | ||
631 | 636 | ||
@@ -823,7 +828,9 @@ mhd_content_cb (void *cls, | |||
823 | start the download, the IO buffer is still full | 828 | start the download, the IO buffer is still full |
824 | with upload data. */ | 829 | with upload data. */ |
825 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 830 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
826 | "Pausing MHD download, not yet ready for download\n"); | 831 | "Pausing MHD download %s%s, not yet ready for download\n", |
832 | s5r->domain, | ||
833 | s5r->url); | ||
827 | return 0; /* not yet ready for data download */ | 834 | return 0; /* not yet ready for data download */ |
828 | } | 835 | } |
829 | bytes_to_copy = GNUNET_MIN (max, | 836 | bytes_to_copy = GNUNET_MIN (max, |
@@ -832,12 +839,21 @@ mhd_content_cb (void *cls, | |||
832 | (SOCKS5_SOCKET_DOWNLOAD_DONE != s5r->state) ) | 839 | (SOCKS5_SOCKET_DOWNLOAD_DONE != s5r->state) ) |
833 | { | 840 | { |
834 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 841 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
835 | "Pausing MHD download, no data available\n"); | 842 | "Pausing MHD download %s%s, no data available\n", |
843 | s5r->domain, | ||
844 | s5r->url); | ||
836 | if (NULL != s5r->curl) | 845 | if (NULL != s5r->curl) |
837 | { | 846 | { |
838 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 847 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
839 | "Continuing CURL interaction\n"); | 848 | "Continuing CURL interaction for %s%s\n", |
840 | curl_easy_pause (s5r->curl, CURLPAUSE_CONT); | 849 | s5r->domain, |
850 | s5r->url); | ||
851 | if (GNUNET_YES == s5r->curl_paused) | ||
852 | { | ||
853 | s5r->curl_paused = GNUNET_NO; | ||
854 | curl_easy_pause (s5r->curl, | ||
855 | CURLPAUSE_CONT); | ||
856 | } | ||
841 | curl_download_prepare (); | 857 | curl_download_prepare (); |
842 | } | 858 | } |
843 | if (GNUNET_NO == s5r->suspended) | 859 | if (GNUNET_NO == s5r->suspended) |
@@ -851,13 +867,17 @@ mhd_content_cb (void *cls, | |||
851 | (SOCKS5_SOCKET_DOWNLOAD_DONE == s5r->state) ) | 867 | (SOCKS5_SOCKET_DOWNLOAD_DONE == s5r->state) ) |
852 | { | 868 | { |
853 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 869 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
854 | "Completed MHD download\n"); | 870 | "Completed MHD download %s%s\n", |
871 | s5r->domain, | ||
872 | s5r->url); | ||
855 | return MHD_CONTENT_READER_END_OF_STREAM; | 873 | return MHD_CONTENT_READER_END_OF_STREAM; |
856 | } | 874 | } |
857 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 875 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
858 | "Writing %llu/%llu bytes\n", | 876 | "Writing %llu/%llu bytes for %s%s\n", |
859 | (unsigned long long) bytes_to_copy, | 877 | (unsigned long long) bytes_to_copy, |
860 | (unsigned long long) s5r->io_len); | 878 | (unsigned long long) s5r->io_len, |
879 | s5r->domain, | ||
880 | s5r->url); | ||
861 | GNUNET_memcpy (buf, | 881 | GNUNET_memcpy (buf, |
862 | s5r->io_buf, | 882 | s5r->io_buf, |
863 | bytes_to_copy); | 883 | bytes_to_copy); |
@@ -865,10 +885,14 @@ mhd_content_cb (void *cls, | |||
865 | &s5r->io_buf[bytes_to_copy], | 885 | &s5r->io_buf[bytes_to_copy], |
866 | s5r->io_len - bytes_to_copy); | 886 | s5r->io_len - bytes_to_copy); |
867 | s5r->io_len -= bytes_to_copy; | 887 | s5r->io_len -= bytes_to_copy; |
868 | if (NULL != s5r->curl) | 888 | if ( (NULL != s5r->curl) && |
889 | (GNUNET_YES == s5r->curl_paused) ) | ||
869 | { | 890 | { |
870 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 891 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
871 | "Continuing CURL interaction\n"); | 892 | "Continuing CURL interaction for %s%s\n", |
893 | s5r->domain, | ||
894 | s5r->url); | ||
895 | s5r->curl_paused = GNUNET_NO; | ||
872 | curl_easy_pause (s5r->curl, | 896 | curl_easy_pause (s5r->curl, |
873 | CURLPAUSE_CONT); | 897 | CURLPAUSE_CONT); |
874 | } | 898 | } |
@@ -1269,6 +1293,7 @@ create_mhd_response_from_s5r (struct Socks5Request *s5r) | |||
1269 | return GNUNET_OK; | 1293 | return GNUNET_OK; |
1270 | } | 1294 | } |
1271 | 1295 | ||
1296 | |||
1272 | /** | 1297 | /** |
1273 | * Handle response payload data from cURL. Copies it into our `io_buf` to make | 1298 | * Handle response payload data from cURL. Copies it into our `io_buf` to make |
1274 | * it available to MHD. | 1299 | * it available to MHD. |
@@ -1288,6 +1313,12 @@ curl_download_cb (void *ptr, | |||
1288 | struct Socks5Request *s5r = ctx; | 1313 | struct Socks5Request *s5r = ctx; |
1289 | size_t total = size * nmemb; | 1314 | size_t total = size * nmemb; |
1290 | 1315 | ||
1316 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1317 | "Receiving %ux%u bytes for `%s%s' from cURL\n", | ||
1318 | (unsigned int) size, | ||
1319 | (unsigned int) nmemb, | ||
1320 | s5r->domain, | ||
1321 | s5r->url); | ||
1291 | if (NULL == s5r->response) | 1322 | if (NULL == s5r->response) |
1292 | GNUNET_assert (GNUNET_OK == | 1323 | GNUNET_assert (GNUNET_OK == |
1293 | create_mhd_response_from_s5r (s5r)); | 1324 | create_mhd_response_from_s5r (s5r)); |
@@ -1302,6 +1333,7 @@ curl_download_cb (void *ptr, | |||
1302 | "Pausing CURL download `%s%s', waiting for UPLOAD to finish\n", | 1333 | "Pausing CURL download `%s%s', waiting for UPLOAD to finish\n", |
1303 | s5r->domain, | 1334 | s5r->domain, |
1304 | s5r->url); | 1335 | s5r->url); |
1336 | s5r->curl_paused = GNUNET_YES; | ||
1305 | return CURL_WRITEFUNC_PAUSE; /* not yet ready for data download */ | 1337 | return CURL_WRITEFUNC_PAUSE; /* not yet ready for data download */ |
1306 | } | 1338 | } |
1307 | if (sizeof (s5r->io_buf) - s5r->io_len < total) | 1339 | if (sizeof (s5r->io_buf) - s5r->io_len < total) |
@@ -1313,6 +1345,7 @@ curl_download_cb (void *ptr, | |||
1313 | (unsigned long long) sizeof (s5r->io_buf), | 1345 | (unsigned long long) sizeof (s5r->io_buf), |
1314 | (unsigned long long) s5r->io_len, | 1346 | (unsigned long long) s5r->io_len, |
1315 | (unsigned long long) total); | 1347 | (unsigned long long) total); |
1348 | s5r->curl_paused = GNUNET_YES; | ||
1316 | return CURL_WRITEFUNC_PAUSE; /* not enough space */ | 1349 | return CURL_WRITEFUNC_PAUSE; /* not enough space */ |
1317 | } | 1350 | } |
1318 | GNUNET_memcpy (&s5r->io_buf[s5r->io_len], | 1351 | GNUNET_memcpy (&s5r->io_buf[s5r->io_len], |
@@ -1381,7 +1414,9 @@ curl_upload_cb (void *buf, | |||
1381 | } | 1414 | } |
1382 | to_copy = GNUNET_MIN (s5r->io_len, | 1415 | to_copy = GNUNET_MIN (s5r->io_len, |
1383 | len); | 1416 | len); |
1384 | GNUNET_memcpy (buf, s5r->io_buf, to_copy); | 1417 | GNUNET_memcpy (buf, |
1418 | s5r->io_buf, | ||
1419 | to_copy); | ||
1385 | memmove (s5r->io_buf, | 1420 | memmove (s5r->io_buf, |
1386 | &s5r->io_buf[to_copy], | 1421 | &s5r->io_buf[to_copy], |
1387 | s5r->io_len - to_copy); | 1422 | s5r->io_len - to_copy); |
@@ -1495,6 +1530,9 @@ curl_task_download (void *cls) | |||
1495 | running = 0; | 1530 | running = 0; |
1496 | mret = curl_multi_perform (curl_multi, | 1531 | mret = curl_multi_perform (curl_multi, |
1497 | &running); | 1532 | &running); |
1533 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1534 | "Checking CURL multi status: %d\n", | ||
1535 | mret); | ||
1498 | while (NULL != (msg = curl_multi_info_read (curl_multi, | 1536 | while (NULL != (msg = curl_multi_info_read (curl_multi, |
1499 | &msgnum))) | 1537 | &msgnum))) |
1500 | { | 1538 | { |
@@ -1527,7 +1565,12 @@ curl_task_download (void *cls) | |||
1527 | GNUNET_assert (GNUNET_OK == | 1565 | GNUNET_assert (GNUNET_OK == |
1528 | create_mhd_response_from_s5r (s5r)); | 1566 | create_mhd_response_from_s5r (s5r)); |
1529 | } | 1567 | } |
1530 | s5r->state = SOCKS5_SOCKET_DOWNLOAD_DONE; | 1568 | s5r->state = SOCKS5_SOCKET_DOWNLOAD_DONE; |
1569 | if (GNUNET_YES == s5r->suspended) | ||
1570 | { | ||
1571 | MHD_resume_connection (s5r->con); | ||
1572 | s5r->suspended = GNUNET_NO; | ||
1573 | } | ||
1531 | run_mhd_now (s5r->hd); | 1574 | run_mhd_now (s5r->hd); |
1532 | break; | 1575 | break; |
1533 | default: | 1576 | default: |
@@ -1538,6 +1581,11 @@ curl_task_download (void *cls) | |||
1538 | curl_easy_strerror (msg->data.result)); | 1581 | curl_easy_strerror (msg->data.result)); |
1539 | /* FIXME: indicate error somehow? close MHD connection badly as well? */ | 1582 | /* FIXME: indicate error somehow? close MHD connection badly as well? */ |
1540 | s5r->state = SOCKS5_SOCKET_DOWNLOAD_DONE; | 1583 | s5r->state = SOCKS5_SOCKET_DOWNLOAD_DONE; |
1584 | if (GNUNET_YES == s5r->suspended) | ||
1585 | { | ||
1586 | MHD_resume_connection (s5r->con); | ||
1587 | s5r->suspended = GNUNET_NO; | ||
1588 | } | ||
1541 | run_mhd_now (s5r->hd); | 1589 | run_mhd_now (s5r->hd); |
1542 | break; | 1590 | break; |
1543 | } | 1591 | } |
@@ -1737,7 +1785,7 @@ create_response (void *cls, | |||
1737 | curl_easy_setopt (s5r->curl, CURLOPT_TIMEOUT, 600L); | 1785 | curl_easy_setopt (s5r->curl, CURLOPT_TIMEOUT, 600L); |
1738 | curl_easy_setopt (s5r->curl, CURLOPT_NOSIGNAL, 1L); | 1786 | curl_easy_setopt (s5r->curl, CURLOPT_NOSIGNAL, 1L); |
1739 | curl_easy_setopt (s5r->curl, CURLOPT_HTTP_CONTENT_DECODING, 0); | 1787 | curl_easy_setopt (s5r->curl, CURLOPT_HTTP_CONTENT_DECODING, 0); |
1740 | curl_easy_setopt (s5r->curl, CURLOPT_HTTP_TRANSFER_DECODING, 0); | 1788 | // curl_easy_setopt (s5r->curl, CURLOPT_HTTP_TRANSFER_DECODING, 0); |
1741 | curl_easy_setopt (s5r->curl, CURLOPT_NOSIGNAL, 1L); | 1789 | curl_easy_setopt (s5r->curl, CURLOPT_NOSIGNAL, 1L); |
1742 | curl_easy_setopt (s5r->curl, CURLOPT_PRIVATE, s5r); | 1790 | curl_easy_setopt (s5r->curl, CURLOPT_PRIVATE, s5r); |
1743 | curl_easy_setopt (s5r->curl, CURLOPT_VERBOSE, 0L); | 1791 | curl_easy_setopt (s5r->curl, CURLOPT_VERBOSE, 0L); |
@@ -1941,8 +1989,12 @@ create_response (void *cls, | |||
1941 | s5r->io_len += left; | 1989 | s5r->io_len += left; |
1942 | *upload_data_size -= left; | 1990 | *upload_data_size -= left; |
1943 | GNUNET_assert (NULL != s5r->curl); | 1991 | GNUNET_assert (NULL != s5r->curl); |
1944 | curl_easy_pause (s5r->curl, | 1992 | if (GNUNET_YES == s5r->curl_paused) |
1945 | CURLPAUSE_CONT); | 1993 | { |
1994 | s5r->curl_paused = GNUNET_NO; | ||
1995 | curl_easy_pause (s5r->curl, | ||
1996 | CURLPAUSE_CONT); | ||
1997 | } | ||
1946 | return MHD_YES; | 1998 | return MHD_YES; |
1947 | } | 1999 | } |
1948 | if (SOCKS5_SOCKET_UPLOAD_STARTED == s5r->state) | 2000 | if (SOCKS5_SOCKET_UPLOAD_STARTED == s5r->state) |
@@ -2442,9 +2494,11 @@ generate_gns_certificate (const char *name) | |||
2442 | etime = mktime (tm_data); | 2494 | etime = mktime (tm_data); |
2443 | gnutls_x509_crt_set_expiration_time (request, | 2495 | gnutls_x509_crt_set_expiration_time (request, |
2444 | etime); | 2496 | etime); |
2445 | gnutls_x509_crt_sign (request, | 2497 | gnutls_x509_crt_sign2 (request, |
2446 | proxy_ca.cert, | 2498 | proxy_ca.cert, |
2447 | proxy_ca.key); | 2499 | proxy_ca.key, |
2500 | GNUTLS_DIG_SHA512, | ||
2501 | 0); | ||
2448 | key_buf_size = sizeof (pgc->key); | 2502 | key_buf_size = sizeof (pgc->key); |
2449 | cert_buf_size = sizeof (pgc->cert); | 2503 | cert_buf_size = sizeof (pgc->cert); |
2450 | gnutls_x509_crt_export (request, GNUTLS_X509_FMT_PEM, | 2504 | gnutls_x509_crt_export (request, GNUTLS_X509_FMT_PEM, |