diff options
Diffstat (limited to 'src/net')
| -rw-r--r-- | src/net/parse.cpp | 2 | ||||
| -rw-r--r-- | src/net/socks.cpp | 18 | ||||
| -rw-r--r-- | src/net/socks.h | 4 | ||||
| -rw-r--r-- | src/net/socks_connect.cpp | 2 |
4 files changed, 14 insertions, 12 deletions
diff --git a/src/net/parse.cpp b/src/net/parse.cpp index b76aefad7..f989d7de4 100644 --- a/src/net/parse.cpp +++ b/src/net/parse.cpp @@ -84,7 +84,7 @@ namespace net return i2p_address::make(address); boost::system::error_code ec; - boost::asio::ip::address_v6 v6 = boost::asio::ip::address_v6::from_string(host_str, ec); + boost::asio::ip::address_v6 v6 = boost::asio::ip::make_address_v6(host_str, ec); ipv6 = !ec; std::uint16_t port = default_port; diff --git a/src/net/socks.cpp b/src/net/socks.cpp index 97ef4a672..43d98024b 100644 --- a/src/net/socks.cpp +++ b/src/net/socks.cpp @@ -29,7 +29,9 @@ #include "socks.h" #include <algorithm> +#include <boost/asio/bind_executor.hpp> #include <boost/asio/buffer.hpp> +#include <boost/asio/dispatch.hpp> #include <boost/asio/read.hpp> #include <boost/asio/write.hpp> #include <boost/endian/arithmetic.hpp> @@ -176,7 +178,7 @@ namespace socks { std::shared_ptr<client> self_; - static boost::asio::mutable_buffers_1 get_buffer(client& self) noexcept + static boost::asio::mutable_buffer get_buffer(client& self) noexcept { static_assert(sizeof(v4_header) <= sizeof(self.buffer_), "buffer too small for v4 response"); return boost::asio::buffer(self.buffer_, sizeof(v4_header)); @@ -192,7 +194,7 @@ namespace socks else if (bytes < self.buffer().size()) self.done(socks::error::bad_write, std::move(self_)); else - boost::asio::async_read(self.proxy_, get_buffer(self), self.strand_.wrap(completed{std::move(self_)})); + boost::asio::async_read(self.proxy_, get_buffer(self), boost::asio::bind_executor(self.strand_, completed{std::move(self_)})); } } }; @@ -201,7 +203,7 @@ namespace socks { std::shared_ptr<client> self_; - static boost::asio::const_buffers_1 get_buffer(client const& self) noexcept + static boost::asio::const_buffer get_buffer(client const& self) noexcept { return boost::asio::buffer(self.buffer_, self.buffer_size_); } @@ -214,13 +216,13 @@ namespace socks if (error) self.done(error, std::move(self_)); else - boost::asio::async_write(self.proxy_, get_buffer(self), self.strand_.wrap(read{std::move(self_)})); + boost::asio::async_write(self.proxy_, get_buffer(self), boost::asio::bind_executor(self.strand_, read{std::move(self_)})); } } }; client::client(stream_type::socket&& proxy, socks::version ver) - : proxy_(std::move(proxy)), strand_(GET_IO_SERVICE(proxy_)), buffer_size_(0), buffer_(), ver_(ver) + : proxy_(std::move(proxy)), strand_(proxy_.get_executor()), buffer_size_(0), buffer_(), ver_(ver) {} client::~client() {} @@ -295,7 +297,7 @@ namespace socks if (self && !self->buffer().empty()) { client& alias = *self; - alias.proxy_.async_connect(proxy_address, alias.strand_.wrap(write{std::move(self)})); + alias.proxy_.async_connect(proxy_address, boost::asio::bind_executor(alias.strand_, write{std::move(self)})); return true; } return false; @@ -306,7 +308,7 @@ namespace socks if (self && !self->buffer().empty()) { client& alias = *self; - boost::asio::async_write(alias.proxy_, write::get_buffer(alias), alias.strand_.wrap(read{std::move(self)})); + boost::asio::async_write(alias.proxy_, write::get_buffer(alias), boost::asio::bind_executor(alias.strand_, read{std::move(self)})); return true; } return false; @@ -317,7 +319,7 @@ namespace socks if (self_ && error != boost::system::errc::operation_canceled) { const std::shared_ptr<client> self = std::move(self_); - self->strand_.dispatch([self] () + boost::asio::dispatch(self->strand_, [self] () { if (self && self->proxy_.is_open()) { diff --git a/src/net/socks.h b/src/net/socks.h index af67d4abe..1c80ece2c 100644 --- a/src/net/socks.h +++ b/src/net/socks.h @@ -29,8 +29,8 @@ #pragma once #include <cstdint> +#include <boost/asio/io_context.hpp> #include <boost/asio/ip/tcp.hpp> -#include <boost/asio/io_service.hpp> #include <boost/asio/strand.hpp> #include <boost/system/error_code.hpp> #include <boost/type_traits/integral_constant.hpp> @@ -93,7 +93,7 @@ namespace socks class client { boost::asio::ip::tcp::socket proxy_; - boost::asio::io_service::strand strand_; + boost::asio::strand<boost::asio::ip::tcp::socket::executor_type> strand_; std::uint16_t buffer_size_; std::uint8_t buffer_[1024]; socks::version ver_; diff --git a/src/net/socks_connect.cpp b/src/net/socks_connect.cpp index 5317564de..8ecbf6d08 100644 --- a/src/net/socks_connect.cpp +++ b/src/net/socks_connect.cpp @@ -71,7 +71,7 @@ namespace socks boost::promise<boost::asio::ip::tcp::socket> result{}; out = result.get_future(); const auto proxy = net::socks::make_connect_client( - boost::asio::ip::tcp::socket{GET_IO_SERVICE(timeout)}, net::socks::version::v4a, future_socket{std::move(result)} + boost::asio::ip::tcp::socket{MONERO_GET_EXECUTOR(timeout)}, net::socks::version::v4a, future_socket{std::move(result)} ); if (epee::string_tools::get_ip_int32_from_string(ip_address, remote_host)) |
