From 45dd66278be3b436b47dfeaa045fe5e8c03c962d Mon Sep 17 00:00:00 2001 From: sectapunterx Date: Sat, 23 Nov 2024 23:25:51 +0300 Subject: [PATCH] [clang-tidy fixes & reformating] Successful connection using Connect() overload for proxy --- library/include/larra/client/client.hpp | 4 ---- tests/proxy.cpp | 22 +++++++++++----------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/library/include/larra/client/client.hpp b/library/include/larra/client/client.hpp index 50026b6..9687fb9 100644 --- a/library/include/larra/client/client.hpp +++ b/library/include/larra/client/client.hpp @@ -423,10 +423,6 @@ struct ClientCreateVisitor { boost::asio::use_awaitable); } - auto Connect(auto& socket, boost::asio::ip::tcp::resolver::results_type resolveResults) -> boost::asio::awaitable { - co_await boost::asio::async_connect(socket, resolveResults, boost::asio::use_awaitable); - } - template auto Connect(Socket& socket) -> boost::asio::awaitable { if(!std::holds_alternative(this->options.proxy)) { diff --git a/tests/proxy.cpp b/tests/proxy.cpp index 13be5f3..5b005e7 100644 --- a/tests/proxy.cpp +++ b/tests/proxy.cpp @@ -82,24 +82,24 @@ TEST(Socks5ProxyTest, ConnectViaProxy) { std::string expectedGreeting = "\x05\x01\x00"; std::array expectedRequest{}; - std::size_t req_len = 0; + std::size_t reqLen = 0; - expectedRequest[req_len++] = 0x05; // VER - expectedRequest[req_len++] = 0x01; // CMD: CONNECT - expectedRequest[req_len++] = 0x00; // RSV - expectedRequest[req_len++] = 0x03; // ATYP: DOMAINNAME + expectedRequest[reqLen++] = 0x05; // VER + expectedRequest[reqLen++] = 0x01; // CMD: CONNECT + expectedRequest[reqLen++] = 0x00; // RSV + expectedRequest[reqLen++] = 0x03; // ATYP: DOMAINNAME - expectedRequest[req_len++] = static_cast(targetHostname.size()); // domain length + expectedRequest[reqLen++] = static_cast(targetHostname.size()); // domain length - std::memcpy(&expectedRequest[req_len], targetHostname.data(), targetHostname.size()); - req_len += targetHostname.size(); + std::memcpy(&expectedRequest[reqLen], targetHostname.data(), targetHostname.size()); + reqLen += targetHostname.size(); std::uint16_t networkOrderPort = htons(targetPort); - expectedRequest[req_len++] = static_cast((networkOrderPort >> 8) & 0xFF); - expectedRequest[req_len++] = static_cast(networkOrderPort & 0xFF); + expectedRequest[reqLen++] = static_cast((networkOrderPort >> 8) & 0xFF); + expectedRequest[reqLen++] = static_cast(networkOrderPort & 0xFF); std::string expectedData = expectedGreeting; - auto transformed_view = expectedRequest | std::views::take(req_len) | std::views::transform([](std::uint8_t byte) { + auto transformed_view = expectedRequest | std::views::take(reqLen) | std::views::transform([](std::uint8_t byte) { return static_cast(byte); });