From 7ac7fa84867506abbc5b9b34a2b6223556ae0e56 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sat, 20 Jul 2019 14:22:47 -0700 Subject: [PATCH] Use schannel on Win instead of OpenSSL --- dep/Makefile | 25 ++++++++++++++++++------- include/network.hpp | 2 -- src/network.cpp | 33 +-------------------------------- 3 files changed, 19 insertions(+), 41 deletions(-) diff --git a/dep/Makefile b/dep/Makefile index 73a12b8a..7929dd80 100755 --- a/dep/Makefile +++ b/dep/Makefile @@ -121,9 +121,20 @@ curl-7.64.1: CURL_FLAGS += --disable-ftp --disable-file --disable-ldap --disable-ldaps --disable-rtsp --disable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --disable-manual --disable-shared --disable-symbol-hiding CURL_FLAGS += --without-zlib --without-libpsl --without-libmetalink --without-libssh2 --without-librtmp --without-winidn --without-libidn2 --without-nghttp2 --without-brotli +ifdef ARCH_LIN CURL_FLAGS += --with-ssl="$(DEP_PATH)" +CURL_DEPS += $(openssl) +endif +ifdef ARCH_MAC +CURL_FLAGS += --with-ssl="$(DEP_PATH)" +CURL_DEPS += $(openssl) +# CURL_FLAGS += --with-secure-transport +endif +ifdef ARCH_WIN +CURL_FLAGS += --with-schannel +endif -$(libcurl): $(openssl) curl-7.64.1 +$(libcurl): $(CURL_DEPS) curl-7.64.1 cd curl-7.64.1 && PKG_CONFIG_PATH= $(CONFIGURE) $(CURL_FLAGS) $(MAKE) -C curl-7.64.1 $(MAKE) -C curl-7.64.1 install @@ -164,15 +175,15 @@ rtmidi-4.0.0: rm rtmidi-4.0.0.tar.gz RTMIDI_FLAGS += --enable-shared=no +ifdef ARCH_LIN +RTMIDI_FLAGS += --with-jack --with-alsa +endif ifdef ARCH_MAC RTMIDI_FLAGS += --with-core --without-jack endif ifdef ARCH_WIN RTMIDI_FLAGS += --with-winmm endif -ifdef ARCH_LIN -RTMIDI_FLAGS += --with-jack --with-alsa -endif $(rtmidi): rtmidi-4.0.0 cd rtmidi-4.0.0 && $(CONFIGURE) $(RTMIDI_FLAGS) @@ -180,15 +191,15 @@ $(rtmidi): rtmidi-4.0.0 $(MAKE) -C rtmidi-4.0.0 install RTAUDIO_FLAGS += -DRTAUDIO_BUILD_STATIC_LIBS=ON +ifdef ARCH_LIN +RTAUDIO_FLAGS += -DRTAUDIO_API_ALSA=ON -DRTAUDIO_API_JACK=ON -DRTAUDIO_API_PULSE=OFF -DRTAUDIO_API_OSS=OFF +endif ifdef ARCH_MAC RTAUDIO_FLAGS += -DRTAUDIO_API_CORE=ON -DRTAUDIO_API_PULSE=OFF -DRTAUDIO_API_JACK=OFF endif ifdef ARCH_WIN RTAUDIO_FLAGS += -DRTAUDIO_API_DS=ON -DRTAUDIO_API_WASAPI=ON -DRTAUDIO_API_ASIO=ON endif -ifdef ARCH_LIN -RTAUDIO_FLAGS += -DRTAUDIO_API_ALSA=ON -DRTAUDIO_API_JACK=ON -DRTAUDIO_API_PULSE=OFF -DRTAUDIO_API_OSS=OFF -endif $(rtaudio): rtaudio cd rtaudio && mkdir -p build diff --git a/include/network.hpp b/include/network.hpp index eaff1d4a..6e8484be 100644 --- a/include/network.hpp +++ b/include/network.hpp @@ -26,8 +26,6 @@ json_t *requestJson(Method method, std::string url, json_t *dataJ); bool requestDownload(std::string url, const std::string &filename, float *progress); /** URL-encodes `s` */ std::string encodeUrl(const std::string &s); -/** Computes the SHA256 of the file at `filename` */ -std::string computeSHA256File(const std::string &filename); /** Gets the path portion of the URL. */ std::string urlPath(const std::string &url); diff --git a/src/network.cpp b/src/network.cpp index 3706ec2a..a64ca28c 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -83,7 +83,7 @@ json_t *requestJson(Method method, std::string url, json_t *dataJ) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, &resText); // Perform request - // INFO("Requesting %s", url.c_str()); + // DEBUG("Requesting %s", url.c_str()); // curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); CURLcode res = curl_easy_perform(curl); @@ -155,37 +155,6 @@ std::string encodeUrl(const std::string &s) { return ret; } -std::string computeSHA256File(const std::string &filename) { - FILE *f = fopen(filename.c_str(), "rb"); - if (!f) - return ""; - - uint8_t hash[SHA256_DIGEST_LENGTH]; - SHA256_CTX sha256; - SHA256_Init(&sha256); - const int bufferLen = 1 << 15; - uint8_t *buffer = new uint8_t[bufferLen]; - int len = 0; - while ((len = fread(buffer, 1, bufferLen, f))) { - SHA256_Update(&sha256, buffer, len); - } - SHA256_Final(hash, &sha256); - delete[] buffer; - fclose(f); - - // Convert binary hash to hex - char hashHex[64]; - const char hexTable[] = "0123456789abcdef"; - for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) { - uint8_t h = hash[i]; - hashHex[2*i + 0] = hexTable[h >> 4]; - hashHex[2*i + 1] = hexTable[h & 0x0f]; - } - - std::string str(hashHex, sizeof(hashHex)); - return str; -} - std::string urlPath(const std::string &url) { CURLU *curl = curl_url(); DEFER({