Possible to use https:// for map downloads, but still use http:// by default

This commit is contained in:
def 2017-07-16 10:45:41 +02:00
parent a736a27430
commit c7c9c3c4dd
4 changed files with 13 additions and 9 deletions

View file

@ -1631,8 +1631,8 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
char aEscaped[128]; char aEscaped[128];
str_format(aFilename, sizeof(aFilename), "%s_%08x.map", pMap, MapCrc); str_format(aFilename, sizeof(aFilename), "%s_%08x.map", pMap, MapCrc);
Fetcher()->Escape(aEscaped, sizeof(aEscaped), aFilename); Fetcher()->Escape(aEscaped, sizeof(aEscaped), aFilename);
str_format(aUrl, sizeof(aUrl), "http://%s/%s", g_Config.m_ClDDNetMapServer, aEscaped); str_format(aUrl, sizeof(aUrl), "%s/%s", g_Config.m_ClDDNetMapServer, aEscaped);
m_pMapdownloadTask = new CFetchTask(true); m_pMapdownloadTask = new CFetchTask(true, false);
Fetcher()->QueueAdd(m_pMapdownloadTask, aUrl, m_aMapdownloadFilename, IStorage::TYPE_SAVE); Fetcher()->QueueAdd(m_pMapdownloadTask, aUrl, m_aMapdownloadFilename, IStorage::TYPE_SAVE);
} }
else else

View file

@ -3,10 +3,11 @@
#include <engine/shared/config.h> #include <engine/shared/config.h>
#include "fetcher.h" #include "fetcher.h"
CFetchTask::CFetchTask(bool canTimeout) CFetchTask::CFetchTask(bool canTimeout, bool useDDNetCA)
{ {
m_pNext = NULL; m_pNext = NULL;
m_CanTimeout = canTimeout; m_CanTimeout = canTimeout;
m_UseDDNetCA = useDDNetCA;
} }
CFetcher::CFetcher() CFetcher::CFetcher()
@ -115,9 +116,6 @@ void CFetcher::FetchFile(CFetchTask *pTask)
return; return;
} }
char aCAFile[512];
m_pStorage->GetBinaryPath("data/ca-ddnet.pem", aCAFile, sizeof aCAFile);
char aErr[CURL_ERROR_SIZE]; char aErr[CURL_ERROR_SIZE];
curl_easy_setopt(m_pHandle, CURLOPT_ERRORBUFFER, aErr); 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_FOLLOWLOCATION, 1L);
curl_easy_setopt(m_pHandle, CURLOPT_MAXREDIRS, 4L); curl_easy_setopt(m_pHandle, CURLOPT_MAXREDIRS, 4L);
curl_easy_setopt(m_pHandle, CURLOPT_FAILONERROR, 1L); curl_easy_setopt(m_pHandle, CURLOPT_FAILONERROR, 1L);
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_CAINFO, aCAFile);
}
curl_easy_setopt(m_pHandle, CURLOPT_URL, pTask->m_aUrl); curl_easy_setopt(m_pHandle, CURLOPT_URL, pTask->m_aUrl);
curl_easy_setopt(m_pHandle, CURLOPT_WRITEDATA, File); curl_easy_setopt(m_pHandle, CURLOPT_WRITEDATA, File);
curl_easy_setopt(m_pHandle, CURLOPT_WRITEFUNCTION, &CFetcher::WriteToFile); curl_easy_setopt(m_pHandle, CURLOPT_WRITEFUNCTION, &CFetcher::WriteToFile);

View file

@ -71,7 +71,7 @@ void CUpdater::FetchFile(const char *pFile, const char *pDestPath)
if(!pDestPath) if(!pDestPath)
pDestPath = pFile; pDestPath = pFile;
str_format(aPath, sizeof(aPath), "update/%s", pDestPath); 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); m_pFetcher->QueueAdd(Task, aBuf, aPath, -2, this, &CUpdater::CompletionCallback, &CUpdater::ProgressCallback);
} }

View file

@ -28,8 +28,9 @@ class CFetchTask
bool m_Abort; bool m_Abort;
bool m_CanTimeout; bool m_CanTimeout;
int m_StorageType; int m_StorageType;
bool m_UseDDNetCA;
public: public:
CFetchTask(bool canTimeout); CFetchTask(bool canTimeout, bool useDDNetCA);
enum enum
{ {