From a3fba18441ef510a6275f71fdaa80a7ac6310676 Mon Sep 17 00:00:00 2001 From: celerizer <33245078+celerizer@users.noreply.github.com> Date: Tue, 31 Oct 2023 14:59:16 -0500 Subject: [PATCH] Use libcurlwrapper instead of static libcurl - Fixes SSL and cuts down filesize from 790KB -> 121KB - Include full user-agent --- Makefile | 3 +-- source/cl_frontend.cpp | 11 ++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index caf6eed..9f54403 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,6 @@ GIT_VERSION := "$(shell git describe --abbrev=8 --dirty --always --tags)" CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ -D__WUPS__ -DDISTRO=\"$(DISTRO)\" \ -DCL_HAVE_EDITOR=0 \ -DCL_HAVE_FILESYSTEM=0 \ - -DCL_HAVE_SSL=0 \ -DCL_WUPS_DEBUG=0 \ -DGIT_VERSION=\"$(GIT_VERSION)\" @@ -68,7 +67,7 @@ CXXFLAGS += -DDEBUG -DVERBOSE_DEBUG -g CFLAGS += -DDEBUG -DVERBOSE_DEBUG -g endif -LIBS := -lnotifications -lcurl -lmbedtls -lmbedx509 -lmbedcrypto -lz -lwups -lwut +LIBS := -lnotifications -lcurlwrapper -lwups -lwut #------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level diff --git a/source/cl_frontend.cpp b/source/cl_frontend.cpp index e8ad0c0..cc8ae6e 100644 --- a/source/cl_frontend.cpp +++ b/source/cl_frontend.cpp @@ -122,17 +122,22 @@ void cl_fe_network_post(const char *url, char *data, CURLcode response_code; cl_wups_network_chunk_t chunk; cl_network_response_t response; + char user_agent[256]; + auto curl_version = curl_version_info(CURLVERSION_NOW); + snprintf(user_agent, sizeof(user_agent), "cl_wups " GIT_VERSION " using curl/%s", curl_version->version); chunk.size = 0; curl_handle = curl_easy_init(); curl_easy_setopt(curl_handle, CURLOPT_URL, CL_REQUEST_URL); - curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0); - curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0); curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, data); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, cl_wups_network_cb); curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void*)&chunk); - curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "cl_wups " GIT_VERSION " using curl/1.0"); + curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, user_agent); +#if !CL_HAVE_SSL + curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L); + curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L); +#endif response_code = curl_easy_perform(curl_handle); curl_easy_cleanup(curl_handle);