From d423ac93e05cdc870dabb4f6b0a05813787afc1f Mon Sep 17 00:00:00 2001 From: Bartosz Wieczorek Date: Thu, 5 Jun 2025 11:32:30 +0200 Subject: [PATCH] Add logs to check is proxy is used --- PAM/ssh/include/rublon/curl.hpp | 4 +++- PAM/ssh/include/rublon/websockets.hpp | 24 +++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/PAM/ssh/include/rublon/curl.hpp b/PAM/ssh/include/rublon/curl.hpp index eb020a3..8ace39f 100644 --- a/PAM/ssh/include/rublon/curl.hpp +++ b/PAM/ssh/include/rublon/curl.hpp @@ -23,7 +23,7 @@ namespace { struct Request { std::pmr::memory_resource * _mr; - + std::pmr::map< std::pmr::string, std::pmr::string > headers; std::pmr::string body; @@ -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") { diff --git a/PAM/ssh/include/rublon/websockets.hpp b/PAM/ssh/include/rublon/websockets.hpp index a95d3e2..c2807ad 100644 --- a/PAM/ssh/include/rublon/websockets.hpp +++ b/PAM/ssh/include/rublon/websockets.hpp @@ -1,21 +1,20 @@ #pragma once -#include "rublon/configuration.hpp" -#include "rublon/json.hpp" -#include "rublon/memory.hpp" -#include "rublon/static_string.hpp" -#include #include #include #include #include -#include -#include -#include - #include #include +#include +#include +#include +#include +#include +#include +#include + #include #include @@ -77,7 +76,8 @@ 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}; proxyUrl.reserve(conservative_estimate(cfg.proxyUsername, cfg.proxyPass, cfg.proxyServer, cfg.proxyPort) + 10); @@ -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); } @@ -211,7 +213,7 @@ class WebSocket { case LWS_CALLBACK_CLIENT_WRITEABLE: { // Perform the Socket.IO 4.x handshake (send `40` message) const std::string_view handshake = "40"; - unsigned char buf[64]={}; + unsigned char buf[64] = {}; memcpy(&buf[LWS_PRE], handshake.data(), handshake.size()); lws_write(wsi, &buf[LWS_PRE], handshake.size(), LWS_WRITE_TEXT); log(LogLevel::Debug, "WebSocket Sent Socket.IO handshake");