From: Schanzenbach, Martin Date: Sat, 23 Jun 2018 14:42:36 +0000 (+0200) Subject: attempt to fix OPTIONS X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2f726a9edd6e3a0cdef639a3e7836eb498d0b30c;p=oweals%2Fgnunet.git attempt to fix OPTIONS --- diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index 9c3c78b76..52291bff0 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c @@ -2026,34 +2026,41 @@ create_response (void *cls, curl_easy_setopt (s5r->curl, CURLOPT_CUSTOMREQUEST, "OPTIONS"); + curl_easy_setopt (s5r->curl, + CURLOPT_WRITEFUNCTION, + &curl_download_cb); + curl_easy_setopt (s5r->curl, + CURLOPT_WRITEDATA, + s5r); + } else if (0 == strcasecmp (meth, - MHD_HTTP_METHOD_GET)) + MHD_HTTP_METHOD_GET)) { s5r->state = SOCKS5_SOCKET_DOWNLOAD_STARTED; curl_easy_setopt (s5r->curl, - CURLOPT_HTTPGET, - 1L); + CURLOPT_HTTPGET, + 1L); curl_easy_setopt (s5r->curl, - CURLOPT_WRITEFUNCTION, - &curl_download_cb); + CURLOPT_WRITEFUNCTION, + &curl_download_cb); curl_easy_setopt (s5r->curl, - CURLOPT_WRITEDATA, - s5r); + CURLOPT_WRITEDATA, + s5r); } else if (0 == strcasecmp (meth, - MHD_HTTP_METHOD_DELETE)) + MHD_HTTP_METHOD_DELETE)) { s5r->state = SOCKS5_SOCKET_DOWNLOAD_STARTED; curl_easy_setopt (s5r->curl, - CURLOPT_CUSTOMREQUEST, - "DELETE"); + CURLOPT_CUSTOMREQUEST, + "DELETE"); curl_easy_setopt (s5r->curl, - CURLOPT_WRITEFUNCTION, - &curl_download_cb); + CURLOPT_WRITEFUNCTION, + &curl_download_cb); curl_easy_setopt (s5r->curl, - CURLOPT_WRITEDATA, - s5r); + CURLOPT_WRITEDATA, + s5r); } else { @@ -2068,46 +2075,46 @@ create_response (void *cls, if (0 == strcasecmp (ver, MHD_HTTP_VERSION_1_0)) { curl_easy_setopt (s5r->curl, - CURLOPT_HTTP_VERSION, - CURL_HTTP_VERSION_1_0); + CURLOPT_HTTP_VERSION, + CURL_HTTP_VERSION_1_0); } else if (0 == strcasecmp (ver, MHD_HTTP_VERSION_1_1)) { curl_easy_setopt (s5r->curl, - CURLOPT_HTTP_VERSION, - CURL_HTTP_VERSION_1_1); + CURLOPT_HTTP_VERSION, + CURL_HTTP_VERSION_1_1); } else { curl_easy_setopt (s5r->curl, - CURLOPT_HTTP_VERSION, - CURL_HTTP_VERSION_NONE); + CURLOPT_HTTP_VERSION, + CURL_HTTP_VERSION_NONE); } if (HTTPS_PORT == s5r->port) { curl_easy_setopt (s5r->curl, - CURLOPT_USE_SSL, - CURLUSESSL_ALL); + CURLOPT_USE_SSL, + CURLUSESSL_ALL); if (NULL != s5r->dane_data) curl_easy_setopt (s5r->curl, - CURLOPT_SSL_VERIFYPEER, - 0L); + CURLOPT_SSL_VERIFYPEER, + 0L); else curl_easy_setopt (s5r->curl, - CURLOPT_SSL_VERIFYPEER, - 1L); + CURLOPT_SSL_VERIFYPEER, + 1L); /* Disable cURL checking the hostname, as we will check ourselves as only we have the domain name or the LEHO or the DANE record */ curl_easy_setopt (s5r->curl, - CURLOPT_SSL_VERIFYHOST, - 0L); + CURLOPT_SSL_VERIFYHOST, + 0L); } else { curl_easy_setopt (s5r->curl, - CURLOPT_USE_SSL, - CURLUSESSL_NONE); + CURLOPT_USE_SSL, + CURLUSESSL_NONE); } if (CURLM_OK != @@ -2135,14 +2142,14 @@ create_response (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing %u bytes UPLOAD\n", - (unsigned int) *upload_data_size); + (unsigned int) *upload_data_size); /* FIXME: This must be set or a header with Transfer-Encoding: chunked. Else * upload callback is not called! */ curl_easy_setopt (s5r->curl, - CURLOPT_POSTFIELDSIZE, - *upload_data_size); + CURLOPT_POSTFIELDSIZE, + *upload_data_size); left = GNUNET_MIN (*upload_data_size, sizeof (s5r->io_buf) - s5r->io_len); @@ -2156,7 +2163,7 @@ create_response (void *cls, { s5r->curl_paused = GNUNET_NO; curl_easy_pause (s5r->curl, - CURLPAUSE_CONT); + CURLPAUSE_CONT); } return MHD_YES; } @@ -2536,9 +2543,9 @@ load_file (const char* filename, if (GNUNET_OK != GNUNET_DISK_file_size (filename, - &fsize, + &fsize, GNUNET_YES, - GNUNET_YES)) + GNUNET_YES)) return NULL; if (fsize > MAX_PEM_SIZE) return NULL; @@ -2571,7 +2578,7 @@ load_key_from_file (gnutls_x509_privkey_t key, int ret; key_data.data = load_file (keyfile, - &key_data.size); + &key_data.size); if (NULL == key_data.data) return GNUNET_SYSERR; ret = gnutls_x509_privkey_import (key, &key_data, @@ -2602,17 +2609,17 @@ load_cert_from_file (gnutls_x509_crt_t crt, int ret; cert_data.data = load_file (certfile, - &cert_data.size); + &cert_data.size); if (NULL == cert_data.data) return GNUNET_SYSERR; ret = gnutls_x509_crt_import (crt, - &cert_data, + &cert_data, GNUTLS_X509_FMT_PEM); if (GNUTLS_E_SUCCESS != ret) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Unable to import certificate from `%s'\n"), - certfile); + certfile); } GNUNET_free_non_null (cert_data.data); return (GNUTLS_E_SUCCESS != ret) ? GNUNET_SYSERR : GNUNET_OK; @@ -2643,26 +2650,26 @@ generate_gns_certificate (const char *name) GNUNET_break (GNUTLS_E_SUCCESS == gnutls_x509_crt_set_key (request, proxy_ca.key)); pgc = GNUNET_new (struct ProxyGNSCertificate); gnutls_x509_crt_set_dn_by_oid (request, - GNUTLS_OID_X520_COUNTRY_NAME, + GNUTLS_OID_X520_COUNTRY_NAME, 0, - "ZZ", - strlen ("ZZ")); + "ZZ", + strlen ("ZZ")); gnutls_x509_crt_set_dn_by_oid (request, - GNUTLS_OID_X520_ORGANIZATION_NAME, + GNUTLS_OID_X520_ORGANIZATION_NAME, 0, - "GNU Name System", - strlen ("GNU Name System")); + "GNU Name System", + strlen ("GNU Name System")); gnutls_x509_crt_set_dn_by_oid (request, - GNUTLS_OID_X520_COMMON_NAME, + GNUTLS_OID_X520_COMMON_NAME, 0, - name, - strlen (name)); + name, + strlen (name)); GNUNET_break (GNUTLS_E_SUCCESS == - gnutls_x509_crt_set_version (request, - 3)); + gnutls_x509_crt_set_version (request, + 3)); gnutls_rnd (GNUTLS_RND_NONCE, - &serial, - sizeof (serial)); + &serial, + sizeof (serial)); gnutls_x509_crt_set_serial (request, &serial, sizeof (serial)); @@ -2677,20 +2684,20 @@ generate_gns_certificate (const char *name) gnutls_x509_crt_set_expiration_time (request, etime); gnutls_x509_crt_sign2 (request, - proxy_ca.cert, - proxy_ca.key, - GNUTLS_DIG_SHA512, - 0); + proxy_ca.cert, + proxy_ca.key, + GNUTLS_DIG_SHA512, + 0); key_buf_size = sizeof (pgc->key); cert_buf_size = sizeof (pgc->cert); gnutls_x509_crt_export (request, - GNUTLS_X509_FMT_PEM, + GNUTLS_X509_FMT_PEM, pgc->cert, - &cert_buf_size); + &cert_buf_size); gnutls_x509_privkey_export (proxy_ca.key, - GNUTLS_X509_FMT_PEM, + GNUTLS_X509_FMT_PEM, pgc->key, - &key_buf_size); + &key_buf_size); gnutls_x509_crt_deinit (request); return pgc; } @@ -3134,7 +3141,7 @@ do_s5r_read (void *cls) tc = GNUNET_SCHEDULER_get_task_context (); if ( (NULL != tc->read_ready) && (GNUNET_NETWORK_fdset_isset (tc->read_ready, - s5r->sock)) ) + s5r->sock)) ) { rlen = GNUNET_NETWORK_socket_recv (s5r->sock, &s5r->rbuf[s5r->rbuf_len], @@ -3261,7 +3268,7 @@ do_s5r_read (void *cls) *dom_len); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requested connection is to http%s://%s:%d\n", - (HTTPS_PORT == s5r->port) ? "s" : "", + (HTTPS_PORT == s5r->port) ? "s" : "", s5r->domain, ntohs (*port)); s5r->state = SOCKS5_RESOLVING; @@ -3333,21 +3340,21 @@ do_accept (void *cls) ltask4 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, lsock, &do_accept, - lsock); + lsock); else if (lsock == lsock6) ltask6 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, lsock, &do_accept, - lsock); + lsock); else GNUNET_assert (0); s = GNUNET_NETWORK_socket_accept (lsock, - NULL, - NULL); + NULL, + NULL); if (NULL == s) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, - "accept"); + "accept"); return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -3361,7 +3368,7 @@ do_accept (void *cls) s5r->rtask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, s5r->sock, &do_s5r_read, - s5r); + s5r); } @@ -3459,7 +3466,7 @@ bind_v4 () return NULL; if (GNUNET_OK != GNUNET_NETWORK_socket_bind (ls, - (const struct sockaddr *) &sa4, + (const struct sockaddr *) &sa4, sizeof (sa4))) { eno = errno; @@ -3496,7 +3503,7 @@ bind_v6 () return NULL; if (GNUNET_OK != GNUNET_NETWORK_socket_bind (ls, - (const struct sockaddr *) &sa6, + (const struct sockaddr *) &sa6, sizeof (sa6))) { eno = errno; @@ -3551,8 +3558,8 @@ run (void *cls, cafile = cafile_cfg; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Using `%s' as CA\n", - cafile); + "Using `%s' as CA\n", + cafile); gnutls_global_init (); gnutls_x509_crt_init (&proxy_ca.cert); @@ -3692,19 +3699,19 @@ main (int argc, { struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_uint16 ('p', - "port", - NULL, - gettext_noop ("listen on specified port (default: 7777)"), - &port), + "port", + NULL, + gettext_noop ("listen on specified port (default: 7777)"), + &port), GNUNET_GETOPT_option_string ('a', "authority", NULL, gettext_noop ("pem file to use as CA"), &cafile_opt), GNUNET_GETOPT_option_flag ('6', - "disable-ivp6", - gettext_noop ("disable use of IPv6"), - &disable_v6), + "disable-ivp6", + gettext_noop ("disable use of IPv6"), + &disable_v6), GNUNET_GETOPT_OPTION_END }; @@ -3715,7 +3722,7 @@ main (int argc, if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) + &argc, &argv)) return 2; GNUNET_log_setup ("gnunet-gns-proxy", "WARNING",