Electroneum
Loading...
Searching...
No Matches
epee::http_server_impl_base< t_child_class, t_connection_context > Class Template Reference

#include <http_server_impl_base.h>

Inheritance diagram for epee::http_server_impl_base< t_child_class, t_connection_context >:
Collaboration diagram for epee::http_server_impl_base< t_child_class, t_connection_context >:

Public Member Functions

 http_server_impl_base ()
 http_server_impl_base (boost::asio::io_service &external_io_service)
bool init (std::function< void(size_t, uint8_t *)> rng, const std::string &bind_port="0", const std::string &bind_ip="0.0.0.0", std::vector< std::string > access_control_origins=std::vector< std::string >(), boost::optional< net_utils::http::login > user=boost::none, net_utils::ssl_options_t ssl_options=net_utils::ssl_support_t::e_ssl_support_autodetect)
bool run (size_t threads_count, bool wait=true)
bool deinit ()
bool timed_wait_server_stop (uint64_t ms)
bool send_stop_signal ()
int get_binded_port ()
long get_connections_count () const
Public Member Functions inherited from epee::net_utils::http::i_http_server_handler< epee::net_utils::connection_context_base >
virtual ~i_http_server_handler ()
virtual bool handle_http_request (const http_request_info &query_info, http_response_info &response, epee::net_utils::connection_context_base &m_conn_context)=0
virtual bool init_server_thread ()
virtual bool deinit_server_thread ()

Protected Attributes

net_utils::boosted_tcp_server< net_utils::http::http_custom_handler< t_connection_context > > m_net_server

Detailed Description

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
class epee::http_server_impl_base< t_child_class, t_connection_context >

Definition at line 47 of file http_server_impl_base.h.

Constructor & Destructor Documentation

◆ http_server_impl_base() [1/2]

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
epee::http_server_impl_base< t_child_class, t_connection_context >::http_server_impl_base ( )
inline

Definition at line 51 of file http_server_impl_base.h.

53 {}
net_utils::boosted_tcp_server< net_utils::http::http_custom_handler< t_connection_context > > m_net_server

◆ http_server_impl_base() [2/2]

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
epee::http_server_impl_base< t_child_class, t_connection_context >::http_server_impl_base ( boost::asio::io_service & external_io_service)
inlineexplicit

Definition at line 55 of file http_server_impl_base.h.

Member Function Documentation

◆ deinit()

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
bool epee::http_server_impl_base< t_child_class, t_connection_context >::deinit ( )
inline

Definition at line 106 of file http_server_impl_base.h.

107 {
108 return m_net_server.deinit_server();
109 }

◆ get_binded_port()

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
int epee::http_server_impl_base< t_child_class, t_connection_context >::get_binded_port ( )
inline

Definition at line 122 of file http_server_impl_base.h.

123 {
124 return m_net_server.get_binded_port();
125 }

◆ get_connections_count()

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
long epee::http_server_impl_base< t_child_class, t_connection_context >::get_connections_count ( ) const
inline

Definition at line 127 of file http_server_impl_base.h.

128 {
129 return m_net_server.get_connections_count();
130 }

◆ init()

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
bool epee::http_server_impl_base< t_child_class, t_connection_context >::init ( std::function< void(size_t, uint8_t *)> rng,
const std::string & bind_port = "0",
const std::string & bind_ip = "0.0.0.0",
std::vector< std::string > access_control_origins = std::vector<std::string>(),
boost::optional< net_utils::http::login > user = boost::none,
net_utils::ssl_options_t ssl_options = net_utils::ssl_support_t::e_ssl_support_autodetect )
inline

Definition at line 59 of file http_server_impl_base.h.

63 {
64
65 //set self as callback handler
66 m_net_server.get_config_object().m_phandler = static_cast<t_child_class*>(this);
67 m_net_server.get_config_object().rng = std::move(rng);
68
69 //here set folder for hosting reqests
70 m_net_server.get_config_object().m_folder = "";
71
72 //set access control allow origins if configured
74 m_net_server.get_config_object().m_access_control_origins = std::move(access_control_origins);
75
76 m_net_server.get_config_object().m_user = std::move(user);
77
78 MGINFO("Binding on " << bind_ip << ":" << bind_port);
80 if(!res)
81 {
82 LOG_ERROR("Failed to bind server");
83 return false;
84 }
85 return true;
86 }
#define LOG_ERROR(x)
Definition misc_log_ex.h:98
#define MGINFO(x)
Definition misc_log_ex.h:80
Here is the caller graph for this function:

◆ run()

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
bool epee::http_server_impl_base< t_child_class, t_connection_context >::run ( size_t threads_count,
bool wait = true )
inline

Definition at line 88 of file http_server_impl_base.h.

89 {
90 //go to loop
91 MINFO("Run net_service loop( " << threads_count << " threads)...");
92 // cn_slow_hash requires ~2MB stack; default thread stack (512KB on macOS)
93 // is insufficient and causes a stack overflow (SIGBUS/SIGSEGV) on arm64.
95 attrs.set_stack_size(8 * 1024 * 1024); // 8 MB
96 if(!m_net_server.run_server(threads_count, wait, attrs))
97 {
98 LOG_ERROR("Failed to run net tcp server!");
99 }
100
101 if(wait)
102 MINFO("net_service loop stopped.");
103 return true;
104 }
#define MINFO(x)
Definition misc_log_ex.h:75
Here is the caller graph for this function:

◆ send_stop_signal()

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
bool epee::http_server_impl_base< t_child_class, t_connection_context >::send_stop_signal ( )
inline

Definition at line 116 of file http_server_impl_base.h.

117 {
118 m_net_server.send_stop_signal();
119 return true;
120 }

◆ timed_wait_server_stop()

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
bool epee::http_server_impl_base< t_child_class, t_connection_context >::timed_wait_server_stop ( uint64_t ms)
inline

Definition at line 111 of file http_server_impl_base.h.

112 {
113 return m_net_server.timed_wait_server_stop(ms);
114 }

Member Data Documentation

◆ m_net_server

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
net_utils::boosted_tcp_server<net_utils::http::http_custom_handler<t_connection_context> > epee::http_server_impl_base< t_child_class, t_connection_context >::m_net_server
protected

Definition at line 133 of file http_server_impl_base.h.


The documentation for this class was generated from the following file:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/contrib/epee/include/net/http_server_impl_base.h