mirror-chatterino2/src/providers/NetworkConfigurationProvider.hpp
nerix e377c30192
Add Crashpad Support on Windows (#4351)
* feat: crashpad on windows

* feat: inline it

* feat: more crashpad

* chore: remove qBreakpad

* fix: add mention to crashpad

* refactor: version string

* feat: add crashpad module

* refactor: build crashpad from source

* fix: minor adjustments

* chore: add changelog entry

* fix: formatting and include

* fix: format

* build: use flags similar to release profile

* ci: build with crashpad on windows

* ci: recurse submodules

* ci: always include crashpad

* fix: try 7z

for some reason zstd just doesn't run

* fix: wrong path for symbols

* fix: copy

pls don't build

* ci: use new cache key

* fix: missing pragma

* ci: add workflow without crashpad

* docs: elevate changelog entry

* fix: add link to cmake issue

* fix: windows include issue

Someone (crashpad) includes Windows.h before winsock2.h

* fix: working directory

* fix: another working directory
2023-02-12 20:36:58 +01:00

59 lines
1.5 KiB
C++

#pragma once
#include "common/QLogging.hpp"
#include <QNetworkProxy>
#include <websocketpp/error.hpp>
#include <string>
namespace chatterino {
class Env;
/** This class manipulates the global network configuration (e.g. proxies). */
class NetworkConfigurationProvider
{
public:
/** This class should never be instantiated. */
NetworkConfigurationProvider() = delete;
/**
* Applies the configuration requested from the environment variables.
*
* Currently a proxy is applied if configured.
*/
static void applyFromEnv(const Env &env);
static void applyToWebSocket(const auto &connection)
{
const auto applicationProxy = QNetworkProxy::applicationProxy();
if (applicationProxy.type() != QNetworkProxy::HttpProxy)
{
return;
}
std::string url = "http://";
url += applicationProxy.hostName().toStdString();
url += ":";
url += std::to_string(applicationProxy.port());
websocketpp::lib::error_code ec;
connection->set_proxy(url, ec);
if (ec)
{
qCDebug(chatterinoNetwork)
<< "Couldn't set websocket proxy:" << ec.value();
return;
}
connection->set_proxy_basic_auth(
applicationProxy.user().toStdString(),
applicationProxy.password().toStdString(), ec);
if (ec)
{
qCDebug(chatterinoNetwork)
<< "Couldn't set websocket proxy auth:" << ec.value();
}
}
};
} // namespace chatterino