https://bugs.gentoo.org/946389 https://github.com/randombit/botan/pull/4484 From 2a406beab449a2cb310fa543451a7087ca7b4b1a Mon Sep 17 00:00:00 2001 From: q66 Date: Sun, 15 Dec 2024 02:42:02 +0100 Subject: [PATCH 1/2] Remove usage of deprecated asio API These were all finally dropped with boost 1.87, so this fixes build with boost 1.87. --- a/src/cli/tls_proxy.cpp +++ b/src/cli/tls_proxy.cpp @@ -106,11 +106,11 @@ class tls_proxy_session final : public std::enable_shared_from_this pointer; - static pointer create(boost::asio::io_service& io, + static pointer create(boost::asio::io_context& io, const std::shared_ptr& session_manager, const std::shared_ptr& credentials, const std::shared_ptr& policy, - const tcp::resolver::iterator& endpoints) { + const tcp::resolver::results_type& endpoints) { auto session = std::make_shared(io, endpoints); // Defer the setup of the TLS server to make use of @@ -144,7 +144,7 @@ class tls_proxy_session final : public std::enable_shared_from_this creds, std::shared_ptr policy, std::shared_ptr session_mgr, @@ -383,7 +383,7 @@ class tls_proxy_server final { } tcp::acceptor m_acceptor; - tcp::resolver::iterator m_server_endpoints; + tcp::resolver::results_type m_server_endpoints; std::shared_ptr m_creds; std::shared_ptr m_policy; @@ -429,10 +429,10 @@ class TLS_Proxy final : public Command { auto policy = load_tls_policy(get_arg("policy")); - boost::asio::io_service io; + boost::asio::io_context io; tcp::resolver resolver(io); - auto server_endpoint_iterator = resolver.resolve({target, target_port}); + auto server_endpoint_iterator = resolver.resolve(target, target_port); std::shared_ptr session_mgr; --- a/src/lib/utils/socket/socket.cpp +++ b/src/lib/utils/socket/socket.cpp @@ -46,20 +46,19 @@ class Asio_Socket final : public OS::Socket { public: Asio_Socket(std::string_view hostname, std::string_view service, std::chrono::milliseconds timeout) : m_timeout(timeout), m_timer(m_io), m_tcp(m_io) { - m_timer.expires_from_now(m_timeout); + m_timer.expires_after(m_timeout); check_timeout(); boost::asio::ip::tcp::resolver resolver(m_io); - boost::asio::ip::tcp::resolver::query query(std::string{hostname}, std::string{service}); - boost::asio::ip::tcp::resolver::iterator dns_iter = resolver.resolve(query); + boost::asio::ip::tcp::resolver::results_type dns_iter = resolver.resolve(std::string{hostname}, std::string{service}); boost::system::error_code ec = boost::asio::error::would_block; - auto connect_cb = [&ec](const boost::system::error_code& e, const boost::asio::ip::tcp::resolver::iterator&) { + auto connect_cb = [&ec](const boost::system::error_code& e, boost::asio::ip::tcp::resolver::results_type::iterator) { ec = e; }; - boost::asio::async_connect(m_tcp, dns_iter, connect_cb); + boost::asio::async_connect(m_tcp, dns_iter.begin(), dns_iter.end(), connect_cb); while(ec == boost::asio::error::would_block) { m_io.run_one(); @@ -74,7 +73,7 @@ class Asio_Socket final : public OS::Socket { } void write(const uint8_t buf[], size_t len) override { - m_timer.expires_from_now(m_timeout); + m_timer.expires_after(m_timeout); boost::system::error_code ec = boost::asio::error::would_block; @@ -90,7 +89,7 @@ class Asio_Socket final : public OS::Socket { } size_t read(uint8_t buf[], size_t len) override { - m_timer.expires_from_now(m_timeout); + m_timer.expires_after(m_timeout); boost::system::error_code ec = boost::asio::error::would_block; size_t got = 0; @@ -116,7 +115,7 @@ class Asio_Socket final : public OS::Socket { private: void check_timeout() { - if(m_tcp.is_open() && m_timer.expires_at() < std::chrono::system_clock::now()) { + if(m_tcp.is_open() && m_timer.expiry() < std::chrono::system_clock::now()) { boost::system::error_code err; // NOLINTNEXTLINE(bugprone-unused-return-value,cert-err33-c) @@ -127,7 +126,7 @@ class Asio_Socket final : public OS::Socket { } const std::chrono::milliseconds m_timeout; - boost::asio::io_service m_io; + boost::asio::io_context m_io; boost::asio::system_timer m_timer; boost::asio::ip::tcp::socket m_tcp; }; --- a/src/lib/utils/socket/socket_udp.cpp +++ b/src/lib/utils/socket/socket_udp.cpp @@ -46,20 +46,19 @@ class Asio_SocketUDP final : public OS::SocketUDP { public: Asio_SocketUDP(std::string_view hostname, std::string_view service, std::chrono::microseconds timeout) : m_timeout(timeout), m_timer(m_io), m_udp(m_io) { - m_timer.expires_from_now(m_timeout); + m_timer.expires_after(m_timeout); check_timeout(); boost::asio::ip::udp::resolver resolver(m_io); - boost::asio::ip::udp::resolver::query query(std::string{hostname}, std::string{service}); - boost::asio::ip::udp::resolver::iterator dns_iter = resolver.resolve(query); + boost::asio::ip::udp::resolver::results_type dns_iter = resolver.resolve(std::string{hostname}, std::string{service}); boost::system::error_code ec = boost::asio::error::would_block; - auto connect_cb = [&ec](const boost::system::error_code& e, const boost::asio::ip::udp::resolver::iterator&) { + auto connect_cb = [&ec](const boost::system::error_code& e, boost::asio::ip::udp::resolver::results_type::iterator) { ec = e; }; - boost::asio::async_connect(m_udp, dns_iter, connect_cb); + boost::asio::async_connect(m_udp, dns_iter.begin(), dns_iter.end(), connect_cb); while(ec == boost::asio::error::would_block) { m_io.run_one(); @@ -74,7 +73,7 @@ class Asio_SocketUDP final : public OS::SocketUDP { } void write(const uint8_t buf[], size_t len) override { - m_timer.expires_from_now(m_timeout); + m_timer.expires_after(m_timeout); boost::system::error_code ec = boost::asio::error::would_block; @@ -90,7 +89,7 @@ class Asio_SocketUDP final : public OS::SocketUDP { } size_t read(uint8_t buf[], size_t len) override { - m_timer.expires_from_now(m_timeout); + m_timer.expires_after(m_timeout); boost::system::error_code ec = boost::asio::error::would_block; size_t got = 0; @@ -116,7 +115,7 @@ class Asio_SocketUDP final : public OS::SocketUDP { private: void check_timeout() { - if(m_udp.is_open() && m_timer.expires_at() < std::chrono::system_clock::now()) { + if(m_udp.is_open() && m_timer.expiry() < std::chrono::system_clock::now()) { boost::system::error_code err; // NOLINTNEXTLINE(bugprone-unused-return-value,cert-err33-c) @@ -127,7 +126,7 @@ class Asio_SocketUDP final : public OS::SocketUDP { } const std::chrono::microseconds m_timeout; - boost::asio::io_service m_io; + boost::asio::io_context m_io; boost::asio::system_timer m_timer; boost::asio::ip::udp::socket m_udp; }; From 3820f357017eacef1fcb5119582bc9789b88f6c2 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Wed, 18 Dec 2024 17:10:34 -0500 Subject: [PATCH 2/2] Address review comments --- a/src/cli/tls_proxy.cpp +++ b/src/cli/tls_proxy.cpp @@ -287,7 +287,7 @@ class tls_proxy_session final : public std::enable_shared_from_this& req) : m_request(req), @@ -46,7 +46,8 @@ class client { host)), m_stream(io_context, m_ctx) { boost::asio::async_connect(m_stream.lowest_layer(), - std::move(endpoint_iterator), + endpoints.begin(), + endpoints.end(), boost::bind(&client::handle_connect, this, ap::error)); } @@ -111,8 +112,7 @@ int main(int argc, char* argv[]) { boost::asio::io_context io_context; boost::asio::ip::tcp::resolver resolver(io_context); - boost::asio::ip::tcp::resolver::query query(host, port); - boost::asio::ip::tcp::resolver::iterator iterator = resolver.resolve(query); + boost::asio::ip::tcp::resolver::results_type endpoints = resolver.resolve(host, port); http::request req; req.version(11); @@ -121,7 +121,7 @@ int main(int argc, char* argv[]) { req.set(http::field::host, host); req.set(http::field::user_agent, Botan::version_string()); - client c(io_context, iterator, host, req); + client c(io_context, endpoints, host, req); io_context.run(); } catch(std::exception& e) { --- a/src/lib/utils/socket/socket.cpp +++ b/src/lib/utils/socket/socket.cpp @@ -50,13 +50,12 @@ class Asio_Socket final : public OS::Socket { check_timeout(); boost::asio::ip::tcp::resolver resolver(m_io); - boost::asio::ip::tcp::resolver::results_type dns_iter = resolver.resolve(std::string{hostname}, std::string{service}); + boost::asio::ip::tcp::resolver::results_type dns_iter = + resolver.resolve(std::string{hostname}, std::string{service}); boost::system::error_code ec = boost::asio::error::would_block; - auto connect_cb = [&ec](const boost::system::error_code& e, boost::asio::ip::tcp::resolver::results_type::iterator) { - ec = e; - }; + auto connect_cb = [&ec](const boost::system::error_code& e, const auto&) { ec = e; }; boost::asio::async_connect(m_tcp, dns_iter.begin(), dns_iter.end(), connect_cb); --- a/src/lib/utils/socket/socket_udp.cpp +++ b/src/lib/utils/socket/socket_udp.cpp @@ -50,13 +50,13 @@ class Asio_SocketUDP final : public OS::SocketUDP { check_timeout(); boost::asio::ip::udp::resolver resolver(m_io); - boost::asio::ip::udp::resolver::results_type dns_iter = resolver.resolve(std::string{hostname}, std::string{service}); + boost::asio::ip::udp::resolver::results_type dns_iter = + resolver.resolve(std::string{hostname}, std::string{service}); boost::system::error_code ec = boost::asio::error::would_block; - auto connect_cb = [&ec](const boost::system::error_code& e, boost::asio::ip::udp::resolver::results_type::iterator) { - ec = e; - }; + auto connect_cb = [&ec](const boost::system::error_code& e, + const boost::asio::ip::udp::resolver::results_type::iterator&) { ec = e; }; boost::asio::async_connect(m_udp, dns_iter.begin(), dns_iter.end(), connect_cb);