Skip to content

Commit

Permalink
Allow setting proxy server from the config
Browse files Browse the repository at this point in the history
  • Loading branch information
crsib committed Oct 26, 2023
1 parent fa0fbb2 commit 02fceab
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions libraries/lib-network-manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ set( SOURCES

set ( LIBRARIES
lib-string-utils-interface
lib-preferences-interface
PRIVATE
CURL::libcurl
threadpool::threadpool
Expand Down
26 changes: 25 additions & 1 deletion libraries/lib-network-manager/curl/CurlHandleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

#include <wx/platinfo.h>

#include "Prefs.h"
#include "CodeConversions.h"

namespace audacity
{
namespace network_manager
Expand Down Expand Up @@ -60,6 +63,22 @@ void GetOSString (std::ostringstream& output, const wxPlatformInfo& platformInfo
#endif
}

BoolSetting EnableSSLValidationPref { "/CURL/EnableSSLValidation", true };
StringSetting ProxyStringPref { "/CURL/Proxy", "" };

struct CurlConfig final : private PrefsListener
{
std::string Proxy;
bool SSLValidation { true };

void UpdatePrefs() override
{
SSLValidation = EnableSSLValidationPref.Read();
Proxy = audacity::ToUTF8(ProxyStringPref.Read());
}
};

static CurlConfig gCurlConfig;
}

constexpr std::chrono::milliseconds CurlHandleManager::KEEP_ALIVE_IDLE;
Expand Down Expand Up @@ -104,7 +123,10 @@ CurlHandleManager::Handle::Handle(CurlHandleManager* owner, CURL* handle, Reques

setOption (CURLOPT_NOSIGNAL, 1L);

enableSSLValidation();
if (gCurlConfig.SSLValidation)
enableSSLValidation();
else
disableSSLValidation();

setOption (CURLOPT_ACCEPT_ENCODING, "");
}
Expand Down Expand Up @@ -256,6 +278,8 @@ CurlHandleManager::CurlHandleManager ()
ss << ")";

mUserAgent = ss.str ();

mProxy = gCurlConfig.Proxy;
}

CurlHandleManager::~CurlHandleManager ()
Expand Down

0 comments on commit 02fceab

Please sign in to comment.