MySQL 9.1.0
Source Code Documentation
|
SSL aware socket buffers. More...
#include <channel.h>
Public Types | |
using | recv_buffer_type = std::vector< uint8_t, default_init_allocator< uint8_t > > |
using | recv_view_type = std::span< typename recv_buffer_type::value_type > |
using | Ssl = mysql_harness::Ssl |
Public Member Functions | |
Channel ()=default | |
Channel (Ssl ssl) | |
void | clear () |
clears all buffers. More... | |
void | init_ssl (SSL_CTX *ssl_ctx) |
initialize the SSL session. More... | |
stdx::expected< void, std::error_code > | tls_accept () |
accept a TLS session. More... | |
stdx::expected< void, std::error_code > | tls_connect () |
connect a TLS session. More... | |
bool | tls_init_is_finished () |
stdx::expected< bool, std::error_code > | tls_shutdown () |
template<class DynamicBuffer > requires (net::is_dynamic_buffer_v<DynamicBuffer>) | |
stdx::expected< size_t, std::error_code > | write (DynamicBuffer &dyn_buf) |
write unencrypted net::dynamic_buffer to the channel. More... | |
stdx::expected< size_t, std::error_code > | write (const net::const_buffer &b) |
write unencrypted net::const_buffer to the channel. More... | |
template<class DynamicBuffer > | |
stdx::expected< size_t, std::error_code > | read (DynamicBuffer &dyn_buf, size_t sz) |
read unencrypted data from channel to a net::dynamic_buffer. More... | |
stdx::expected< size_t, std::error_code > | read_to_plain (size_t sz) |
stdx::expected< size_t, std::error_code > | write_plain (const net::const_buffer &b) |
write unencrypted data from a net::const_buffer to the channel. More... | |
stdx::expected< size_t, std::error_code > | read_plain (const net::mutable_buffer &b) |
read plaintext data from recv_plain_buffer() into b. More... | |
stdx::expected< size_t, std::error_code > | flush_from_recv_buf () |
flush data from receive buffer to recv_plain_buffer(). More... | |
stdx::expected< size_t, std::error_code > | flush_to_send_buf () |
flush data to the send buffer. More... | |
void | want_recv (size_t wanted) |
bytes wanted. More... | |
size_t | want_recv () const |
bytes wanted. More... | |
recv_buffer_type & | recv_buffer () |
buffer of data that was received from the socket. More... | |
recv_buffer_type & | send_buffer () |
buffer of data to be sent to the socket. More... | |
recv_buffer_type & | send_plain_buffer () |
unencrypted data to be sent to the socket. More... | |
const recv_buffer_type & | recv_buffer () const |
buffer of data that was received from the socket. More... | |
const recv_view_type & | recv_view () const |
network data after a recv(). More... | |
const recv_buffer_type & | send_buffer () const |
buffer of data to be sent to the socket. More... | |
const recv_buffer_type & | payload_buffer () const |
payload buffer for More... | |
recv_buffer_type & | payload_buffer () |
const recv_view_type & | recv_plain_view () const |
decrypted data after a recv(). More... | |
void | consume_raw (size_t count) |
void | consume_plain (size_t count) |
void | view_discard_raw () |
void | view_discard_plain () |
void | view_sync_raw () |
void | view_sync_plain () |
void | is_tls (bool v) |
mark channel as containing TLS data in the recv_buffer(). More... | |
bool | is_tls () const |
check if connection switched to TLS. More... | |
SSL * | ssl () const |
get access to the raw SSL handle. More... | |
Ssl | release_ssl () |
release the internal Ssl structure. More... | |
Private Attributes | |
size_t | want_recv_ {} |
recv_buffer_type | recv_buffer_ |
recv_view_type | recv_view_ |
recv_buffer_type | recv_plain_buffer_ |
recv_view_type | recv_plain_view_ |
recv_buffer_type | payload_buffer_ |
recv_buffer_type | send_plain_buffer_ |
recv_buffer_type | send_buffer_ |
bool | is_tls_ {false} |
Ssl | ssl_ {} |
SSL aware socket buffers.
manages the raw and plaintext socket buffers of connection which may switch to TLS.
an external user like a socket class can
Once init_ssl() is called, the recv_plain() and write_plain() methods transparently decrypt and encrypt.
using Channel::recv_buffer_type = std::vector<uint8_t, default_init_allocator<uint8_t> > |
using Channel::recv_view_type = std::span<typename recv_buffer_type::value_type> |
using Channel::Ssl = mysql_harness::Ssl |
|
default |
|
inlineexplicit |
|
inline |
clears all buffers.
void Channel::consume_plain | ( | size_t | count | ) |
void Channel::consume_raw | ( | size_t | count | ) |
stdx::expected< size_t, std::error_code > Channel::flush_from_recv_buf | ( | ) |
flush data from receive buffer to recv_plain_buffer().
if an SSL session is active, flush_to_recv_buf() ensures that data encrypted data gets decrypted and added to the recv_plain_buffer().
In case no SSL session is active, it is a no-op.
stdx::expected< size_t, std::error_code > Channel::flush_to_send_buf | ( | ) |
flush data to the send buffer.
if write_plain() was used and an SSL session is active, flush_to_send_buf() ensures that data plaintext data gets encrypted and added to the send_buf().
In case no SSL session is active, it is a no-op.
|
inline |
initialize the SSL session.
|
inline |
check if connection switched to TLS.
|
inline |
mark channel as containing TLS data in the recv_buffer().
it is independent of calling init_tls() as the channel may be used to transfer encrypted data as is without ever call init_ssl().
|
inline |
|
inline |
payload buffer for
|
inline |
read unencrypted data from channel to a net::dynamic_buffer.
if the channel has a ssl session in transparently decrypts before the data is appending to the recv_plain_buf()
stdx::expected< size_t, std::error_code > Channel::read_plain | ( | const net::mutable_buffer & | b | ) |
read plaintext data from recv_plain_buffer() into b.
stdx::expected< size_t, std::error_code > Channel::read_to_plain | ( | size_t | sz | ) |
|
inline |
buffer of data that was received from the socket.
|
inline |
buffer of data that was received from the socket.
const Channel::recv_view_type & Channel::recv_plain_view | ( | ) | const |
decrypted data after a recv().
const Channel::recv_view_type & Channel::recv_view | ( | ) | const |
network data after a recv().
Channel::Ssl Channel::release_ssl | ( | ) |
release the internal Ssl structure.
|
inline |
buffer of data to be sent to the socket.
written into by write(), write_plain(), flush_to_send_buf().
|
inline |
buffer of data to be sent to the socket.
Channel::recv_buffer_type & Channel::send_plain_buffer | ( | ) |
unencrypted data to be sent to the socket.
|
inline |
get access to the raw SSL handle.
can be used to call:
nullptr | if channel has no SSL initialized. |
stdx::expected< void, std::error_code > Channel::tls_accept | ( | ) |
accept a TLS session.
expects a Tls::ClientHello in the recv_buf.
stdx::expected< void, std::error_code > Channel::tls_connect | ( | ) |
connect a TLS session.
bool Channel::tls_init_is_finished | ( | ) |
stdx::expected< bool, std::error_code > Channel::tls_shutdown | ( | ) |
void Channel::view_discard_plain | ( | ) |
void Channel::view_discard_raw | ( | ) |
void Channel::view_sync_plain | ( | ) |
void Channel::view_sync_raw | ( | ) |
|
inline |
bytes wanted.
|
inline |
bytes wanted.
signals to the socket layer how many bytes should be at least read into the buffer.
|
inline |
write unencrypted net::const_buffer to the channel.
if the channel has an ssl session it transparently encrypts before the data is appended to the send_buf()
|
inline |
write unencrypted net::dynamic_buffer to the channel.
if the channel has an ssl session it transparently encrypts before the data is appended to the send_buf()
stdx::expected< size_t, std::error_code > Channel::write_plain | ( | const net::const_buffer & | b | ) |
write unencrypted data from a net::const_buffer to the channel.
call flush_to_send_buf() ensure data is written to the send-buffers for the socket.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |