20 #include <ripple/basics/make_SSLContext.h>
21 #include <ripple/beast/core/CurrentThreadName.h>
22 #include <ripple/beast/unit_test.h>
23 #include <test/jtx/envconfig.h>
25 #include <boost/asio.hpp>
26 #include <boost/asio/ssl.hpp>
27 #include <boost/utility/in_place_factory.hpp>
56 boost::asio::basic_waitable_timer<std::chrono::steady_clock>;
70 template <
class Streambuf>
74 using boost::asio::buffer;
75 using boost::asio::buffer_copy;
76 using boost::asio::buffer_size;
77 boost::asio::const_buffers_1 buf(s.
data(), s.
size());
78 sb.commit(buffer_copy(sb.prepare(buffer_size(buf)), buf));
115 assert(
list_.empty());
122 list_.emplace(child.get(), child);
144 for (
auto const& c :
list_)
146 if (
auto p = c.second.lock())
162 while (!
list_.empty())
191 test::getEnvLocalhostAddr()),
203 if (!
strand_.running_in_this_thread())
220 std::placeholders::_1)));
228 if (ec != boost::asio::error::operation_aborted)
238 return fail(
"accept", ec);
250 std::placeholders::_1)));
278 if (!
strand_.running_in_this_thread())
293 timer_.async_wait(bind_executor(
298 std::placeholders::_1)));
306 std::placeholders::_1)));
314 if (ec != boost::asio::error::operation_aborted)
315 test_.log <<
"[server] " << what <<
": " << ec.message()
325 if (ec == boost::asio::error::operation_aborted)
328 return fail(
"timer", ec);
337 return fail(
"handshake", ec);
339 boost::asio::async_read_until(
348 std::placeholders::_1,
349 std::placeholders::_2)));
358 if (ec == boost::asio::error::eof)
361 return stream_.async_shutdown(bind_executor(
366 std::placeholders::_1)));
369 return fail(
"read", ec);
371 buf_.commit(bytes_transferred);
372 buf_.consume(bytes_transferred);
374 boost::asio::async_write(
382 std::placeholders::_1,
383 std::placeholders::_2)));
389 buf_.consume(bytes_transferred);
391 return fail(
"write", ec);
392 stream_.async_shutdown(bind_executor(
397 std::placeholders::_1)));
404 return fail(
"shutdown", ec);
413 auto const p = std::make_shared<Acceptor>(*
this);
464 if (!
strand_.running_in_this_thread())
479 timer_.async_wait(bind_executor(
484 std::placeholders::_1)));
492 std::placeholders::_1)));
500 if (ec != boost::asio::error::operation_aborted)
501 test_.log <<
"[client] " << what <<
": " << ec.message()
511 if (ec == boost::asio::error::operation_aborted)
514 return fail(
"timer", ec);
515 test_.log <<
"[client] timeout";
523 return fail(
"connect", ec);
531 std::placeholders::_1)));
538 return fail(
"handshake", ec);
542 boost::asio::async_write(
550 std::placeholders::_1,
551 std::placeholders::_2)));
553 stream_.async_shutdown(bind_executor(
558 std::placeholders::_1)));
565 buf_.consume(bytes_transferred);
567 return fail(
"write", ec);
569 boost::asio::async_read_until(
578 std::placeholders::_1,
579 std::placeholders::_2)));
581 stream_.async_shutdown(bind_executor(
586 std::placeholders::_1)));
594 return fail(
"read", ec);
595 buf_.commit(bytes_transferred);
596 stream_.async_shutdown(bind_executor(
601 std::placeholders::_1)));
608 return fail(
"shutdown", ec);
617 auto const p = std::make_shared<Connection>(*
this, ep);
634 this->io_context_.run();