From c7c9c3c4dd09b07890a02ef4abbec4fcb3f2dd86 Mon Sep 17 00:00:00 2001 From: def Date: Sun, 16 Jul 2017 10:45:41 +0200 Subject: [PATCH] Possible to use https:// for map downloads, but still use http:// by default --- src/engine/client/client.cpp | 4 ++-- src/engine/client/fetcher.cpp | 13 ++++++++----- src/engine/client/updater.cpp | 2 +- src/engine/fetcher.h | 3 ++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 13e784c89..d516575ed 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1631,8 +1631,8 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket) char aEscaped[128]; str_format(aFilename, sizeof(aFilename), "%s_%08x.map", pMap, MapCrc); Fetcher()->Escape(aEscaped, sizeof(aEscaped), aFilename); - str_format(aUrl, sizeof(aUrl), "http://%s/%s", g_Config.m_ClDDNetMapServer, aEscaped); - m_pMapdownloadTask = new CFetchTask(true); + str_format(aUrl, sizeof(aUrl), "%s/%s", g_Config.m_ClDDNetMapServer, aEscaped); + m_pMapdownloadTask = new CFetchTask(true, false); Fetcher()->QueueAdd(m_pMapdownloadTask, aUrl, m_aMapdownloadFilename, IStorage::TYPE_SAVE); } else diff --git a/src/engine/client/fetcher.cpp b/src/engine/client/fetcher.cpp index 06c096707..cb251be34 100644 --- a/src/engine/client/fetcher.cpp +++ b/src/engine/client/fetcher.cpp @@ -3,10 +3,11 @@ #include #include "fetcher.h" -CFetchTask::CFetchTask(bool canTimeout) +CFetchTask::CFetchTask(bool canTimeout, bool useDDNetCA) { m_pNext = NULL; m_CanTimeout = canTimeout; + m_UseDDNetCA = useDDNetCA; } CFetcher::CFetcher() @@ -115,9 +116,6 @@ void CFetcher::FetchFile(CFetchTask *pTask) return; } - char aCAFile[512]; - m_pStorage->GetBinaryPath("data/ca-ddnet.pem", aCAFile, sizeof aCAFile); - char aErr[CURL_ERROR_SIZE]; curl_easy_setopt(m_pHandle, CURLOPT_ERRORBUFFER, aErr); @@ -137,7 +135,12 @@ void CFetcher::FetchFile(CFetchTask *pTask) curl_easy_setopt(m_pHandle, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(m_pHandle, CURLOPT_MAXREDIRS, 4L); curl_easy_setopt(m_pHandle, CURLOPT_FAILONERROR, 1L); - curl_easy_setopt(m_pHandle, CURLOPT_CAINFO, aCAFile); + if(pTask->m_UseDDNetCA) + { + char aCAFile[512]; + m_pStorage->GetBinaryPath("data/ca-ddnet.pem", aCAFile, sizeof aCAFile); + curl_easy_setopt(m_pHandle, CURLOPT_CAINFO, aCAFile); + } curl_easy_setopt(m_pHandle, CURLOPT_URL, pTask->m_aUrl); curl_easy_setopt(m_pHandle, CURLOPT_WRITEDATA, File); curl_easy_setopt(m_pHandle, CURLOPT_WRITEFUNCTION, &CFetcher::WriteToFile); diff --git a/src/engine/client/updater.cpp b/src/engine/client/updater.cpp index 40c6e9011..eb7d58474 100644 --- a/src/engine/client/updater.cpp +++ b/src/engine/client/updater.cpp @@ -71,7 +71,7 @@ void CUpdater::FetchFile(const char *pFile, const char *pDestPath) if(!pDestPath) pDestPath = pFile; str_format(aPath, sizeof(aPath), "update/%s", pDestPath); - CFetchTask *Task = new CFetchTask(false); + CFetchTask *Task = new CFetchTask(false, true); m_pFetcher->QueueAdd(Task, aBuf, aPath, -2, this, &CUpdater::CompletionCallback, &CUpdater::ProgressCallback); } diff --git a/src/engine/fetcher.h b/src/engine/fetcher.h index 2d747f430..ab6ea710b 100644 --- a/src/engine/fetcher.h +++ b/src/engine/fetcher.h @@ -28,8 +28,9 @@ class CFetchTask bool m_Abort; bool m_CanTimeout; int m_StorageType; + bool m_UseDDNetCA; public: - CFetchTask(bool canTimeout); + CFetchTask(bool canTimeout, bool useDDNetCA); enum {