Monero
Classes | Public Types | Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
epee::net_utils::boosted_tcp_server< t_protocol_handler > Class Template Reference

#include <abstract_tcp_server2.h>

Inheritance diagram for epee::net_utils::boosted_tcp_server< t_protocol_handler >:
Inheritance graph
[legend]
Collaboration diagram for epee::net_utils::boosted_tcp_server< t_protocol_handler >:
Collaboration graph
[legend]

Classes

struct  idle_callback_conext
 
struct  idle_callback_conext_base
 
struct  worker
 The io_context used to perform asynchronous operations. More...
 

Public Types

typedef boost::shared_ptr< connection< t_protocol_handler > > connection_ptr
 
typedef t_protocol_handler::connection_context t_connection_context
 

Public Member Functions

 boosted_tcp_server (t_connection_type connection_type)
 
 boosted_tcp_server (boost::asio::io_context &external_io_context, t_connection_type connection_type)
 
 ~boosted_tcp_server ()
 
void create_server_type_map ()
 
bool init_server (uint32_t port, const std::string &address="0.0.0.0", uint32_t port_ipv6=0, const std::string &address_ipv6="::", bool use_ipv6=false, bool require_ipv4=true, ssl_options_t ssl_options=ssl_support_t::e_ssl_support_autodetect)
 
bool init_server (const std::string port, const std::string &address="0.0.0.0", const std::string port_ipv6="", const std::string address_ipv6="::", bool use_ipv6=false, bool require_ipv4=true, ssl_options_t ssl_options=ssl_support_t::e_ssl_support_autodetect)
 
bool run_server (size_t threads_count, bool wait=true, const boost::thread::attributes &attrs=boost::thread::attributes())
 Run the server's io_context loop. More...
 
bool timed_wait_server_stop (uint64_t wait_mseconds)
 wait for service workers stop More...
 
void send_stop_signal ()
 Stop the server. More...
 
bool is_stop_signal_sent () const noexcept
 
const std::atomic< bool > & get_stop_signal () const noexcept
 
void set_threads_prefix (const std::string &prefix_name)
 
bool deinit_server ()
 
size_t get_threads_count ()
 
void set_connection_filter (i_connection_filter *pfilter)
 
void set_connection_limit (i_connection_limit *plimit)
 
void set_response_soft_limit (std::size_t limit)
 
void set_default_remote (epee::net_utils::network_address remote)
 
bool add_connection (t_connection_context &out, boost::asio::ip::tcp::socket &&sock, network_address real_remote, epee::net_utils::ssl_support_t ssl_support=epee::net_utils::ssl_support_t::e_ssl_support_autodetect)
 
try_connect_result_t try_connect (connection_ptr new_connection_l, const std::string &adr, const std::string &port, boost::asio::ip::tcp::socket &sock_, const boost::asio::ip::tcp::endpoint &remote_endpoint, const std::string &bind_ip, uint32_t conn_timeout, epee::net_utils::ssl_support_t ssl_support)
 
bool connect (const std::string &adr, const std::string &port, uint32_t conn_timeot, t_connection_context &cn, const std::string &bind_ip="0.0.0.0", epee::net_utils::ssl_support_t ssl_support=epee::net_utils::ssl_support_t::e_ssl_support_autodetect)
 
template<class t_callback >
bool connect_async (const std::string &adr, const std::string &port, uint32_t conn_timeot, const t_callback &cb, const std::string &bind_ip="0.0.0.0", epee::net_utils::ssl_support_t ssl_support=epee::net_utils::ssl_support_t::e_ssl_support_autodetect, t_connection_context &&initial=t_connection_context{})
 
boost::asio::ssl::context & get_ssl_context () noexcept
 
t_protocol_handler::config_type & get_config_object ()
 
std::shared_ptr< typename t_protocol_handler::config_type > get_config_shared ()
 
int get_binded_port ()
 
int get_binded_port_ipv6 ()
 
long get_connections_count () const
 
boost::asio::io_context & get_io_context ()
 
template<class t_handler >
bool add_idle_handler (t_handler t_callback, uint64_t timeout_ms)
 
template<class t_handler >
bool global_timer_handler (boost::shared_ptr< idle_callback_conext< t_handler >> ptr)
 
template<class t_handler >
bool async_call (t_handler &&t_callback)
 
template<class t_callback >
bool connect_async (const std::string &adr, const std::string &port, uint32_t conn_timeout, const t_callback &cb, const std::string &bind_ip, epee::net_utils::ssl_support_t ssl_support, t_connection_context &&initial)
 

Public Attributes

std::map< std::string, t_connection_typeserver_type_map
 

Private Types

enum  try_connect_result_t { CONNECT_SUCCESS, CONNECT_FAILURE, CONNECT_NO_SSL }
 

Private Member Functions

bool worker_thread ()
 Run the server's io_context loop. More...
 
void handle_accept_ipv4 (const boost::system::error_code &e)
 Handle completion of an asynchronous accept operation. More...
 
void handle_accept_ipv6 (const boost::system::error_code &e)
 
void handle_accept (const boost::system::error_code &e, bool ipv6=false)
 
bool is_thread_worker ()
 

Private Attributes

const std::shared_ptr< typename connection< t_protocol_handler >::shared_state > m_state
 
std::unique_ptr< workerm_io_context_local_instance
 
boost::asio::io_context & io_context_
 
boost::asio::ip::tcp::acceptor acceptor_
 Acceptor used to listen for incoming connections. More...
 
boost::asio::ip::tcp::acceptor acceptor_ipv6
 
epee::net_utils::network_address default_remote
 
std::atomic< boolm_stop_signal_sent
 
uint32_t m_port
 
uint32_t m_port_ipv6
 
std::string m_address
 
std::string m_address_ipv6
 
bool m_use_ipv6
 
bool m_require_ipv4
 
std::string m_thread_name_prefix
 
size_t m_threads_count
 
std::vector< boost::shared_ptr< boost::thread > > m_threads
 
boost::thread::id m_main_thread_id
 
critical_section m_threads_lock
 
std::atomic< uint32_tm_thread_index
 
t_connection_type m_connection_type
 
connection_ptr new_connection_
 The next connection to be accepted. More...
 
connection_ptr new_connection_ipv6
 
boost::mutex connections_mutex
 
std::set< connection_ptrconnections_
 

Member Typedef Documentation

◆ connection_ptr

template<class t_protocol_handler>
typedef boost::shared_ptr<connection<t_protocol_handler> > epee::net_utils::boosted_tcp_server< t_protocol_handler >::connection_ptr

◆ t_connection_context

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

Member Enumeration Documentation

◆ try_connect_result_t

template<class t_protocol_handler>
enum epee::net_utils::boosted_tcp_server::try_connect_result_t
private
Enumerator
CONNECT_SUCCESS 
CONNECT_FAILURE 
CONNECT_NO_SSL 

Constructor & Destructor Documentation

◆ boosted_tcp_server() [1/2]

template<class t_protocol_handler >
epee::net_utils::boosted_tcp_server< t_protocol_handler >::boosted_tcp_server ( t_connection_type  connection_type)

Construct the server to listen on the specified TCP address and port, and serve up files from the given directory.

◆ boosted_tcp_server() [2/2]

template<class t_protocol_handler >
epee::net_utils::boosted_tcp_server< t_protocol_handler >::boosted_tcp_server ( boost::asio::io_context &  external_io_context,
t_connection_type  connection_type 
)
explicit

◆ ~boosted_tcp_server()

template<class t_protocol_handler >
epee::net_utils::boosted_tcp_server< t_protocol_handler >::~boosted_tcp_server ( )

Member Function Documentation

◆ add_connection()

template<class t_protocol_handler>
bool epee::boosted_tcp_server::add_connection ( t_connection_context out,
boost::asio::ip::tcp::socket &&  sock,
network_address  real_remote,
epee::net_utils::ssl_support_t  ssl_support = epee::net_utils::ssl_support_t::e_ssl_support_autodetect 
)

◆ add_idle_handler()

template<class t_protocol_handler>
template<class t_handler >
bool epee::net_utils::boosted_tcp_server< t_protocol_handler >::add_idle_handler ( t_handler  t_callback,
uint64_t  timeout_ms 
)
inline

◆ async_call()

template<class t_protocol_handler>
template<class t_handler >
bool epee::net_utils::boosted_tcp_server< t_protocol_handler >::async_call ( t_handler &&  t_callback)
inline

◆ connect()

template<class t_protocol_handler>
bool epee::boosted_tcp_server::connect ( const std::string &  adr,
const std::string &  port,
uint32_t  conn_timeot,
t_connection_context cn,
const std::string &  bind_ip = "0.0.0.0",
epee::net_utils::ssl_support_t  ssl_support = epee::net_utils::ssl_support_t::e_ssl_support_autodetect 
)

◆ connect_async() [1/2]

template<class t_protocol_handler>
template<class t_callback >
bool epee::net_utils::boosted_tcp_server< t_protocol_handler >::connect_async ( const std::string &  adr,
const std::string &  port,
uint32_t  conn_timeot,
const t_callback &  cb,
const std::string &  bind_ip = "0.0.0.0",
epee::net_utils::ssl_support_t  ssl_support = epee::net_utils::ssl_support_t::e_ssl_support_autodetect,
t_connection_context &&  initial = t_connection_context{} 
)

◆ connect_async() [2/2]

template<class t_protocol_handler>
template<class t_callback >
bool epee::net_utils::boosted_tcp_server< t_protocol_handler >::connect_async ( const std::string &  adr,
const std::string &  port,
uint32_t  conn_timeout,
const t_callback &  cb,
const std::string &  bind_ip,
epee::net_utils::ssl_support_t  ssl_support,
t_connection_context &&  initial 
)

◆ create_server_type_map()

template<class t_protocol_handler >
void epee::net_utils::boosted_tcp_server< t_protocol_handler >::create_server_type_map ( )

◆ deinit_server()

template<class t_protocol_handler>
bool epee::net_utils::boosted_tcp_server< t_protocol_handler >::deinit_server ( )
inline

◆ get_binded_port()

template<class t_protocol_handler>
int epee::net_utils::boosted_tcp_server< t_protocol_handler >::get_binded_port ( )
inline

◆ get_binded_port_ipv6()

template<class t_protocol_handler>
int epee::net_utils::boosted_tcp_server< t_protocol_handler >::get_binded_port_ipv6 ( )
inline

◆ get_config_object()

template<class t_protocol_handler>
t_protocol_handler::config_type& epee::net_utils::boosted_tcp_server< t_protocol_handler >::get_config_object ( )
inline

◆ get_config_shared()

template<class t_protocol_handler>
std::shared_ptr<typename t_protocol_handler::config_type> epee::net_utils::boosted_tcp_server< t_protocol_handler >::get_config_shared ( )
inline

◆ get_connections_count()

template<class t_protocol_handler>
long epee::net_utils::boosted_tcp_server< t_protocol_handler >::get_connections_count ( ) const
inline

◆ get_io_context()

template<class t_protocol_handler>
boost::asio::io_context& epee::net_utils::boosted_tcp_server< t_protocol_handler >::get_io_context ( )
inline

◆ get_ssl_context()

template<class t_protocol_handler>
boost::asio::ssl::context& epee::net_utils::boosted_tcp_server< t_protocol_handler >::get_ssl_context ( )
inlinenoexcept

◆ get_stop_signal()

template<class t_protocol_handler>
const std::atomic<bool>& epee::net_utils::boosted_tcp_server< t_protocol_handler >::get_stop_signal ( ) const
inlinenoexcept

◆ get_threads_count()

template<class t_protocol_handler>
size_t epee::net_utils::boosted_tcp_server< t_protocol_handler >::get_threads_count ( )
inline

◆ global_timer_handler()

template<class t_protocol_handler>
template<class t_handler >
bool epee::net_utils::boosted_tcp_server< t_protocol_handler >::global_timer_handler ( boost::shared_ptr< idle_callback_conext< t_handler >>  ptr)
inline

◆ handle_accept()

template<class t_protocol_handler>
void epee::boosted_tcp_server::handle_accept ( const boost::system::error_code &  e,
bool  ipv6 = false 
)
private

◆ handle_accept_ipv4()

template<class t_protocol_handler>
void epee::boosted_tcp_server::handle_accept_ipv4 ( const boost::system::error_code &  e)
private

Handle completion of an asynchronous accept operation.

◆ handle_accept_ipv6()

template<class t_protocol_handler>
void epee::boosted_tcp_server::handle_accept_ipv6 ( const boost::system::error_code &  e)
private

◆ init_server() [1/2]

template<class t_protocol_handler >
bool epee::net_utils::boosted_tcp_server< t_protocol_handler >::init_server ( uint32_t  port,
const std::string &  address = "0.0.0.0",
uint32_t  port_ipv6 = 0,
const std::string &  address_ipv6 = "::",
bool  use_ipv6 = false,
bool  require_ipv4 = true,
ssl_options_t  ssl_options = ssl_support_t::e_ssl_support_autodetect 
)

◆ init_server() [2/2]

template<class t_protocol_handler>
bool epee::net_utils::boosted_tcp_server< t_protocol_handler >::init_server ( const std::string  port,
const std::string &  address = "0.0.0.0",
const std::string  port_ipv6 = "",
const std::string  address_ipv6 = "::",
bool  use_ipv6 = false,
bool  require_ipv4 = true,
ssl_options_t  ssl_options = ssl_support_t::e_ssl_support_autodetect 
)

◆ is_stop_signal_sent()

template<class t_protocol_handler>
bool epee::net_utils::boosted_tcp_server< t_protocol_handler >::is_stop_signal_sent ( ) const
inlinenoexcept

◆ is_thread_worker()

template<class t_protocol_handler>
bool epee::boosted_tcp_server::is_thread_worker ( )
private

◆ run_server()

template<class t_protocol_handler>
bool epee::boosted_tcp_server::run_server ( size_t  threads_count,
bool  wait = true,
const boost::thread::attributes &  attrs = boost::thread::attributes() 
)

Run the server's io_context loop.

◆ send_stop_signal()

template<class t_protocol_handler>
void epee::boosted_tcp_server::send_stop_signal ( )

Stop the server.

◆ set_connection_filter()

template<class t_protocol_handler>
void epee::boosted_tcp_server::set_connection_filter ( i_connection_filter pfilter)

◆ set_connection_limit()

template<class t_protocol_handler>
void epee::boosted_tcp_server::set_connection_limit ( i_connection_limit plimit)

◆ set_default_remote()

template<class t_protocol_handler>
void epee::net_utils::boosted_tcp_server< t_protocol_handler >::set_default_remote ( epee::net_utils::network_address  remote)
inline

◆ set_response_soft_limit()

template<class t_protocol_handler>
void epee::boosted_tcp_server::set_response_soft_limit ( std::size_t  limit)

◆ set_threads_prefix()

template<class t_protocol_handler>
void epee::boosted_tcp_server::set_threads_prefix ( const std::string &  prefix_name)

◆ timed_wait_server_stop()

template<class t_protocol_handler>
bool epee::boosted_tcp_server::timed_wait_server_stop ( uint64_t  wait_mseconds)

wait for service workers stop

◆ try_connect()

template<class t_protocol_handler>
boosted_tcp_server< t_protocol_handler >::try_connect_result_t epee::boosted_tcp_server::try_connect ( connection_ptr  new_connection_l,
const std::string &  adr,
const std::string &  port,
boost::asio::ip::tcp::socket &  sock_,
const boost::asio::ip::tcp::endpoint &  remote_endpoint,
const std::string &  bind_ip,
uint32_t  conn_timeout,
epee::net_utils::ssl_support_t  ssl_support 
)

◆ worker_thread()

template<class t_protocol_handler>
bool epee::boosted_tcp_server::worker_thread ( )
private

Run the server's io_context loop.

Member Data Documentation

◆ acceptor_

template<class t_protocol_handler>
boost::asio::ip::tcp::acceptor epee::net_utils::boosted_tcp_server< t_protocol_handler >::acceptor_
private

Acceptor used to listen for incoming connections.

◆ acceptor_ipv6

template<class t_protocol_handler>
boost::asio::ip::tcp::acceptor epee::net_utils::boosted_tcp_server< t_protocol_handler >::acceptor_ipv6
private

◆ connections_

template<class t_protocol_handler>
std::set<connection_ptr> epee::net_utils::boosted_tcp_server< t_protocol_handler >::connections_
private

◆ connections_mutex

template<class t_protocol_handler>
boost::mutex epee::net_utils::boosted_tcp_server< t_protocol_handler >::connections_mutex
private

◆ default_remote

template<class t_protocol_handler>
epee::net_utils::network_address epee::net_utils::boosted_tcp_server< t_protocol_handler >::default_remote
private

◆ io_context_

template<class t_protocol_handler>
boost::asio::io_context& epee::net_utils::boosted_tcp_server< t_protocol_handler >::io_context_
private

◆ m_address

template<class t_protocol_handler>
std::string epee::net_utils::boosted_tcp_server< t_protocol_handler >::m_address
private

◆ m_address_ipv6

template<class t_protocol_handler>
std::string epee::net_utils::boosted_tcp_server< t_protocol_handler >::m_address_ipv6
private

◆ m_connection_type

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

◆ m_io_context_local_instance

template<class t_protocol_handler>
std::unique_ptr<worker> epee::net_utils::boosted_tcp_server< t_protocol_handler >::m_io_context_local_instance
private

◆ m_main_thread_id

template<class t_protocol_handler>
boost::thread::id epee::net_utils::boosted_tcp_server< t_protocol_handler >::m_main_thread_id
private

◆ m_port

template<class t_protocol_handler>
uint32_t epee::net_utils::boosted_tcp_server< t_protocol_handler >::m_port
private

◆ m_port_ipv6

template<class t_protocol_handler>
uint32_t epee::net_utils::boosted_tcp_server< t_protocol_handler >::m_port_ipv6
private

◆ m_require_ipv4

template<class t_protocol_handler>
bool epee::net_utils::boosted_tcp_server< t_protocol_handler >::m_require_ipv4
private

◆ m_state

template<class t_protocol_handler>
const std::shared_ptr<typename connection<t_protocol_handler>::shared_state> epee::net_utils::boosted_tcp_server< t_protocol_handler >::m_state
private

◆ m_stop_signal_sent

template<class t_protocol_handler>
std::atomic<bool> epee::net_utils::boosted_tcp_server< t_protocol_handler >::m_stop_signal_sent
private

◆ m_thread_index

template<class t_protocol_handler>
std::atomic<uint32_t> epee::net_utils::boosted_tcp_server< t_protocol_handler >::m_thread_index
private

◆ m_thread_name_prefix

template<class t_protocol_handler>
std::string epee::net_utils::boosted_tcp_server< t_protocol_handler >::m_thread_name_prefix
private

◆ m_threads

template<class t_protocol_handler>
std::vector<boost::shared_ptr<boost::thread> > epee::net_utils::boosted_tcp_server< t_protocol_handler >::m_threads
private

◆ m_threads_count

template<class t_protocol_handler>
size_t epee::net_utils::boosted_tcp_server< t_protocol_handler >::m_threads_count
private

◆ m_threads_lock

template<class t_protocol_handler>
critical_section epee::net_utils::boosted_tcp_server< t_protocol_handler >::m_threads_lock
private

◆ m_use_ipv6

template<class t_protocol_handler>
bool epee::net_utils::boosted_tcp_server< t_protocol_handler >::m_use_ipv6
private

◆ new_connection_

template<class t_protocol_handler>
connection_ptr epee::net_utils::boosted_tcp_server< t_protocol_handler >::new_connection_
private

The next connection to be accepted.

◆ new_connection_ipv6

template<class t_protocol_handler>
connection_ptr epee::net_utils::boosted_tcp_server< t_protocol_handler >::new_connection_ipv6
private

◆ server_type_map

template<class t_protocol_handler>
std::map<std::string, t_connection_type> epee::net_utils::boosted_tcp_server< t_protocol_handler >::server_type_map

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