Monero
Loading...
Searching...
No Matches
epee::net_utils::connection< t_protocol_handler > Class Template Reference

Represents a single connection from a client. More...

#include <abstract_tcp_server2.h>

Inheritance diagram for epee::net_utils::connection< t_protocol_handler >:
Collaboration diagram for epee::net_utils::connection< t_protocol_handler >:

Classes

struct  state_t
struct  timers_t
struct  shared_state

Public Types

typedef t_protocol_handler::connection_context t_connection_context

Public Member Functions

 connection (io_context_t &io_context, std::shared_ptr< shared_state > state, t_connection_type connection_type, epee::net_utils::ssl_support_t ssl_support, t_connection_context &&initial=t_connection_context{})
 Construct a connection with the given io_context.
 connection (io_context_t &io_context, boost::asio::ip::tcp::socket &&sock, std::shared_ptr< shared_state > state, t_connection_type connection_type, epee::net_utils::ssl_support_t ssl_support, t_connection_context &&initial=t_connection_context{})
virtual ~connection () noexcept(false)
bool start (bool is_income, bool is_multithreaded)
 Start the first asynchronous operation for the connection.
bool start (bool is_income, bool is_multithreaded, network_address real_remote)
void get_context (t_connection_context &context_)
void call_back_starter ()
void save_dbg_log ()
bool speed_limit_is_enabled () const
 tells us should we be sleeping here (e.g. do not sleep on RPC connections)
bool cancel ()
void setRpcStation ()
Public Member Functions inherited from epee::net_utils::connection_basic
 connection_basic (boost::asio::io_context &context, boost::asio::ip::tcp::socket &&sock, std::shared_ptr< connection_basic_shared_state > state, ssl_support_t ssl_support)
 connection_basic (boost::asio::io_context &context, std::shared_ptr< connection_basic_shared_state > state, ssl_support_t ssl_support)
virtual ~connection_basic () noexcept(false)
connection_basic_shared_stateget_state () noexcept
boost::asio::ip::tcp::socket & socket ()
ssl_support_t get_ssl_support () const
void disable_ssl ()
bool handshake (boost::asio::ssl::stream_base::handshake_type type, boost::asio::const_buffer buffer={})
template<typename MutableBufferSequence, typename ReadHandler>
void async_read_some (const MutableBufferSequence &buffers, ReadHandler &&handler)
template<typename ConstBufferSequence, typename WriteHandler>
void async_write_some (const ConstBufferSequence &buffers, WriteHandler &&handler)
template<typename ConstBufferSequence, typename WriteHandler>
void async_write (const ConstBufferSequence &buffers, WriteHandler &&handler)
void do_send_handler_write (const void *ptr, size_t cb)
void do_send_handler_write_from_queue (const boost::system::error_code &e, size_t cb, int q_len)
void logger_handle_net_write (size_t size)
void logger_handle_net_read (size_t size)
void sleep_before_packet (size_t packet_size, int phase, int q_len)

Private Types

enum  status_t {
  TERMINATED , RUNNING , INTERRUPTED , TERMINATING ,
  WASTED
}
using connection_t = connection<t_protocol_handler>
using connection_ptr = boost::shared_ptr<connection_t>
using ssl_support_t = epee::net_utils::ssl_support_t
using timer_t = boost::asio::steady_timer
using duration_t = timer_t::duration
using ec_t = boost::system::error_code
using handshake_t = boost::asio::ssl::stream_base::handshake_type
using io_context_t = boost::asio::io_context
using strand_t = io_context_t::strand
using socket_t = boost::asio::ip::tcp::socket
using network_throttle_t = epee::net_utils::network_throttle
using network_throttle_manager_t = epee::net_utils::network_throttle_manager

Private Member Functions

unsigned int host_count (int delta=0)
duration_t get_default_timeout ()
duration_t get_timeout_from_bytes_read (size_t bytes) const
void state_status_check ()
void start_timer (duration_t duration, bool add={})
void async_wait_timer ()
void cancel_timer ()
void start_handshake ()
void start_read ()
void finish_read (size_t bytes_transferred)
void start_write ()
void start_shutdown ()
void cancel_socket ()
void cancel_handler ()
void interrupt ()
void on_interrupted ()
void terminate ()
void on_terminating ()
void terminate_async ()
bool send (epee::byte_slice message)
bool start_internal (bool is_income, bool is_multithreaded, boost::optional< network_address > real_remote)
virtual bool do_send (byte_slice message)
 (see do_send from i_service_endpoint)
virtual bool send_done ()
virtual bool close ()
virtual bool call_run_once_service_io ()
virtual bool request_callback ()
virtual io_context_tget_io_context ()
virtual bool add_ref ()
virtual bool release ()

Private Attributes

io_context_tm_io_context
t_connection_type m_connection_type
t_connection_context m_conn_context {}
strand_t m_strand
timers_t m_timers
connection_ptr self {}
bool m_local {}
std::string m_host {}
state_t m_state {}
t_protocol_handler m_handler

Additional Inherited Members

Static Public Member Functions inherited from epee::net_utils::connection_basic
static void set_rate_up_limit (uint64_t limit)
static void set_rate_down_limit (uint64_t limit)
static uint64_t get_rate_up_limit ()
static uint64_t get_rate_down_limit ()
static void set_tos_flag (int tos)
static int get_tos_flag ()
static void save_limit_to_file (int limit)
 for dr-monero
static double get_sleep_time (size_t cb)
Public Attributes inherited from epee::net_utils::connection_basic
std::unique_ptr< connection_basic_pimplmI
std::atomic< bool > m_want_close_connection
std::atomic< bool > m_was_shutdown
critical_section m_send_que_lock
std::deque< byte_slicem_send_que
volatile bool m_is_multithreaded
boost::asio::io_context::strand strand_
 Strand to ensure the connection's handlers are not called concurrently.
boost::asio::ssl::stream< boost::asio::ip::tcp::socket > socket_
 Socket for the connection.
ssl_support_t m_ssl_support
Protected Member Functions inherited from epee::net_utils::i_service_endpoint
virtual ~i_service_endpoint () noexcept(false)

Detailed Description

template<class t_protocol_handler>
class epee::net_utils::connection< t_protocol_handler >

Represents a single connection from a client.

Member Typedef Documentation

◆ connection_ptr

template<class t_protocol_handler>
using epee::net_utils::connection< t_protocol_handler >::connection_ptr = boost::shared_ptr<connection_t>
private

◆ connection_t

template<class t_protocol_handler>
using epee::net_utils::connection< t_protocol_handler >::connection_t = connection<t_protocol_handler>
private

◆ duration_t

template<class t_protocol_handler>
using epee::net_utils::connection< t_protocol_handler >::duration_t = timer_t::duration
private

◆ ec_t

template<class t_protocol_handler>
using epee::net_utils::connection< t_protocol_handler >::ec_t = boost::system::error_code
private

◆ handshake_t

template<class t_protocol_handler>
using epee::net_utils::connection< t_protocol_handler >::handshake_t = boost::asio::ssl::stream_base::handshake_type
private

◆ io_context_t

template<class t_protocol_handler>
using epee::net_utils::connection< t_protocol_handler >::io_context_t = boost::asio::io_context
private

◆ network_throttle_manager_t

template<class t_protocol_handler>
using epee::net_utils::connection< t_protocol_handler >::network_throttle_manager_t = epee::net_utils::network_throttle_manager
private

◆ network_throttle_t

template<class t_protocol_handler>
using epee::net_utils::connection< t_protocol_handler >::network_throttle_t = epee::net_utils::network_throttle
private

◆ socket_t

template<class t_protocol_handler>
using epee::net_utils::connection< t_protocol_handler >::socket_t = boost::asio::ip::tcp::socket
private

◆ ssl_support_t

template<class t_protocol_handler>
using epee::net_utils::connection< t_protocol_handler >::ssl_support_t = epee::net_utils::ssl_support_t
private

◆ strand_t

template<class t_protocol_handler>
using epee::net_utils::connection< t_protocol_handler >::strand_t = io_context_t::strand
private

◆ t_connection_context

template<class t_protocol_handler>
typedef t_protocol_handler::connection_context epee::net_utils::connection< t_protocol_handler >::t_connection_context

◆ timer_t

template<class t_protocol_handler>
using epee::net_utils::connection< t_protocol_handler >::timer_t = boost::asio::steady_timer
private

Member Enumeration Documentation

◆ status_t

template<class t_protocol_handler>
enum epee::net_utils::connection::status_t
private
Enumerator
TERMINATED 
RUNNING 
INTERRUPTED 
TERMINATING 
WASTED 

Constructor & Destructor Documentation

◆ connection() [1/2]

template<typename T>
epee::net_utils::connection< T >::connection ( io_context_t & io_context,
std::shared_ptr< shared_state > state,
t_connection_type connection_type,
epee::net_utils::ssl_support_t ssl_support,
t_connection_context && initial = t_connection_context{} )
explicit

Construct a connection with the given io_context.

◆ connection() [2/2]

template<typename T>
epee::net_utils::connection< T >::connection ( io_context_t & io_context,
boost::asio::ip::tcp::socket && sock,
std::shared_ptr< shared_state > state,
t_connection_type connection_type,
epee::net_utils::ssl_support_t ssl_support,
t_connection_context && initial = t_connection_context{} )
explicit

◆ ~connection()

template<typename T>
epee::net_utils::connection< T >::~connection ( )
virtual

Member Function Documentation

◆ add_ref()

template<typename T>
bool epee::net_utils::connection< T >::add_ref ( )
privatevirtual

◆ async_wait_timer()

template<typename T>
void epee::net_utils::connection< T >::async_wait_timer ( )
private

◆ call_back_starter()

template<class t_protocol_handler>
void epee::net_utils::connection< t_protocol_handler >::call_back_starter ( )

◆ call_run_once_service_io()

template<typename T>
bool epee::net_utils::connection< T >::call_run_once_service_io ( )
privatevirtual

◆ cancel()

template<typename T>
bool epee::net_utils::connection< T >::cancel ( )

◆ cancel_handler()

template<typename T>
void epee::net_utils::connection< T >::cancel_handler ( )
private

◆ cancel_socket()

template<typename T>
void epee::net_utils::connection< T >::cancel_socket ( )
private

◆ cancel_timer()

template<typename T>
void epee::net_utils::connection< T >::cancel_timer ( )
private

◆ close()

template<typename T>
bool epee::net_utils::connection< T >::close ( )
privatevirtual

◆ do_send()

template<typename T>
bool epee::net_utils::connection< T >::do_send ( byte_slice message)
privatevirtual

◆ finish_read()

template<typename T>
void epee::net_utils::connection< T >::finish_read ( size_t bytes_transferred)
private

◆ get_context()

template<class t_protocol_handler>
void epee::net_utils::connection< t_protocol_handler >::get_context ( t_connection_context & context_)
inline

◆ get_default_timeout()

template<typename T>
connection< T >::duration_t epee::net_utils::connection< T >::get_default_timeout ( )
private

◆ get_io_context()

template<typename T>
connection< T >::io_context_t & epee::net_utils::connection< T >::get_io_context ( )
privatevirtual

◆ get_timeout_from_bytes_read()

template<typename T>
connection< T >::duration_t epee::net_utils::connection< T >::get_timeout_from_bytes_read ( size_t bytes) const
private

◆ host_count()

template<typename T>
unsigned int epee::net_utils::connection< T >::host_count ( int delta = 0)
private

◆ interrupt()

template<typename T>
void epee::net_utils::connection< T >::interrupt ( )
private

◆ on_interrupted()

template<typename T>
void epee::net_utils::connection< T >::on_interrupted ( )
private

◆ on_terminating()

template<typename T>
void epee::net_utils::connection< T >::on_terminating ( )
private

◆ release()

template<typename T>
bool epee::net_utils::connection< T >::release ( )
privatevirtual

◆ request_callback()

template<typename T>
bool epee::net_utils::connection< T >::request_callback ( )
privatevirtual

◆ save_dbg_log()

template<typename T>
void epee::net_utils::connection< T >::save_dbg_log ( )

◆ send()

template<typename T>
bool epee::net_utils::connection< T >::send ( epee::byte_slice message)
private

◆ send_done()

template<typename T>
bool epee::net_utils::connection< T >::send_done ( )
privatevirtual

◆ setRpcStation()

template<typename T>
void epee::net_utils::connection< T >::setRpcStation ( )

◆ speed_limit_is_enabled()

template<typename T>
bool epee::net_utils::connection< T >::speed_limit_is_enabled ( ) const

tells us should we be sleeping here (e.g. do not sleep on RPC connections)

◆ start() [1/2]

template<typename T>
bool epee::net_utils::connection< T >::start ( bool is_income,
bool is_multithreaded )

Start the first asynchronous operation for the connection.

◆ start() [2/2]

template<typename T>
bool epee::net_utils::connection< T >::start ( bool is_income,
bool is_multithreaded,
network_address real_remote )

◆ start_handshake()

template<typename T>
void epee::net_utils::connection< T >::start_handshake ( )
private

◆ start_internal()

template<typename T>
bool epee::net_utils::connection< T >::start_internal ( bool is_income,
bool is_multithreaded,
boost::optional< network_address > real_remote )
private

◆ start_read()

template<typename T>
void epee::net_utils::connection< T >::start_read ( )
private

◆ start_shutdown()

template<typename T>
void epee::net_utils::connection< T >::start_shutdown ( )
private

◆ start_timer()

template<typename T>
void epee::net_utils::connection< T >::start_timer ( duration_t duration,
bool add = {} )
private

◆ start_write()

template<typename T>
void epee::net_utils::connection< T >::start_write ( )
private

◆ state_status_check()

template<typename T>
void epee::net_utils::connection< T >::state_status_check ( )
private

◆ terminate()

template<typename T>
void epee::net_utils::connection< T >::terminate ( )
private

◆ terminate_async()

template<typename T>
void epee::net_utils::connection< T >::terminate_async ( )
private

Member Data Documentation

◆ m_conn_context

template<class t_protocol_handler>
t_connection_context epee::net_utils::connection< t_protocol_handler >::m_conn_context {}
private

◆ m_connection_type

template<class t_protocol_handler>
t_connection_type epee::net_utils::connection< t_protocol_handler >::m_connection_type
private

◆ m_handler

template<class t_protocol_handler>
t_protocol_handler epee::net_utils::connection< t_protocol_handler >::m_handler
private

◆ m_host

template<class t_protocol_handler>
std::string epee::net_utils::connection< t_protocol_handler >::m_host {}
private

◆ m_io_context

template<class t_protocol_handler>
io_context_t& epee::net_utils::connection< t_protocol_handler >::m_io_context
private

◆ m_local

template<class t_protocol_handler>
bool epee::net_utils::connection< t_protocol_handler >::m_local {}
private

◆ m_state

template<class t_protocol_handler>
state_t epee::net_utils::connection< t_protocol_handler >::m_state {}
private

◆ m_strand

template<class t_protocol_handler>
strand_t epee::net_utils::connection< t_protocol_handler >::m_strand
private

◆ m_timers

template<class t_protocol_handler>
timers_t epee::net_utils::connection< t_protocol_handler >::m_timers
private

◆ self

template<class t_protocol_handler>
connection_ptr epee::net_utils::connection< t_protocol_handler >::self {}
private

The documentation for this class was generated from the following files: