https://bugs.gentoo.org/946389 https://github.com/randombit/botan/commit/37fec38ff97604f964122cd2d33f5d503f319b10 From 37fec38ff97604f964122cd2d33f5d503f319b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Meusel?= Date: Thu, 19 Dec 2024 10:28:40 +0100 Subject: [PATCH] Backport: Remove usage of deprecated asio API These were all finally dropped with boost 1.87, so this fixes build with boost 1.87. Co-Authored-By: Jack Lloyd Co-Authored-By: q66 --- src/cli/tls_http_server.cpp | 16 +++++----- src/cli/tls_proxy.cpp | 46 ++++++++++++++++------------- src/lib/utils/socket/socket.cpp | 18 +++++------ src/lib/utils/socket/socket_udp.cpp | 18 +++++------ 4 files changed, 50 insertions(+), 48 deletions(-) diff --git a/src/cli/tls_http_server.cpp b/src/cli/tls_http_server.cpp index fc0b5bbb77e..67ab126b145 100644 --- a/src/cli/tls_http_server.cpp +++ b/src/cli/tls_http_server.cpp @@ -176,7 +176,7 @@ class TLS_Asio_HTTP_Session final : public std::enable_shared_from_this pointer; static pointer create( - boost::asio::io_service& io, + boost::asio::io_context& io, Botan::TLS::Session_Manager& session_manager, Botan::Credentials_Manager& credentials, Botan::TLS::Policy& policy) @@ -201,7 +201,7 @@ class TLS_Asio_HTTP_Session final : public std::enable_shared_from_this pointer; static pointer create( - boost::asio::io_service& io, + boost::asio::io_context& io, Botan::TLS::Session_Manager& session_manager, Botan::Credentials_Manager& credentials, Botan::TLS::Policy& policy, - tcp::resolver::iterator endpoints) + tcp::resolver::results_type endpoints) { return pointer( new tls_proxy_session( @@ -141,11 +141,11 @@ class tls_proxy_session final : public std::enable_shared_from_this session_mgr; diff --git a/src/lib/utils/socket/socket.cpp b/src/lib/utils/socket/socket.cpp index bc632259a64..0ce4e85830f 100644 --- a/src/lib/utils/socket/socket.cpp +++ b/src/lib/utils/socket/socket.cpp @@ -48,19 +48,17 @@ class Asio_Socket final : public OS::Socket 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(hostname, service); - boost::asio::ip::tcp::resolver::iterator dns_iter = resolver.resolve(query); + boost::asio::ip::tcp::resolver::results_type endpoints = resolver.resolve(hostname, 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::iterator) { ec = e; }; - - boost::asio::async_connect(m_tcp, dns_iter, connect_cb); + const boost::asio::ip::tcp::resolver::results_type::iterator&) { ec = e; }; + boost::asio::async_connect(m_tcp, endpoints.begin(), endpoints.end(), connect_cb); while(ec == boost::asio::error::would_block) { @@ -75,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; @@ -92,7 +90,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; @@ -115,7 +113,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; m_tcp.close(err); @@ -125,7 +123,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; }; diff --git a/src/lib/utils/socket/socket_udp.cpp b/src/lib/utils/socket/socket_udp.cpp index fbbdd9abbcc..82a25b49cda 100644 --- a/src/lib/utils/socket/socket_udp.cpp +++ b/src/lib/utils/socket/socket_udp.cpp @@ -48,19 +48,17 @@ class Asio_SocketUDP final : public OS::SocketUDP 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(hostname, service); - boost::asio::ip::udp::resolver::iterator dns_iter = resolver.resolve(query); + boost::asio::ip::udp::resolver::results_type endpoints = resolver.resolve(hostname, 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::iterator) { ec = e; }; - - boost::asio::async_connect(m_udp, dns_iter, connect_cb); + const boost::asio::ip::udp::resolver::results_type::iterator&) { ec = e; }; + boost::asio::async_connect(m_udp, endpoints.begin(), endpoints.end(), connect_cb); while(ec == boost::asio::error::would_block) { @@ -75,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; @@ -95,7 +93,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; @@ -121,7 +119,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; m_udp.close(err); @@ -131,7 +129,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; };