From ca9143dde93a0a057682ad433830ee95aaaf7bf6 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 30 Jan 2023 00:04:11 +0100 Subject: [PATCH] Add curl cvars for debugging --- r5dev/tier1/IConVar.cpp | 3 +++ r5dev/tier1/cvar.cpp | 3 +++ r5dev/tier1/cvar.h | 3 +++ r5dev/tier2/curlutils.cpp | 8 ++++++++ 4 files changed, 17 insertions(+) diff --git a/r5dev/tier1/IConVar.cpp b/r5dev/tier1/IConVar.cpp index 6e22e846..b1e1577e 100644 --- a/r5dev/tier1/IConVar.cpp +++ b/r5dev/tier1/IConVar.cpp @@ -72,6 +72,9 @@ void ConVar::Init(void) cm_unset_all_cmdquery = ConVar::Create("cm_unset_all_cmdquery" , "0", FCVAR_DEVELOPMENTONLY | FCVAR_REPLICATED, "Returns false on every ConVar/ConCommand query ( !warning! ).", false, 0.f, false, 0.f, nullptr, nullptr); + curl_debug = ConVar::Create("curl_debug", "0", FCVAR_DEVELOPMENTONLY, "Determines whether or not to enable curl debug logging.", false, 0.f, false, 0.f, nullptr, "1 = curl logs; 0 (zero) = no logs."); + ssl_verify_peer = ConVar::Create("ssl_verify_peer", "1", FCVAR_DEVELOPMENTONLY, "Verify the authenticity of the peer's SSL certificate.", false, 0.f, false, 0.f, nullptr, "1 = curl verifies; 0 (zero) = no verification."); + rcon_address = ConVar::Create("rcon_address", "localhost", FCVAR_SERVER_CANNOT_QUERY | FCVAR_DONTRECORD | FCVAR_RELEASE, "Remote server access address.", false, 0.f, false, 0.f, nullptr, nullptr); rcon_password = ConVar::Create("rcon_password", "" , FCVAR_SERVER_CANNOT_QUERY | FCVAR_DONTRECORD | FCVAR_RELEASE, "Remote server access password (rcon is disabled if empty).", false, 0.f, false, 0.f, &RCON_PasswordChanged_f, nullptr); diff --git a/r5dev/tier1/cvar.cpp b/r5dev/tier1/cvar.cpp index bd78b724..8fa35894 100644 --- a/r5dev/tier1/cvar.cpp +++ b/r5dev/tier1/cvar.cpp @@ -32,6 +32,9 @@ ConVar* hostport = nullptr; ConVar* host_hasIrreversibleShutdown = nullptr; ConVar* mp_gamemode = nullptr; +ConVar* curl_debug = nullptr; +ConVar* ssl_verify_peer = nullptr; + ConVar* rcon_address = nullptr; ConVar* rcon_password = nullptr; diff --git a/r5dev/tier1/cvar.h b/r5dev/tier1/cvar.h index 1550a66a..939b736c 100644 --- a/r5dev/tier1/cvar.h +++ b/r5dev/tier1/cvar.h @@ -29,6 +29,9 @@ extern ConVar* host_hasIrreversibleShutdown; extern ConVar* mp_gamemode; +extern ConVar* curl_debug; +extern ConVar* ssl_verify_peer; + extern ConVar* rcon_address; extern ConVar* rcon_password; diff --git a/r5dev/tier2/curlutils.cpp b/r5dev/tier2/curlutils.cpp index 2faf653c..2b4bb2fa 100644 --- a/r5dev/tier2/curlutils.cpp +++ b/r5dev/tier2/curlutils.cpp @@ -4,6 +4,7 @@ // //===========================================================================// #include "core/stdafx.h" +#include "tier1/cvar.h" #include "curlutils.h" size_t CURLWriteStringCallback(char* contents, size_t size, size_t nmemb, void* userp) @@ -43,6 +44,13 @@ CURL* CURLInitRequest(const string& hostname, const string& request, string& res curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CURLWriteStringCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response); + curl_easy_setopt(curl, CURLOPT_VERBOSE, curl_debug->GetBool()); + + if (!ssl_verify_peer->GetBool()) + { + curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); + } + return curl; }