26#ifndef MYSQL_ROUTER_CHANNEL_INCLUDED
27#define MYSQL_ROUTER_CHANNEL_INCLUDED
32#include <system_error>
43#include <openssl/ssl.h>
71 std::vector<uint8_t, default_init_allocator<uint8_t>>;
82 recv_plain_buffer_.clear();
84 send_plain_buffer_.clear();
86 payload_buffer_.clear();
97 init_ssl_impl(ssl_ctx);
100 void init_ssl(std::shared_ptr<TlsContext> ssl_ctx) {
101 tls_context_ = std::move(ssl_ctx);
102 init_ssl_impl(tls_context_->get());
118 bool tls_init_is_finished();
132 template <
class DynamicBuffer>
134 requires(net::is_dynamic_buffer_v<DynamicBuffer>)
136 auto orig_size = dyn_buf.size();
137 size_t transferred{};
139 auto write_res = write_plain(dyn_buf.data(0, orig_size));
144 transferred += write_res.value();
145 dyn_buf.consume(write_res.value());
157 return write_plain(b);
166 template <
class DynamicBuffer>
169 auto orig_size = dyn_buf.size();
171 size_t transferred{};
173 dyn_buf.grow(grow_size);
175 const auto res_res = read_plain(dyn_buf.data(orig_size, grow_size));
177 dyn_buf.shrink(grow_size);
181 transferred += res_res.value();
182 dyn_buf.shrink(grow_size - res_res.value());
257 recv_buffer_type &send_plain_buffer();
268 const recv_view_type &recv_view()
const;
285 const recv_view_type &recv_plain_view()
const;
288 void consume_raw(
size_t count);
291 void consume_plain(
size_t count);
294 void view_discard_raw();
297 void view_discard_plain();
300 void view_sync_raw();
303 void view_sync_plain();
329 SSL *
ssl()
const {
return ssl_.get(); }
338 ssl_.reset(SSL_new(ssl_ctx));
340 SSL_set_bio(ssl_.get(), BIO_new(BIO_s_mem()), BIO_new(BIO_s_mem()));
SSL aware socket buffers.
Definition: channel.h:66
std::shared_ptr< TlsContext > tls_context_
Definition: channel.h:358
void init_ssl(std::shared_ptr< TlsContext > ssl_ctx)
Definition: channel.h:100
stdx::expected< size_t, std::error_code > write(const net::const_buffer &b)
write unencrypted net::const_buffer to the channel.
Definition: channel.h:156
recv_buffer_type send_buffer_
Definition: channel.h:353
recv_buffer_type send_plain_buffer_
Definition: channel.h:352
const recv_buffer_type & recv_buffer() const
buffer of data that was received from the socket.
Definition: channel.h:263
void clear()
clears all buffers.
Definition: channel.h:80
size_t want_recv() const
bytes wanted.
Definition: channel.h:240
stdx::expected< size_t, std::error_code > read(DynamicBuffer &dyn_buf, size_t sz)
read unencrypted data from channel to a net::dynamic_buffer.
Definition: channel.h:167
const recv_buffer_type & send_buffer() const
buffer of data to be sent to the socket.
Definition: channel.h:273
void init_ssl(SSL_CTX *ssl_ctx)
initialize the SSL session.
Definition: channel.h:95
void is_tls(bool v)
mark channel as containing TLS data in the recv_buffer().
Definition: channel.h:312
stdx::expected< size_t, std::error_code > write(DynamicBuffer &dyn_buf)
write unencrypted net::dynamic_buffer to the channel.
Definition: channel.h:133
void want_recv(size_t wanted)
bytes wanted.
Definition: channel.h:233
recv_buffer_type & payload_buffer()
Definition: channel.h:280
SSL * ssl() const
get access to the raw SSL handle.
Definition: channel.h:329
const recv_buffer_type & payload_buffer() const
payload buffer for
Definition: channel.h:278
Channel(Ssl ssl)
Definition: channel.h:75
void init_ssl_impl(SSL_CTX *ssl_ctx)
Definition: channel.h:337
recv_view_type recv_view_
Definition: channel.h:346
recv_buffer_type recv_buffer_
Definition: channel.h:345
std::span< typename recv_buffer_type::value_type > recv_view_type
Definition: channel.h:72
recv_view_type recv_plain_view_
Definition: channel.h:348
mysql_harness::Ssl Ssl
Definition: channel.h:73
recv_buffer_type & send_buffer()
buffer of data to be sent to the socket.
Definition: channel.h:252
std::vector< uint8_t, default_init_allocator< uint8_t > > recv_buffer_type
Definition: channel.h:71
bool is_tls() const
check if connection switched to TLS.
Definition: channel.h:317
recv_buffer_type & recv_buffer()
buffer of data that was received from the socket.
Definition: channel.h:245
recv_buffer_type payload_buffer_
Definition: channel.h:350
recv_buffer_type recv_plain_buffer_
Definition: channel.h:347
Definition: expected.h:286
static int count
Definition: myisam_ftdump.cc:45
constexpr value_type ssl
Definition: classic_protocol_constants.h:49
std::unique_ptr< SSL, mysql_harness::impl::Deleter_SSL > Ssl
Definition: tls_types.h:48
Define std::hash<Gtid>.
Definition: gtid.h:355
unexpected(E) -> unexpected< E >
#define ROUTING_CONNECTIONS_EXPORT
Definition: routing_connections_export.h:15