Add logs to check is proxy is used

This commit is contained in:
Bartosz Wieczorek 2025-06-05 11:32:30 +02:00
parent 3aca263a53
commit d423ac93e0
2 changed files with 16 additions and 12 deletions

View File

@ -90,6 +90,7 @@ class CURL {
// configuration reader check if proxy has needed fields
assert(conf().proxyType.has_value());
assert(conf().proxyServer.has_value());
log(LogLevel::Debug, "CURL using proxy");
std::pmr::string proxyUrl{&memoryResource};
proxyUrl.reserve(conservative_estimate(conf().proxyType, conf().proxyServer, conf().proxyPort) + 10);
@ -103,6 +104,7 @@ class CURL {
proxyUrl += std::to_string(*conf().proxyPort);
}
log(LogLevel::Debug, "CURL using %s", proxyUrl.c_str());
curl_easy_setopt(curl.get(), CURLOPT_PROXY, proxyUrl.c_str());
if(conf().proxyType == "socks4") {

View File

@ -1,21 +1,20 @@
#pragma once
#include "rublon/configuration.hpp"
#include "rublon/json.hpp"
#include "rublon/memory.hpp"
#include "rublon/static_string.hpp"
#include <array>
#include <chrono>
#include <cstdio>
#include <cstring>
#include <functional>
#include <rublon/error.hpp>
#include <rublon/pam_action.hpp>
#include <rublon/utils.hpp>
#include <string>
#include <string_view>
#include <rublon/configuration.hpp>
#include <rublon/error.hpp>
#include <rublon/json.hpp>
#include <rublon/memory.hpp>
#include <rublon/pam_action.hpp>
#include <rublon/static_string.hpp>
#include <rublon/utils.hpp>
#include <libwebsockets.h>
#include <unistd.h>
@ -77,6 +76,7 @@ class WebSocket {
if(cfg.proxyEnabled && (cfg.proxyType == "http" || cfg.proxyType == "https")) {
assert(cfg.proxyType.has_value());
assert(cfg.proxyServer.has_value());
log(LogLevel::Debug, "WebSocket using proxy");
memory::Monotonic_8k_Resource memoryResource;
std::pmr::string proxyUrl{&memoryResource};
@ -99,6 +99,8 @@ class WebSocket {
}
// Set environment variable for libwebsockets to pick up
log(LogLevel::Debug, "WebSocket proxy %s", proxyUrl.c_str());
setenv((cfg.proxyType == "https" ? "https_proxy" : "http_proxy"), proxyUrl.c_str(), 1);
}