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()),
205 if (!
strand_.running_in_this_thread())
222 std::placeholders::_1)));
230 if (ec != boost::asio::error::operation_aborted)
240 return fail(
"accept", ec);
252 std::placeholders::_1)));
280 if (!
strand_.running_in_this_thread())
295 timer_.async_wait(bind_executor(
300 std::placeholders::_1)));
308 std::placeholders::_1)));
316 if (ec != boost::asio::error::operation_aborted)
317 test_.log <<
"[server] " << what <<
": " << ec.message()
327 if (ec == boost::asio::error::operation_aborted)
330 return fail(
"timer", ec);
339 return fail(
"handshake", ec);
341 boost::asio::async_read_until(
350 std::placeholders::_1,
351 std::placeholders::_2)));
360 if (ec == boost::asio::error::eof)
363 return stream_.async_shutdown(bind_executor(
368 std::placeholders::_1)));
371 return fail(
"read", ec);
373 buf_.commit(bytes_transferred);
374 buf_.consume(bytes_transferred);
376 boost::asio::async_write(
384 std::placeholders::_1,
385 std::placeholders::_2)));
391 buf_.consume(bytes_transferred);
393 return fail(
"write", ec);
394 stream_.async_shutdown(bind_executor(
399 std::placeholders::_1)));
406 return fail(
"shutdown", ec);
415 auto const p = std::make_shared<Acceptor>(*
this);
466 if (!
strand_.running_in_this_thread())
481 timer_.async_wait(bind_executor(
486 std::placeholders::_1)));
494 std::placeholders::_1)));
502 if (ec != boost::asio::error::operation_aborted)
503 test_.log <<
"[client] " << what <<
": " << ec.message()
513 if (ec == boost::asio::error::operation_aborted)
516 return fail(
"timer", ec);
517 test_.log <<
"[client] timeout";
525 return fail(
"connect", ec);
533 std::placeholders::_1)));
540 return fail(
"handshake", ec);
544 boost::asio::async_write(
552 std::placeholders::_1,
553 std::placeholders::_2)));
555 stream_.async_shutdown(bind_executor(
560 std::placeholders::_1)));
567 buf_.consume(bytes_transferred);
569 return fail(
"write", ec);
571 boost::asio::async_read_until(
580 std::placeholders::_1,
581 std::placeholders::_2)));
583 stream_.async_shutdown(bind_executor(
588 std::placeholders::_1)));
596 return fail(
"read", ec);
597 buf_.commit(bytes_transferred);
598 stream_.async_shutdown(bind_executor(
603 std::placeholders::_1)));
610 return fail(
"shutdown", ec);
619 auto const p = std::make_shared<Connection>(*
this, ep);
636 this->io_context_.run();