17namespace connection_state
99template<
typename Lambda >
107template<
typename Lambda >
112 throw exception_t{
"an attempt to call inspect_tls for "
113 "non-TLS-connection" };
118template<
typename Lambda,
typename T >
138 typename Strand = asio_ns::strand< default_asio_executor > >
160template <
typename Connection,
typename Start_Read_CB,
typename Failed_CB >
169 asio_ns::ssl::stream_base::server,
172 con =
con.shared_from_this() ](
const asio_ns::error_code &
ec ){
188template <
typename Settings >
202 asio_ns::ssl::context
context ) &
204 m_tls_context = std::make_shared< asio_ns::ssl::context >(
206 return upcast_reference();
212 asio_ns::ssl::context
context ) &&
214 return std::move( this->tls_context( std::move(
context ) ) );
251 return upcast_reference();
291 return std::move( this->tls_context( std::move(
shared_context) ) );
301 std::shared_ptr< asio_ns::ssl::context >
304 return std::move(m_tls_context);
311 return static_cast< Settings &
>( *this );
314 std::shared_ptr< asio_ns::ssl::context > m_tls_context{
315 std::make_shared< asio_ns::ssl::context >(
316 asio_ns::ssl::context::sslv23 )
340 template <
typename Settings >
343 asio_ns::io_context & io_context )
344 : m_tls_context{
settings.giveaway_tls_context() }
decltype(auto) inspect_tls_or_throw(Lambda &&lambda) const
Calls the specified lambda-function if the accepted connection is a TLS-connection.
T inspect_tls_or_default(Lambda &&lambda, T &&default_value) const
Calls the specified lambda-function if the accepted connection is a TLS-connection.
tls_socket_t * m_tls_socket
An optional pointer to TLS-related connection.
void try_inspect_tls(Lambda &&lambda) const
Calls the specified lambda-function if the accepted connection is a TLS-connection.
Accessor to TLS-specific information related to a connection.
tls_accessor_t(tls_socket_t &tls_socket)
auto native_handle() const noexcept
Get the access to native handle behind Asio's ssl_stream.
tls_socket_t & m_tls_socket
Exception class for all exceptions thrown by RESTinio.
asio_ns::io_context & m_io_context
tls_socket_t & socket(std::size_t idx)
virtual ~socket_supplier_t()=default
auto concurrent_accept_sockets_count() const
The number of sockets that can be used for cuncurrent accept operations.
std::shared_ptr< asio_ns::ssl::context > m_tls_context
std::vector< tls_socket_t > m_sockets
auto move_socket(std::size_t idx)
socket_supplier_t(Settings &settings, asio_ns::io_context &io_context)
std::vector< Socket > m_sockets
A temporary socket for receiving new connections.
asio_ns::io_context & m_io_context
io_context for sockets to run on.
Socket adapter for asio::ssl::stream< asio::ip::tcp::socket >.
auto async_handshake(Args &&... args)
socket_t & asio_ssl_stream()
Get an access to underlying Asio's socket.
Settings & tls_context(std::shared_ptr< asio_ns::ssl::context > shared_context) &
Setup a shared TLS-context for server's settings.
socket_type_dependent_settings_t()=default
Settings && tls_context(std::shared_ptr< asio_ns::ssl::context > shared_context) &&
Setup a shared TLS-context for server's settings.
Settings & upcast_reference()
Settings && tls_context(asio_ns::ssl::context context) &&
Setup an exclusive TLS-context for server's settings.
~socket_type_dependent_settings_t()=default
socket_type_dependent_settings_t(socket_type_dependent_settings_t &&)=default
Settings & tls_context(asio_ns::ssl::context context) &
Setup an exclusive TLS-context for server's settings.
std::shared_ptr< asio_ns::ssl::context > giveaway_tls_context()
Get away the TLS-context from settings.
Extra settings needed for working with socket.
tls_socket_t * make_tls_socket_pointer_for_state_listener(asio_ns::ip::tcp::socket &) noexcept
std::function< request_handling_status_t(request_handle_t) > default_request_handler_t
run_on_this_thread_settings_t< Traits > on_this_thread()
A special marker for the case when http_server must be run on the context of the current thread.
impl::tls_socket_t tls_socket_t
A public alias for the actual implementation of TLS-socket.
void prepare_connection_and_start_read(tls_socket_t &socket, Connection &con, Start_Read_CB start_read_cb, Failed_CB failed_cb)
Customizes connection init routine with an additional step: perform handshake and only then start rea...