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 >
125 return default_value;
135 typename Timer_Factory,
138 typename Strand = asio_ns::strand< default_asio_executor > >
146 typename Timer_Factory,
160template <
typename Connection,
typename Start_Read_CB,
typename Failed_CB >
165 Start_Read_CB start_read_cb,
166 Failed_CB failed_cb )
169 asio_ns::ssl::stream_base::server,
170 [ start_read_cb =
std::move( start_read_cb ),
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 ) &&
248 std::shared_ptr< asio_ns::ssl::context > shared_context ) &
250 m_tls_context =
std::move( shared_context );
251 return upcast_reference();
289 std::shared_ptr< asio_ns::ssl::context > shared_context ) &&
301 asio_ns::ssl::context
304 asio_ns::ssl::context result{
std::move( *m_tls_context ) };
305 m_tls_context.reset();
317 std::shared_ptr< asio_ns::ssl::context >
327 return static_cast< Settings &
>( *this );
330 std::shared_ptr< asio_ns::ssl::context > m_tls_context{
331 std::make_shared< asio_ns::ssl::context >(
332 asio_ns::ssl::context::sslv23 )
356 template <
typename Settings >
359 asio_ns::io_context & io_context )
360 : m_tls_context{ settings.giveaway_tls_context() }
363 m_sockets.reserve( settings.concurrent_accepts_count() );
365 while(
m_sockets.size() < settings.concurrent_accepts_count() )
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.
RESTINIO_NODISCARD auto native_handle() const noexcept
Get the access to native handle behind Asio's ssl_stream.
tls_accessor_t(tls_socket_t &tls_socket)
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()
asio_ns::ssl::context tls_context()
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.
#define RESTINIO_NODISCARD
void swap(optional< T > &x, optional< T > &y)
tls_socket_t * make_tls_socket_pointer_for_state_listener(asio_ns::ip::tcp::socket &) noexcept
impl::tls_socket_t tls_socket_t
A public alias for the actual implementation of TLS-socket.
std::function< request_handling_status_t(request_handle_t) > default_request_handler_t
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...