Skip to content

Commit

Permalink
Use libcurlwrapper instead of static libcurl
Browse files Browse the repository at this point in the history
- Fixes SSL and cuts down filesize from 790KB -> 121KB
- Include full user-agent
  • Loading branch information
celerizer committed Oct 31, 2023
1 parent 675e26c commit a3fba18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)\"

Expand All @@ -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
Expand Down
11 changes: 8 additions & 3 deletions source/cl_frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit a3fba18

Please sign in to comment.