diff options
Diffstat (limited to 'src/net/socks.cpp')
| -rw-r--r-- | src/net/socks.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
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()) { |
