Skip to content

Commit

Permalink
prepopulate dns-cache, ref. #8 - moved definition of host variable to…
Browse files Browse the repository at this point in the history
… header file
  • Loading branch information
jakoch committed Oct 20, 2020
1 parent 06282ed commit 71c0d25
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/ShareCodeUpload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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/");

Expand Down Expand Up @@ -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");

Expand Down
2 changes: 2 additions & 0 deletions src/ShareCodeUpload.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class ShareCodeUpload
private:
CURL *curl = nullptr;
bool verbose = false;

struct curl_slist *host = NULL;

CURL* initCurlConnection();
};
Expand Down

0 comments on commit 71c0d25

Please sign in to comment.