Browse Source

Use schannel on Win instead of OpenSSL

tags/v1.1.2
Andrew Belt 5 years ago
parent
commit
7ac7fa8486
3 changed files with 19 additions and 41 deletions
  1. +18
    -7
      dep/Makefile
  2. +0
    -2
      include/network.hpp
  3. +1
    -32
      src/network.cpp

+ 18
- 7
dep/Makefile View File

@@ -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


+ 0
- 2
include/network.hpp View File

@@ -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);



+ 1
- 32
src/network.cpp View File

@@ -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({


Loading…
Cancel
Save