From 71c0d2516b0f3ef74040e0b7091895af8d5a770b Mon Sep 17 00:00:00 2001 From: "Jens A. Koch" Date: Tue, 20 Oct 2020 23:55:04 +0200 Subject: [PATCH] prepopulate dns-cache, ref. #8 - moved definition of host variable to header file --- src/ShareCodeUpload.cpp | 9 +++++++++ src/ShareCodeUpload.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/ShareCodeUpload.cpp b/src/ShareCodeUpload.cpp index 52af8de..74441f9 100644 --- a/src/ShareCodeUpload.cpp +++ b/src/ShareCodeUpload.cpp @@ -8,10 +8,15 @@ ShareCodeUpload::ShareCodeUpload(bool verboseMode) { verbose = verboseMode; curl = initCurlConnection(); + + host = curl_slist_append(NULL, "csgostats.gg:80:104.18.76.107"); + host = curl_slist_append(host, "csgostats.gg:443:104.18.76.107"); } ShareCodeUpload::~ShareCodeUpload() { + curl_slist_free_all(host); + curl_easy_cleanup(curl); } @@ -53,6 +58,8 @@ CURL* ShareCodeUpload::initCurlConnection() // provide a buffer for storing errors curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer); + curl_easy_setopt(curl, CURLOPT_RESOLVE, host); + // 1. URL that is about to receive our GET request curl_easy_setopt(curl, CURLOPT_URL, "https://csgostats.gg/"); @@ -145,6 +152,8 @@ int ShareCodeUpload::uploadShareCode(std::string shareCode, std::string& respons // set the error buffer as empty before performing a request errorBuffer[0] = 0; + curl_easy_setopt(curl, CURLOPT_RESOLVE, host); + // 1. URL that is about to receive our POST data curl_easy_setopt(curl, CURLOPT_URL, "https://csgostats.gg/match/upload/ajax"); diff --git a/src/ShareCodeUpload.h b/src/ShareCodeUpload.h index 8d7b42d..3ffa228 100644 --- a/src/ShareCodeUpload.h +++ b/src/ShareCodeUpload.h @@ -25,6 +25,8 @@ class ShareCodeUpload private: CURL *curl = nullptr; bool verbose = false; + + struct curl_slist *host = NULL; CURL* initCurlConnection(); };