Add logs to check is proxy is used
This commit is contained in:
parent
3aca263a53
commit
d423ac93e0
@ -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") {
|
||||
|
||||
@ -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,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");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user