24 #ifdef INADDR_BROADCAST
25 #undef INADDR_BROADCAST
37 #include <boost/asio/io_context.hpp>
38 #include <boost/asio/ip/tcp.hpp>
39 #include <boost/asio/streambuf.hpp>
40 #include <boost/asio/ssl.hpp>
64 connection(
const std::string& host,
const std::string& service);
74 }
catch(
const boost::system::system_error&
err) {
75 if(
err.code() == boost::asio::error::operation_aborted) {
106 return utils::holds_alternative<tls_socket>(
socket_);
137 boost::asio::ssl::context
tls_context_ { boost::asio::ssl::context::sslv23 };
139 typedef std::unique_ptr<boost::asio::ip::tcp::socket>
raw_socket;
140 typedef std::unique_ptr<boost::asio::ssl::stream<raw_socket::element_type>>
tls_socket;
151 using endpoint =
const boost::asio::ip::tcp::endpoint&;
164 void handle_write(
const boost::system::error_code& ec, std::size_t bytes_transferred);
167 void handle_read(
const boost::system::error_code& ec, std::size_t bytes_transferred,
config& response);
A config object defines a single node in a WML file, with access to child nodes.
A class that represents a TCP/IP connection.
void handle_write(const boost::system::error_code &ec, std::size_t bytes_transferred)
std::size_t is_read_complete(const boost::system::error_code &error, std::size_t bytes_transferred)
void run()
Run asio's event loop.
std::size_t bytes_to_write() const
utils::variant< raw_socket, tls_socket > any_socket
void transfer(const config &request, config &response)
std::unique_ptr< boost::asio::ssl::stream< raw_socket::element_type > > tls_socket
std::size_t bytes_read() const
uint32_t handshake_response_
void fallback_to_unencrypted()
resolver::results_type results_type
std::size_t is_write_complete(const boost::system::error_code &error, std::size_t bytes_transferred)
boost::asio::io_context io_context_
std::size_t bytes_to_read_
std::unique_ptr< boost::asio::ip::tcp::socket > raw_socket
void handle_read(const boost::system::error_code &ec, std::size_t bytes_transferred, config &response)
std::unique_ptr< boost::asio::streambuf > write_buf_
void handle_handshake(const boost::system::error_code &ec)
void handle_connect(const boost::system::error_code &ec, endpoint endpoint)
connection(const std::string &host, const std::string &service)
Constructor.
std::size_t bytes_to_write_
std::size_t bytes_written_
std::size_t poll()
Handle all pending asynchronous events and return.
bool using_tls() const
True if connection is currently using TLS and thus is allowed to send cleartext passwords or auth tok...
boost::asio::ip::tcp::resolver resolver
boost::asio::ssl::context tls_context_
void handle_resolve(const boost::system::error_code &ec, results_type results)
std::size_t bytes_to_read() const
std::size_t bytes_written() const
const boost::asio::ip::tcp::endpoint & endpoint
std::unique_ptr< boost::asio::streambuf > read_buf_
bool done() const
True if connected and no high-level operation is in progress.
const std::string service_
Base class for all the errors encountered by the engine.
error(const boost::system::error_code &error)
MacOS doesn't support std::visit when targing MacOS < 10.14 (currently we target 10....