summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-06-05 10:00:23 +0200
committerChristian Grothoff <christian@grothoff.org>2018-06-05 10:00:23 +0200
commit1cc9d829c0add9533f1bb7fab59c32a7328086d0 (patch)
tree82bc36b82747dacd38a41b3771c8db8ef1e668ad
parent09f7c260e7cd3bc0f12ad89e2dcf7d813f4089d8 (diff)
code cleanup, fix strlen
-rw-r--r--po/POTFILES.in124
-rw-r--r--src/gns/gnunet-gns-proxy.c313
2 files changed, 293 insertions, 144 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 120e3be78..35a9d6977 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,21 +4,13 @@ src/arm/arm_monitor_api.c
src/arm/gnunet-arm.c
src/arm/gnunet-service-arm.c
src/arm/mockup-service.c
-src/ats-tests/ats-testing-experiment.c
-src/ats-tests/ats-testing-log.c
-src/ats-tests/ats-testing-preferences.c
-src/ats-tests/ats-testing-traffic.c
-src/ats-tests/ats-testing.c
-src/ats-tests/gnunet-ats-sim.c
-src/ats-tests/gnunet-solver-eval.c
-src/ats-tool/gnunet-ats.c
src/ats/ats_api_connectivity.c
src/ats/ats_api_performance.c
src/ats/ats_api_scanner.c
src/ats/ats_api_scheduling.c
src/ats/gnunet-ats-solver-eval.c
-src/ats/gnunet-service-ats.c
src/ats/gnunet-service-ats_addresses.c
+src/ats/gnunet-service-ats.c
src/ats/gnunet-service-ats_connectivity.c
src/ats/gnunet-service-ats_normalization.c
src/ats/gnunet-service-ats_performance.c
@@ -29,6 +21,14 @@ src/ats/gnunet-service-ats_scheduling.c
src/ats/plugin_ats_mlp.c
src/ats/plugin_ats_proportional.c
src/ats/plugin_ats_ril.c
+src/ats-tests/ats-testing.c
+src/ats-tests/ats-testing-experiment.c
+src/ats-tests/ats-testing-log.c
+src/ats-tests/ats-testing-preferences.c
+src/ats-tests/ats-testing-traffic.c
+src/ats-tests/gnunet-ats-sim.c
+src/ats-tests/gnunet-solver-eval.c
+src/ats-tool/gnunet-ats.c
src/auction/gnunet-auction-create.c
src/auction/gnunet-auction-info.c
src/auction/gnunet-auction-join.c
@@ -40,8 +40,8 @@ src/block/plugin_block_test.c
src/cadet/cadet_api.c
src/cadet/cadet_test_lib.c
src/cadet/desirability_table.c
-src/cadet/gnunet-cadet-profiler.c
src/cadet/gnunet-cadet.c
+src/cadet/gnunet-cadet-profiler.c
src/cadet/gnunet-service-cadet.c
src/cadet/gnunet-service-cadet_channel.c
src/cadet/gnunet-service-cadet_connection.c
@@ -57,15 +57,15 @@ src/consensus/gnunet-service-consensus.c
src/consensus/plugin_block_consensus.c
src/conversation/conversation_api.c
src/conversation/conversation_api_call.c
-src/conversation/gnunet-conversation-test.c
src/conversation/gnunet-conversation.c
-src/conversation/gnunet-helper-audio-playback-gst.c
+src/conversation/gnunet-conversation-test.c
+src/conversation/gnunet_gst.c
+src/conversation/gnunet_gst_test.c
src/conversation/gnunet-helper-audio-playback.c
-src/conversation/gnunet-helper-audio-record-gst.c
+src/conversation/gnunet-helper-audio-playback-gst.c
src/conversation/gnunet-helper-audio-record.c
+src/conversation/gnunet-helper-audio-record-gst.c
src/conversation/gnunet-service-conversation.c
-src/conversation/gnunet_gst.c
-src/conversation/gnunet_gst_test.c
src/conversation/microphone.c
src/conversation/plugin_gnsrecord_conversation.c
src/conversation/speaker.c
@@ -102,6 +102,7 @@ src/dht/dht_api.c
src/dht/dht_test_lib.c
src/dht/gnunet-dht-get.c
src/dht/gnunet-dht-monitor.c
+src/dht/gnunet_dht_profiler.c
src/dht/gnunet-dht-put.c
src/dht/gnunet-service-dht.c
src/dht/gnunet-service-dht_clients.c
@@ -110,7 +111,6 @@ src/dht/gnunet-service-dht_hello.c
src/dht/gnunet-service-dht_neighbours.c
src/dht/gnunet-service-dht_nse.c
src/dht/gnunet-service-dht_routing.c
-src/dht/gnunet_dht_profiler.c
src/dht/plugin_block_dht.c
src/dns/dns_api.c
src/dns/dnsparser.c
@@ -126,8 +126,8 @@ src/dv/gnunet-dv.c
src/dv/gnunet-service-dv.c
src/dv/plugin_transport_dv.c
src/exit/gnunet-daemon-exit.c
-src/exit/gnunet-helper-exit-windows.c
src/exit/gnunet-helper-exit.c
+src/exit/gnunet-helper-exit-windows.c
src/fragmentation/defragmentation.c
src/fragmentation/fragmentation.c
src/fs/fs_api.c
@@ -152,8 +152,8 @@ src/fs/gnunet-auto-share.c
src/fs/gnunet-daemon-fsprofiler.c
src/fs/gnunet-directory.c
src/fs/gnunet-download.c
-src/fs/gnunet-fs-profiler.c
src/fs/gnunet-fs.c
+src/fs/gnunet-fs-profiler.c
src/fs/gnunet-helper-fs-publish.c
src/fs/gnunet-publish.c
src/fs/gnunet-search.c
@@ -173,10 +173,10 @@ src/gns/gns_tld_api.c
src/gns/gnunet-bcd.c
src/gns/gnunet-dns2gns.c
src/gns/gnunet-gns-benchmark.c
+src/gns/gnunet-gns.c
src/gns/gnunet-gns-helper-service-w32.c
src/gns/gnunet-gns-import.c
src/gns/gnunet-gns-proxy.c
-src/gns/gnunet-gns.c
src/gns/gnunet-service-gns.c
src/gns/gnunet-service-gns_interceptor.c
src/gns/gnunet-service-gns_resolver.c
@@ -185,15 +185,15 @@ src/gns/nss/nss_gns_query.c
src/gns/plugin_block_gns.c
src/gns/plugin_gnsrecord_gns.c
src/gns/plugin_rest_gns.c
-src/gns/w32nsp-install.c
-src/gns/w32nsp-resolve.c
-src/gns/w32nsp-uninstall.c
-src/gns/w32nsp.c
src/gnsrecord/gnsrecord.c
src/gnsrecord/gnsrecord_crypto.c
src/gnsrecord/gnsrecord_misc.c
src/gnsrecord/gnsrecord_serialization.c
src/gnsrecord/plugin_gnsrecord_dns.c
+src/gns/w32nsp.c
+src/gns/w32nsp-install.c
+src/gns/w32nsp-resolve.c
+src/gns/w32nsp-uninstall.c
src/hello/address.c
src/hello/gnunet-hello.c
src/hello/hello.c
@@ -202,6 +202,11 @@ src/hostlist/gnunet-daemon-hostlist_client.c
src/hostlist/gnunet-daemon-hostlist_server.c
src/identity-attribute/identity_attribute.c
src/identity-attribute/plugin_identity_attribute_gnuid.c
+src/identity/gnunet-identity.c
+src/identity/gnunet-service-identity.c
+src/identity/identity_api.c
+src/identity/identity_api_lookup.c
+src/identity/plugin_rest_identity.c
src/identity-provider/gnunet-idp.c
src/identity-provider/gnunet-service-identity-provider.c
src/identity-provider/identity_provider_api.c
@@ -210,20 +215,15 @@ src/identity-provider/plugin_gnsrecord_identity_provider.c
src/identity-provider/plugin_identity_provider_sqlite.c
src/identity-provider/plugin_rest_identity_provider.c
src/identity-provider/plugin_rest_openid_connect.c
-src/identity/gnunet-identity.c
-src/identity/gnunet-service-identity.c
-src/identity/identity_api.c
-src/identity/identity_api_lookup.c
-src/identity/plugin_rest_identity.c
-src/json/json.c
-src/json/json_generator.c
-src/json/json_helper.c
-src/json/json_mhd.c
src/jsonapi/jsonapi.c
src/jsonapi/jsonapi_document.c
src/jsonapi/jsonapi_error.c
src/jsonapi/jsonapi_relationship.c
src/jsonapi/jsonapi_resource.c
+src/json/json.c
+src/json/json_generator.c
+src/json/json_helper.c
+src/json/json_mhd.c
src/multicast/gnunet-multicast.c
src/multicast/gnunet-service-multicast.c
src/multicast/multicast_api.c
@@ -237,8 +237,8 @@ src/namecache/namecache_api.c
src/namecache/plugin_namecache_flat.c
src/namecache/plugin_namecache_postgres.c
src/namecache/plugin_namecache_sqlite.c
-src/namestore/gnunet-namestore-fcfsd.c
src/namestore/gnunet-namestore.c
+src/namestore/gnunet-namestore-fcfsd.c
src/namestore/gnunet-service-namestore.c
src/namestore/gnunet-zoneimport.c
src/namestore/namestore_api.c
@@ -254,10 +254,10 @@ src/nat-auto/gnunet-service-nat-auto.c
src/nat-auto/gnunet-service-nat-auto_legacy.c
src/nat-auto/nat_auto_api.c
src/nat-auto/nat_auto_api_test.c
-src/nat/gnunet-helper-nat-client-windows.c
src/nat/gnunet-helper-nat-client.c
-src/nat/gnunet-helper-nat-server-windows.c
+src/nat/gnunet-helper-nat-client-windows.c
src/nat/gnunet-helper-nat-server.c
+src/nat/gnunet-helper-nat-server-windows.c
src/nat/gnunet-nat.c
src/nat/gnunet-service-nat.c
src/nat/gnunet-service-nat_externalip.c
@@ -266,15 +266,15 @@ src/nat/gnunet-service-nat_mini.c
src/nat/gnunet-service-nat_stun.c
src/nat/nat_api.c
src/nat/nat_api_stun.c
-src/nse/gnunet-nse-profiler.c
src/nse/gnunet-nse.c
+src/nse/gnunet-nse-profiler.c
src/nse/gnunet-service-nse.c
src/nse/nse_api.c
-src/peerinfo-tool/gnunet-peerinfo.c
-src/peerinfo-tool/gnunet-peerinfo_plugins.c
src/peerinfo/gnunet-service-peerinfo.c
src/peerinfo/peerinfo_api.c
src/peerinfo/peerinfo_api_notify.c
+src/peerinfo-tool/gnunet-peerinfo.c
+src/peerinfo-tool/gnunet-peerinfo_plugins.c
src/peerstore/gnunet-peerstore.c
src/peerstore/gnunet-service-peerstore.c
src/peerstore/peerstore_api.c
@@ -325,13 +325,13 @@ src/rps/gnunet-service-rps_custommap.c
src/rps/gnunet-service-rps_sampler.c
src/rps/gnunet-service-rps_sampler_elem.c
src/rps/gnunet-service-rps_view.c
-src/rps/rps-test_util.c
src/rps/rps_api.c
+src/rps/rps-test_util.c
src/scalarproduct/gnunet-scalarproduct.c
-src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c
-src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c
src/scalarproduct/gnunet-service-scalarproduct_alice.c
src/scalarproduct/gnunet-service-scalarproduct_bob.c
+src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c
+src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c
src/scalarproduct/scalarproduct_api.c
src/secretsharing/gnunet-secretsharing-profiler.c
src/secretsharing/gnunet-service-secretsharing.c
@@ -360,16 +360,15 @@ src/statistics/gnunet-statistics.c
src/statistics/statistics_api.c
src/template/gnunet-service-template.c
src/template/gnunet-template.c
-src/testbed-logger/gnunet-service-testbed-logger.c
-src/testbed-logger/testbed_logger_api.c
src/testbed/generate-underlay-topology.c
src/testbed/gnunet-daemon-latency-logger.c
src/testbed/gnunet-daemon-testbed-blacklist.c
src/testbed/gnunet-daemon-testbed-underlay.c
src/testbed/gnunet-helper-testbed.c
+src/testbed/gnunet_mpi_test.c
src/testbed/gnunet-service-test-barriers.c
-src/testbed/gnunet-service-testbed.c
src/testbed/gnunet-service-testbed_barriers.c
+src/testbed/gnunet-service-testbed.c
src/testbed/gnunet-service-testbed_cache.c
src/testbed/gnunet-service-testbed_connectionpool.c
src/testbed/gnunet-service-testbed_cpustatus.c
@@ -377,19 +376,20 @@ src/testbed/gnunet-service-testbed_links.c
src/testbed/gnunet-service-testbed_meminfo.c
src/testbed/gnunet-service-testbed_oc.c
src/testbed/gnunet-service-testbed_peers.c
-src/testbed/gnunet-testbed-profiler.c
-src/testbed/gnunet_mpi_test.c
src/testbed/gnunet_testbed_mpi_spawn.c
-src/testbed/testbed_api.c
+src/testbed/gnunet-testbed-profiler.c
+src/testbed-logger/gnunet-service-testbed-logger.c
+src/testbed-logger/testbed_logger_api.c
src/testbed/testbed_api_barriers.c
+src/testbed/testbed_api.c
src/testbed/testbed_api_hosts.c
src/testbed/testbed_api_operations.c
src/testbed/testbed_api_peers.c
src/testbed/testbed_api_sd.c
src/testbed/testbed_api_services.c
src/testbed/testbed_api_statistics.c
-src/testbed/testbed_api_test.c
src/testbed/testbed_api_testbed.c
+src/testbed/testbed_api_test.c
src/testbed/testbed_api_topology.c
src/testbed/testbed_api_underlay.c
src/testing/gnunet-testing.c
@@ -398,39 +398,36 @@ src/testing/testing.c
src/topology/friends.c
src/topology/gnunet-daemon-topology.c
src/transport/gnunet-helper-transport-bluetooth.c
-src/transport/gnunet-helper-transport-wlan-dummy.c
src/transport/gnunet-helper-transport-wlan.c
-src/transport/gnunet-service-transport.c
+src/transport/gnunet-helper-transport-wlan-dummy.c
src/transport/gnunet-service-transport_ats.c
+src/transport/gnunet-service-transport.c
src/transport/gnunet-service-transport_hello.c
src/transport/gnunet-service-transport_manipulation.c
src/transport/gnunet-service-transport_neighbours.c
src/transport/gnunet-service-transport_plugins.c
src/transport/gnunet-service-transport_validation.c
+src/transport/gnunet-transport.c
src/transport/gnunet-transport-certificate-creation.c
src/transport/gnunet-transport-profiler.c
src/transport/gnunet-transport-wlan-receiver.c
src/transport/gnunet-transport-wlan-sender.c
-src/transport/gnunet-transport.c
src/transport/plugin_transport_http_client.c
src/transport/plugin_transport_http_common.c
src/transport/plugin_transport_http_server.c
src/transport/plugin_transport_smtp.c
src/transport/plugin_transport_tcp.c
src/transport/plugin_transport_template.c
-src/transport/plugin_transport_udp.c
src/transport/plugin_transport_udp_broadcasting.c
+src/transport/plugin_transport_udp.c
src/transport/plugin_transport_unix.c
src/transport/plugin_transport_wlan.c
+src/transport/plugin_transport_xt.c
+src/transport/plugin_transport_xu.c
src/transport/tcp_connection_legacy.c
src/transport/tcp_server_legacy.c
src/transport/tcp_server_mst_legacy.c
src/transport/tcp_service_legacy.c
-src/transport/transport-testing-filenames.c
-src/transport/transport-testing-loggers.c
-src/transport/transport-testing-main.c
-src/transport/transport-testing-send.c
-src/transport/transport-testing.c
src/transport/transport_api_address_to_string.c
src/transport/transport_api_blacklist.c
src/transport/transport_api_core.c
@@ -439,6 +436,11 @@ src/transport/transport_api_manipulation.c
src/transport/transport_api_monitor_peers.c
src/transport/transport_api_monitor_plugins.c
src/transport/transport_api_offer_hello.c
+src/transport/transport-testing.c
+src/transport/transport-testing-filenames.c
+src/transport/transport-testing-loggers.c
+src/transport/transport-testing-main.c
+src/transport/transport-testing-send.c
src/tun/regex.c
src/tun/tun.c
src/util/bandwidth.c
@@ -452,8 +454,8 @@ src/util/configuration_loader.c
src/util/container_bloomfilter.c
src/util/container_heap.c
src/util/container_meta_data.c
-src/util/container_multihashmap.c
src/util/container_multihashmap32.c
+src/util/container_multihashmap.c
src/util/container_multipeermap.c
src/util/container_multishortmap.c
src/util/crypto_abe.c
@@ -474,8 +476,8 @@ src/util/crypto_symmetric.c
src/util/disk.c
src/util/getopt.c
src/util/getopt_helpers.c
-src/util/gnunet-config-diff.c
src/util/gnunet-config.c
+src/util/gnunet-config-diff.c
src/util/gnunet-ecc.c
src/util/gnunet-helper-w32-console.c
src/util/gnunet-resolver.c
@@ -506,13 +508,13 @@ src/util/time.c
src/util/w32cat.c
src/util/win.c
src/util/winproc.c
-src/vpn/gnunet-helper-vpn-windows.c
src/vpn/gnunet-helper-vpn.c
+src/vpn/gnunet-helper-vpn-windows.c
src/vpn/gnunet-service-vpn.c
src/vpn/gnunet-vpn.c
src/vpn/vpn_api.c
-src/zonemaster/gnunet-service-zonemaster-monitor.c
src/zonemaster/gnunet-service-zonemaster.c
+src/zonemaster/gnunet-service-zonemaster-monitor.c
src/fs/fs_api.h
src/include/gnunet_common.h
src/include/gnunet_mq_lib.h
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c
index fcd69599b..e4fa5cc10 100644
--- a/src/gns/gnunet-gns-proxy.c
+++ b/src/gns/gnunet-gns-proxy.c
@@ -106,7 +106,13 @@
* @param fun name of curl_easy-function that gave the error
* @param rc return code from curl
*/
-#define LOG_CURL_EASY(level,fun,rc) GNUNET_log(level, _("%s failed at %s:%d: `%s'\n"), fun, __FILE__, __LINE__, curl_easy_strerror (rc))
+#define LOG_CURL_EASY(level,fun,rc) \
+ GNUNET_log (level, \
+ _("%s failed at %s:%d: `%s'\n"), \
+ fun, \
+ __FILE__, \
+ __LINE__, \
+ curl_easy_strerror (rc))
/* *************** Socks protocol definitions (move to TUN?) ****************** */
@@ -768,21 +774,37 @@ cleanup_s5r (struct Socks5Request *s5r)
}
if ( (NULL != s5r->response) &&
(curl_failure_response != s5r->response) )
+ {
MHD_destroy_response (s5r->response);
+ s5r->response = NULL;
+ }
if (NULL != s5r->rtask)
+ {
GNUNET_SCHEDULER_cancel (s5r->rtask);
+ s5r->rtask = NULL;
+ }
if (NULL != s5r->timeout_task)
+ {
GNUNET_SCHEDULER_cancel (s5r->timeout_task);
+ s5r->timeout_task = NULL;
+ }
if (NULL != s5r->wtask)
+ {
GNUNET_SCHEDULER_cancel (s5r->wtask);
+ s5r->wtask = NULL;
+ }
if (NULL != s5r->gns_lookup)
+ {
GNUNET_GNS_lookup_with_tld_cancel (s5r->gns_lookup);
+ s5r->gns_lookup = NULL;
+ }
if (NULL != s5r->sock)
{
if (SOCKS5_SOCKET_WITH_MHD <= s5r->state)
GNUNET_NETWORK_socket_free_memory_only_ (s5r->sock);
else
GNUNET_NETWORK_socket_close (s5r->sock);
+ s5r->sock = NULL;
}
GNUNET_CONTAINER_DLL_remove (s5r_head,
s5r_tail,
@@ -1129,7 +1151,9 @@ curl_check_hdr (void *buffer,
domain_matched = GNUNET_NO; /* make sure we match domain at most once */
for (tok = strtok (hdr_val, ";"); NULL != tok; tok = strtok (NULL, ";"))
{
- if ( (0 == strncasecmp (tok, " domain", strlen (" domain"))) &&
+ if ( (0 == strncasecmp (tok,
+ " domain",
+ strlen (" domain"))) &&
(GNUNET_NO == domain_matched) )
{
domain_matched = GNUNET_YES;
@@ -1137,7 +1161,8 @@ curl_check_hdr (void *buffer,
if (strlen (cookie_domain) < strlen (s5r->leho))
{
delta_cdomain = strlen (s5r->leho) - strlen (cookie_domain);
- if (0 == strcasecmp (cookie_domain, s5r->leho + delta_cdomain))
+ if (0 == strcasecmp (cookie_domain,
+ s5r->leho + delta_cdomain))
{
offset += sprintf (new_cookie_hdr + offset,
" domain=%s;",
@@ -1145,7 +1170,8 @@ curl_check_hdr (void *buffer,
continue;
}
}
- else if (0 == strcmp (cookie_domain, s5r->leho))
+ else if (0 == strcmp (cookie_domain,
+ s5r->leho))
{
offset += sprintf (new_cookie_hdr + offset,
" domain=%s;",
@@ -1156,7 +1182,9 @@ curl_check_hdr (void *buffer,
_("Cookie domain `%s' supplied by server is invalid\n"),
tok);
}
- GNUNET_memcpy (new_cookie_hdr + offset, tok, strlen (tok));
+ GNUNET_memcpy (new_cookie_hdr + offset,
+ tok,
+ strlen (tok));
offset += strlen (tok);
new_cookie_hdr[offset++] = ';';
}
@@ -1164,7 +1192,8 @@ curl_check_hdr (void *buffer,
}
new_location = NULL;
- if (0 == strcasecmp (MHD_HTTP_HEADER_LOCATION, hdr_type))
+ if (0 == strcasecmp (MHD_HTTP_HEADER_LOCATION,
+ hdr_type))
{
char *leho_host;
@@ -1251,7 +1280,9 @@ create_mhd_response_from_s5r (struct Socks5Request *s5r)
s5r->domain,
s5r->url);
s5r->response_code = resp_code;
- s5r->response = MHD_create_response_from_callback ((-1 == content_length) ? MHD_SIZE_UNKNOWN : content_length,
+ s5r->response = MHD_create_response_from_callback ((-1 == content_length)
+ ? MHD_SIZE_UNKNOWN
+ : content_length,
IO_BUFFERSIZE,
&mhd_content_cb,
s5r,
@@ -1480,20 +1511,28 @@ curl_download_prepare ()
return;
}
to = -1;
- GNUNET_break (CURLM_OK == curl_multi_timeout (curl_multi, &to));
+ GNUNET_break (CURLM_OK ==
+ curl_multi_timeout (curl_multi,
+ &to));
if (-1 == to)
rtime = GNUNET_TIME_UNIT_FOREVER_REL;
else
- rtime = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, to);
+ rtime = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
+ to);
if (-1 != max)
{
grs = GNUNET_NETWORK_fdset_create ();
gws = GNUNET_NETWORK_fdset_create ();
- GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1);
- GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1);
+ GNUNET_NETWORK_fdset_copy_native (grs,
+ &rs,
+ max + 1);
+ GNUNET_NETWORK_fdset_copy_native (gws,
+ &ws,
+ max + 1);
curl_download_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
rtime,
- grs, gws,
+ grs,
+ gws,
&curl_task_download,
curl_multi);
GNUNET_NETWORK_fdset_destroy (gws);
@@ -1648,12 +1687,15 @@ con_val_iter (void *cls,
struct Socks5Request *s5r = cls;
char *hdr;
- if ( (0 == strcasecmp (MHD_HTTP_HEADER_HOST, key)) &&
+ if ( (0 == strcasecmp (MHD_HTTP_HEADER_HOST,
+ key)) &&
(NULL != s5r->leho) )
value = s5r->leho;
- if (0 == strcasecmp (MHD_HTTP_HEADER_CONTENT_LENGTH, key))
+ if (0 == strcasecmp (MHD_HTTP_HEADER_CONTENT_LENGTH,
+ key))
return MHD_YES;
- if (0 == strcasecmp (MHD_HTTP_HEADER_ACCEPT_ENCODING, key))
+ if (0 == strcasecmp (MHD_HTTP_HEADER_ACCEPT_ENCODING,
+ key))
return MHD_YES;
GNUNET_asprintf (&hdr,
"%s: %s",
@@ -1774,21 +1816,40 @@ create_response (void *cls,
return MHD_queue_response (con,
MHD_HTTP_INTERNAL_SERVER_ERROR,
curl_failure_response);
- curl_easy_setopt (s5r->curl, CURLOPT_HEADERFUNCTION, &curl_check_hdr);
- curl_easy_setopt (s5r->curl, CURLOPT_HEADERDATA, s5r);
- curl_easy_setopt (s5r->curl, CURLOPT_FOLLOWLOCATION, 0);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_HEADERFUNCTION,
+ &curl_check_hdr);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_HEADERDATA,
+ s5r);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_FOLLOWLOCATION,
+ 0);
if (s5r->is_gns)
curl_easy_setopt (s5r->curl,
CURLOPT_IPRESOLVE,
CURL_IPRESOLVE_V4);
- curl_easy_setopt (s5r->curl, CURLOPT_CONNECTTIMEOUT, 600L);
- curl_easy_setopt (s5r->curl, CURLOPT_TIMEOUT, 600L);
- curl_easy_setopt (s5r->curl, CURLOPT_NOSIGNAL, 1L);
- curl_easy_setopt (s5r->curl, CURLOPT_HTTP_CONTENT_DECODING, 0);
- // curl_easy_setopt (s5r->curl, CURLOPT_HTTP_TRANSFER_DECODING, 0);
- curl_easy_setopt (s5r->curl, CURLOPT_NOSIGNAL, 1L);
- curl_easy_setopt (s5r->curl, CURLOPT_PRIVATE, s5r);
- curl_easy_setopt (s5r->curl, CURLOPT_VERBOSE, 0L);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_CONNECTTIMEOUT,
+ 600L);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_TIMEOUT,
+ 600L);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_NOSIGNAL,
+ 1L);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_HTTP_CONTENT_DECODING,
+ 0);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_NOSIGNAL,
+ 1L);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_PRIVATE,
+ s5r);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_VERBOSE,
+ 0L);
/**
* Pre-populate cache to resolve Hostname.
* This is necessary as the DNS name in the CURLOPT_URL is used
@@ -1844,11 +1905,21 @@ create_response (void *cls,
MHD_HTTP_METHOD_PUT))
{
s5r->state = SOCKS5_SOCKET_UPLOAD_STARTED;
- curl_easy_setopt (s5r->curl, CURLOPT_UPLOAD, 1L);
- curl_easy_setopt (s5r->curl, CURLOPT_WRITEFUNCTION, &curl_download_cb);
- curl_easy_setopt (s5r->curl, CURLOPT_WRITEDATA, s5r);
- curl_easy_setopt (s5r->curl, CURLOPT_READFUNCTION, &curl_upload_cb);
- curl_easy_setopt (s5r->curl, CURLOPT_READDATA, s5r);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_UPLOAD,
+ 1L);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_WRITEFUNCTION,
+ &curl_download_cb);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_WRITEDATA,
+ s5r);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_READFUNCTION,
+ &curl_upload_cb);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_READDATA,
+ s5r);
{
const char *us;
long upload_size;
@@ -1870,11 +1941,21 @@ create_response (void *cls,
else if (0 == strcasecmp (meth, MHD_HTTP_METHOD_POST))
{
s5r->state = SOCKS5_SOCKET_UPLOAD_STARTED;
- curl_easy_setopt (s5r->curl, CURLOPT_POST, 1L);
- curl_easy_setopt (s5r->curl, CURLOPT_WRITEFUNCTION, &curl_download_cb);
- curl_easy_setopt (s5r->curl, CURLOPT_WRITEDATA, s5r);
- curl_easy_setopt (s5r->curl, CURLOPT_READFUNCTION, &curl_upload_cb);
- curl_easy_setopt (s5r->curl, CURLOPT_READDATA, s5r);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_POST,
+ 1L);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_WRITEFUNCTION,
+ &curl_download_cb);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_WRITEDATA,
+ s5r);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_READFUNCTION,
+ &curl_upload_cb);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_READDATA,
+ s5r);
{
const char *us;
long upload_size;
@@ -1893,22 +1974,35 @@ create_response (void *cls,
}
}
}
- else if (0 == strcasecmp (meth, MHD_HTTP_METHOD_HEAD))
+ else if (0 == strcasecmp (meth,
+ MHD_HTTP_METHOD_HEAD))
{
s5r->state = SOCKS5_SOCKET_DOWNLOAD_STARTED;
- curl_easy_setopt (s5r->curl, CURLOPT_NOBODY, 1L);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_NOBODY,
+ 1L);
}
- else if (0 == strcasecmp (meth, MHD_HTTP_METHOD_OPTIONS))
+ else if (0 == strcasecmp (meth,
+ MHD_HTTP_METHOD_OPTIONS))
{
s5r->state = SOCKS5_SOCKET_DOWNLOAD_STARTED;
- curl_easy_setopt (s5r->curl, CURLOPT_CUSTOMREQUEST, "OPTIONS");
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_CUSTOMREQUEST,
+ "OPTIONS");
}
- else if (0 == strcasecmp (meth, MHD_HTTP_METHOD_GET))
+ else if (0 == strcasecmp (meth,
+ MHD_HTTP_METHOD_GET))
{
s5r->state = SOCKS5_SOCKET_DOWNLOAD_STARTED;
- curl_easy_setopt (s5r->curl, CURLOPT_HTTPGET, 1L);
- curl_easy_setopt (s5r->curl, CURLOPT_WRITEFUNCTION, &curl_download_cb);
- curl_easy_setopt (s5r->curl, CURLOPT_WRITEDATA, s5r);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_HTTPGET,
+ 1L);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_WRITEFUNCTION,
+ &curl_download_cb);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_WRITEDATA,
+ s5r);
}
else
{
@@ -1922,31 +2016,47 @@ 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);
+ curl_easy_setopt (s5r->curl,
+ 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);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_HTTP_VERSION,
+ CURL_HTTP_VERSION_1_1);
}
else
{
- curl_easy_setopt (s5r->curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_NONE);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_HTTP_VERSION,
+ CURL_HTTP_VERSION_NONE);
}
if (HTTPS_PORT == s5r->port)
{
- curl_easy_setopt (s5r->curl, CURLOPT_USE_SSL, CURLUSESSL_ALL);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_USE_SSL,
+ CURLUSESSL_ALL);
if (NULL != s5r->dane_data)
- curl_easy_setopt (s5r->curl, CURLOPT_SSL_VERIFYPEER, 0L);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_SSL_VERIFYPEER,
+ 0L);
else
- curl_easy_setopt (s5r->curl, CURLOPT_SSL_VERIFYPEER, 1L);
+ curl_easy_setopt (s5r->curl,
+ 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);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_SSL_VERIFYHOST,
+ 0L);
}
else
{
- curl_easy_setopt (s5r->curl, CURLOPT_USE_SSL, CURLUSESSL_NONE);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_USE_SSL,
+ CURLUSESSL_NONE);
}
if (CURLM_OK !=
@@ -1979,7 +2089,9 @@ create_response (void *cls,
/* 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);
+ curl_easy_setopt (s5r->curl,
+ CURLOPT_POSTFIELDSIZE,
+ *upload_data_size);
left = GNUNET_MIN (*upload_data_size,
sizeof (s5r->io_buf) - s5r->io_len);
@@ -2372,8 +2484,10 @@ load_file (const char* filename,
uint64_t fsize;
if (GNUNET_OK !=
- GNUNET_DISK_file_size (filename, &fsize,
- GNUNET_YES, GNUNET_YES))
+ GNUNET_DISK_file_size (filename,
+ &fsize,
+ GNUNET_YES,
+ GNUNET_YES))
return NULL;
if (fsize > MAX_PEM_SIZE)
return NULL;
@@ -2405,7 +2519,8 @@ load_key_from_file (gnutls_x509_privkey_t key,
gnutls_datum_t key_data;
int ret;
- key_data.data = load_file (keyfile, &key_data.size);
+ key_data.data = load_file (keyfile,
+ &key_data.size);
if (NULL == key_data.data)
return GNUNET_SYSERR;
ret = gnutls_x509_privkey_import (key, &key_data,
@@ -2435,15 +2550,18 @@ load_cert_from_file (gnutls_x509_crt_t crt,
gnutls_datum_t cert_data;
int ret;
- cert_data.data = load_file (certfile, &cert_data.size);
+ cert_data.data = load_file (certfile,
+ &cert_data.size);
if (NULL == cert_data.data)
return GNUNET_SYSERR;
- ret = gnutls_x509_crt_import (crt, &cert_data,
+ ret = gnutls_x509_crt_import (crt,
+ &cert_data,
GNUTLS_X509_FMT_PEM);
if (GNUTLS_E_SUCCESS != ret)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Unable to import certificate %s\n"), certfile);
+ _("Unable to import certificate from `%s'\n"),
+ certfile);
}
GNUNET_free_non_null (cert_data.data);
return (GNUTLS_E_SUCCESS != ret) ? GNUNET_SYSERR : GNUNET_OK;
@@ -2473,14 +2591,27 @@ generate_gns_certificate (const char *name)
GNUNET_break (GNUTLS_E_SUCCESS == gnutls_x509_crt_init (&request));
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,
- 0, "ZZ", 2);
- gnutls_x509_crt_set_dn_by_oid (request, GNUTLS_OID_X520_ORGANIZATION_NAME,
- 0, "GNU Name System", 4);
- gnutls_x509_crt_set_dn_by_oid (request, GNUTLS_OID_X520_COMMON_NAME,
- 0, name, strlen (name));
- GNUNET_break (GNUTLS_E_SUCCESS == gnutls_x509_crt_set_version (request, 3));
- gnutls_rnd (GNUTLS_RND_NONCE, &serial, sizeof (serial));
+ gnutls_x509_crt_set_dn_by_oid (request,
+ GNUTLS_OID_X520_COUNTRY_NAME,
+ 0,
+ "ZZ",
+ strlen ("ZZ"));
+ gnutls_x509_crt_set_dn_by_oid (request,
+ GNUTLS_OID_X520_ORGANIZATION_NAME,
+ 0,
+ "GNU Name System",
+ strlen ("GNU Name System"));
+ gnutls_x509_crt_set_dn_by_oid (request,
+ GNUTLS_OID_X520_COMMON_NAME,
+ 0,
+ name,
+ strlen (name));
+ GNUNET_break (GNUTLS_E_SUCCESS ==
+ gnutls_x509_crt_set_version (request,
+ 3));
+ gnutls_rnd (GNUTLS_RND_NONCE,
+ &serial,
+ sizeof (serial));
gnutls_x509_crt_set_serial (request,
&serial,
sizeof (serial));
@@ -2501,10 +2632,14 @@ generate_gns_certificate (const char *name)
0);
key_buf_size = sizeof (pgc->key);
cert_buf_size = sizeof (pgc->cert);
- gnutls_x509_crt_export (request, GNUTLS_X509_FMT_PEM,
- pgc->cert, &cert_buf_size);
- gnutls_x509_privkey_export (proxy_ca.key, GNUTLS_X509_FMT_PEM,
- pgc->key, &key_buf_size);
+ gnutls_x509_crt_export (request,
+ GNUTLS_X509_FMT_PEM,
+ pgc->cert,
+ &cert_buf_size);
+ gnutls_x509_privkey_export (proxy_ca.key,
+ GNUTLS_X509_FMT_PEM,
+ pgc->key,
+ &key_buf_size);
gnutls_x509_crt_deinit (request);
return pgc;
}
@@ -2945,7 +3080,8 @@ do_s5r_read (void *cls)
s5r->rtask = NULL;
tc = GNUNET_SCHEDULER_get_task_context ();
if ( (NULL != tc->read_ready) &&
- (GNUNET_NETWORK_fdset_isset (tc->read_ready, s5r->sock)) )
+ (GNUNET_NETWORK_fdset_isset (tc->read_ready,
+ s5r->sock)) )
{
rlen = GNUNET_NETWORK_socket_recv (s5r->sock,
&s5r->rbuf[s5r->rbuf_len],
@@ -3142,17 +3278,22 @@ do_accept (void *cls)
if (lsock == lsock4)
ltask4 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
lsock,
- &do_accept, lsock);
+ &do_accept,
+ lsock);
else if (lsock == lsock6)
ltask6 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
lsock,
- &do_accept, lsock);
+ &do_accept,
+ lsock);
else
GNUNET_assert (0);
- s = GNUNET_NETWORK_socket_accept (lsock, NULL, NULL);
+ s = GNUNET_NETWORK_socket_accept (lsock,
+ NULL,
+ NULL);
if (NULL == s)
{
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "accept");
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
+ "accept");
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -3165,7 +3306,8 @@ do_accept (void *cls)
s5r->state = SOCKS5_INIT;
s5r->rtask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
s5r->sock,
- &do_s5r_read, s5r);
+ &do_s5r_read,
+ s5r);
}
@@ -3262,7 +3404,8 @@ bind_v4 ()
if (NULL == ls)
return NULL;
if (GNUNET_OK !=
- GNUNET_NETWORK_socket_bind (ls, (const struct sockaddr *) &sa4,
+ GNUNET_NETWORK_socket_bind (ls,
+ (const struct sockaddr *) &sa4,
sizeof (sa4)))
{
eno = errno;
@@ -3298,7 +3441,8 @@ bind_v6 ()
if (NULL == ls)
return NULL;
if (GNUNET_OK !=
- GNUNET_NETWORK_socket_bind (ls, (const struct sockaddr *) &sa6,
+ GNUNET_NETWORK_socket_bind (ls,
+ (const struct sockaddr *) &sa6,
sizeof (sa6)))
{
eno = errno;
@@ -3353,7 +3497,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);
@@ -3488,7 +3633,8 @@ run (void *cls,
* @return 0 ok, 1 on error
*/
int
-main (int argc, char *const *argv)
+main (int argc,
+ char *const *argv)
{
struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_option_uint16 ('p',
@@ -3509,8 +3655,9 @@ main (int argc, char *const *argv)
"</head><body>cURL fail</body></html>";
int ret;
- if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv,
- &argc, &argv))
+ if (GNUNET_OK !=
+ GNUNET_STRINGS_get_utf8_args (argc, argv,
+ &argc, &argv))
return 2;
GNUNET_log_setup ("gnunet-gns-proxy",
"WARNING",