mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
some fixes
This commit is contained in:
parent
296ae46ed8
commit
8efa1313f3
67 changed files with 1523 additions and 757 deletions
|
@ -57,7 +57,7 @@ namespace net_utils
|
|||
|
||||
struct i_connection_filter
|
||||
{
|
||||
virtual bool is_remote_ip_allowed(boost::uint32_t adress)=0;
|
||||
virtual bool is_remote_ip_allowed(uint32_t adress)=0;
|
||||
protected:
|
||||
virtual ~i_connection_filter(){}
|
||||
};
|
||||
|
@ -76,7 +76,7 @@ namespace net_utils
|
|||
typedef typename t_protocol_handler::connection_context t_connection_context;
|
||||
/// Construct a connection with the given io_service.
|
||||
explicit connection(boost::asio::io_service& io_service,
|
||||
typename t_protocol_handler::config_type& config, volatile boost::uint32_t& sock_count, i_connection_filter * &pfilter);
|
||||
typename t_protocol_handler::config_type& config, volatile uint32_t& sock_count, i_connection_filter * &pfilter);
|
||||
|
||||
virtual ~connection();
|
||||
/// Get the socket associated with the connection.
|
||||
|
@ -117,11 +117,11 @@ namespace net_utils
|
|||
boost::array<char, 8192> buffer_;
|
||||
|
||||
t_connection_context context;
|
||||
volatile boost::uint32_t m_want_close_connection;
|
||||
volatile uint32_t m_want_close_connection;
|
||||
std::atomic<bool> m_was_shutdown;
|
||||
critical_section m_send_que_lock;
|
||||
std::list<std::string> m_send_que;
|
||||
volatile boost::uint32_t& m_ref_sockets_count;
|
||||
volatile uint32_t& m_ref_sockets_count;
|
||||
i_connection_filter* &m_pfilter;
|
||||
volatile bool m_is_multithreaded;
|
||||
|
||||
|
@ -156,7 +156,7 @@ namespace net_utils
|
|||
bool run_server(size_t threads_count, bool wait = true);
|
||||
|
||||
/// wait for service workers stop
|
||||
bool timed_wait_server_stop(boost::uint64_t wait_mseconds);
|
||||
bool timed_wait_server_stop(uint64_t wait_mseconds);
|
||||
|
||||
/// Stop the server.
|
||||
void send_stop_signal();
|
||||
|
@ -171,9 +171,9 @@ namespace net_utils
|
|||
|
||||
void set_connection_filter(i_connection_filter* pfilter);
|
||||
|
||||
bool connect(const std::string& adr, const std::string& port, boost::uint32_t conn_timeot, t_connection_context& cn, const std::string& bind_ip = "0.0.0.0");
|
||||
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");
|
||||
template<class t_callback>
|
||||
bool connect_async(const std::string& adr, const std::string& port, boost::uint32_t conn_timeot, t_callback cb, const std::string& bind_ip = "0.0.0.0");
|
||||
bool connect_async(const std::string& adr, const std::string& port, uint32_t conn_timeot, t_callback cb, const std::string& bind_ip = "0.0.0.0");
|
||||
|
||||
typename t_protocol_handler::config_type& get_config_object(){return m_config;}
|
||||
|
||||
|
@ -191,13 +191,13 @@ namespace net_utils
|
|||
m_timer(io_serice)
|
||||
{}
|
||||
boost::asio::deadline_timer m_timer;
|
||||
boost::uint64_t m_period;
|
||||
uint64_t m_period;
|
||||
};
|
||||
|
||||
template <class t_handler>
|
||||
struct idle_callback_conext: public idle_callback_conext_base
|
||||
{
|
||||
idle_callback_conext(boost::asio::io_service& io_serice, t_handler& h, boost::uint64_t period):
|
||||
idle_callback_conext(boost::asio::io_service& io_serice, t_handler& h, uint64_t period):
|
||||
idle_callback_conext_base(io_serice),
|
||||
m_handler(h)
|
||||
{this->m_period = period;}
|
||||
|
@ -210,7 +210,7 @@ namespace net_utils
|
|||
};
|
||||
|
||||
template<class t_handler>
|
||||
bool add_idle_handler(t_handler t_callback, boost::uint64_t timeout_ms)
|
||||
bool add_idle_handler(t_handler t_callback, uint64_t timeout_ms)
|
||||
{
|
||||
boost::shared_ptr<idle_callback_conext_base> ptr(new idle_callback_conext<t_handler>(io_service_, t_callback, timeout_ms));
|
||||
//needed call handler here ?...
|
||||
|
@ -258,7 +258,7 @@ namespace net_utils
|
|||
connection_ptr new_connection_;
|
||||
std::atomic<bool> m_stop_signal_sent;
|
||||
uint32_t m_port;
|
||||
volatile boost::uint32_t m_sockets_count;
|
||||
volatile uint32_t m_sockets_count;
|
||||
std::string m_address;
|
||||
std::string m_thread_name_prefix;
|
||||
size_t m_threads_count;
|
||||
|
|
|
@ -49,10 +49,9 @@ PRAGMA_WARNING_DISABLE_VS(4355)
|
|||
|
||||
template<class t_protocol_handler>
|
||||
connection<t_protocol_handler>::connection(boost::asio::io_service& io_service,
|
||||
typename t_protocol_handler::config_type& config, volatile boost::uint32_t& sock_count, i_connection_filter* &pfilter)
|
||||
typename t_protocol_handler::config_type& config, volatile uint32_t& sock_count, i_connection_filter* &pfilter)
|
||||
: strand_(io_service),
|
||||
socket_(io_service),
|
||||
//context(typename boost::value_initialized<t_connection_context>())
|
||||
m_protocol_handler(this, config, context),
|
||||
m_want_close_connection(0),
|
||||
m_was_shutdown(0),
|
||||
|
@ -217,6 +216,8 @@ PRAGMA_WARNING_DISABLE_VS(4355)
|
|||
if (!e)
|
||||
{
|
||||
LOG_PRINT("[sock " << socket_.native_handle() << "] RECV " << bytes_transferred, LOG_LEVEL_4);
|
||||
context.m_last_recv = time(NULL);
|
||||
context.m_recv_cnt += bytes_transferred;
|
||||
bool recv_res = m_protocol_handler.handle_recv(buffer_.data(), bytes_transferred);
|
||||
if(!recv_res)
|
||||
{
|
||||
|
@ -294,6 +295,8 @@ PRAGMA_WARNING_DISABLE_VS(4355)
|
|||
return false;
|
||||
|
||||
LOG_PRINT("[sock " << socket_.native_handle() << "] SEND " << cb, LOG_LEVEL_4);
|
||||
context.m_last_send = time(NULL);
|
||||
context.m_send_cnt += cb;
|
||||
//some data should be wrote to stream
|
||||
//request complete
|
||||
|
||||
|
@ -473,8 +476,8 @@ DISABLE_GCC_WARNING(maybe-uninitialized)
|
|||
uint32_t p = 0;
|
||||
|
||||
if (port.size() && !string_tools::get_xtype_from_string(p, port)) {
|
||||
LOG_ERROR("Failed to convert port no = " << port);
|
||||
return false;
|
||||
LOG_ERROR("Failed to convert port no = port");
|
||||
}
|
||||
return this->init_server(p, address);
|
||||
}
|
||||
|
@ -586,7 +589,7 @@ POP_WARNINGS
|
|||
}
|
||||
//---------------------------------------------------------------------------------
|
||||
template<class t_protocol_handler>
|
||||
bool boosted_tcp_server<t_protocol_handler>::timed_wait_server_stop(boost::uint64_t wait_mseconds)
|
||||
bool boosted_tcp_server<t_protocol_handler>::timed_wait_server_stop(uint64_t wait_mseconds)
|
||||
{
|
||||
TRY_ENTRY();
|
||||
boost::chrono::milliseconds ms(wait_mseconds);
|
||||
|
@ -641,7 +644,7 @@ POP_WARNINGS
|
|||
}
|
||||
//---------------------------------------------------------------------------------
|
||||
template<class t_protocol_handler>
|
||||
bool boosted_tcp_server<t_protocol_handler>::connect(const std::string& adr, const std::string& port, boost::uint32_t conn_timeout, t_connection_context& conn_context, const std::string& bind_ip)
|
||||
bool boosted_tcp_server<t_protocol_handler>::connect(const std::string& adr, const std::string& port, uint32_t conn_timeout, t_connection_context& conn_context, const std::string& bind_ip)
|
||||
{
|
||||
TRY_ENTRY();
|
||||
|
||||
|
@ -732,7 +735,7 @@ POP_WARNINGS
|
|||
}
|
||||
//---------------------------------------------------------------------------------
|
||||
template<class t_protocol_handler> template<class t_callback>
|
||||
bool boosted_tcp_server<t_protocol_handler>::connect_async(const std::string& adr, const std::string& port, boost::uint32_t conn_timeout, t_callback cb, const std::string& bind_ip)
|
||||
bool boosted_tcp_server<t_protocol_handler>::connect_async(const std::string& adr, const std::string& port, uint32_t conn_timeout, t_callback cb, const std::string& bind_ip)
|
||||
{
|
||||
TRY_ENTRY();
|
||||
connection_ptr new_connection_l(new connection<t_protocol_handler>(io_service_, m_config, m_sockets_count, m_pfilter) );
|
||||
|
|
|
@ -127,7 +127,7 @@ namespace net_utils
|
|||
std::string schema;
|
||||
std::string host;
|
||||
std::string uri;
|
||||
boost::uint64_t port;
|
||||
uint64_t port;
|
||||
uri_content m_uri_content;
|
||||
};
|
||||
|
||||
|
|
|
@ -55,10 +55,11 @@ namespace net_utils
|
|||
/************************************************************************/
|
||||
/* */
|
||||
/************************************************************************/
|
||||
template<class t_connection_context = net_utils::connection_context_base>
|
||||
class simple_http_connection_handler
|
||||
{
|
||||
public:
|
||||
typedef net_utils::connection_context_base connection_context;
|
||||
typedef t_connection_context connection_context;//t_connection_context net_utils::connection_context_base connection_context;
|
||||
typedef http_server_config config_type;
|
||||
|
||||
simple_http_connection_handler(i_service_endpoint* psnd_hndlr, config_type& config);
|
||||
|
@ -141,30 +142,32 @@ namespace net_utils
|
|||
i_service_endpoint* m_psnd_hndlr;
|
||||
};
|
||||
|
||||
|
||||
template<class t_connection_context>
|
||||
struct i_http_server_handler
|
||||
{
|
||||
virtual ~i_http_server_handler(){}
|
||||
virtual bool handle_http_request(const http_request_info& query_info, http_response_info& response, const net_utils::connection_context_base& m_conn_context)=0;
|
||||
virtual bool handle_http_request(const http_request_info& query_info, http_response_info& response, t_connection_context& m_conn_context)=0;
|
||||
virtual bool init_server_thread(){return true;}
|
||||
virtual bool deinit_server_thread(){return true;}
|
||||
};
|
||||
|
||||
|
||||
template<class t_connection_context>
|
||||
struct custum_handler_config: public http_server_config
|
||||
{
|
||||
i_http_server_handler* m_phandler;
|
||||
i_http_server_handler<t_connection_context>* m_phandler;
|
||||
};
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/************************************************************************/
|
||||
class http_custom_handler: public simple_http_connection_handler
|
||||
|
||||
template<class t_connection_context = net_utils::connection_context_base>
|
||||
class http_custom_handler: public simple_http_connection_handler<t_connection_context>
|
||||
{
|
||||
public:
|
||||
typedef custum_handler_config config_type;
|
||||
typedef custum_handler_config<t_connection_context> config_type;
|
||||
|
||||
http_custom_handler(i_service_endpoint* psnd_hndlr, config_type& config, const net_utils::connection_context_base& conn_context):simple_http_connection_handler(psnd_hndlr, config),
|
||||
http_custom_handler(i_service_endpoint* psnd_hndlr, config_type& config, t_connection_context& conn_context):simple_http_connection_handler<t_connection_context>(psnd_hndlr, config),
|
||||
m_config(config),
|
||||
m_conn_context(conn_context)
|
||||
{}
|
||||
|
@ -198,7 +201,7 @@ namespace net_utils
|
|||
private:
|
||||
//simple_http_connection_handler::config_type m_stub_config;
|
||||
config_type& m_config;
|
||||
const net_utils::connection_context_base& m_conn_context;
|
||||
t_connection_context& m_conn_context;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,8 +191,8 @@ namespace net_utils
|
|||
|
||||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
inline
|
||||
simple_http_connection_handler::simple_http_connection_handler(i_service_endpoint* psnd_hndlr, config_type& config):
|
||||
template<class t_connection_context>
|
||||
simple_http_connection_handler<t_connection_context>::simple_http_connection_handler(i_service_endpoint* psnd_hndlr, config_type& config):
|
||||
m_state(http_state_retriving_comand_line),
|
||||
m_body_transfer_type(http_body_transfer_undefined),
|
||||
m_is_stop_handling(false),
|
||||
|
@ -205,7 +205,8 @@ namespace net_utils
|
|||
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------
|
||||
inline bool simple_http_connection_handler::set_ready_state()
|
||||
template<class t_connection_context>
|
||||
bool simple_http_connection_handler<t_connection_context>::set_ready_state()
|
||||
{
|
||||
m_is_stop_handling = false;
|
||||
m_state = http_state_retriving_comand_line;
|
||||
|
@ -215,7 +216,8 @@ namespace net_utils
|
|||
return true;
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------
|
||||
inline bool simple_http_connection_handler::handle_recv(const void* ptr, size_t cb)
|
||||
template<class t_connection_context>
|
||||
bool simple_http_connection_handler<t_connection_context>::handle_recv(const void* ptr, size_t cb)
|
||||
{
|
||||
std::string buf((const char*)ptr, cb);
|
||||
//LOG_PRINT_L0("HTTP_RECV: " << ptr << "\r\n" << buf);
|
||||
|
@ -227,7 +229,8 @@ namespace net_utils
|
|||
return res;
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------
|
||||
inline bool simple_http_connection_handler::handle_buff_in(std::string& buf)
|
||||
template<class t_connection_context>
|
||||
bool simple_http_connection_handler<t_connection_context>::handle_buff_in(std::string& buf)
|
||||
{
|
||||
|
||||
if(m_cache.size())
|
||||
|
@ -324,9 +327,10 @@ namespace net_utils
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
inline bool simple_http_connection_handler::handle_invoke_query_line()
|
||||
template<class t_connection_context>
|
||||
bool simple_http_connection_handler<t_connection_context>::handle_invoke_query_line()
|
||||
{
|
||||
LOG_FRAME("simple_http_connection_handler::handle_recognize_protocol_out(*)", LOG_LEVEL_3);
|
||||
LOG_FRAME("simple_http_connection_handler<t_connection_context>::handle_recognize_protocol_out(*)", LOG_LEVEL_3);
|
||||
|
||||
STATIC_REGEXP_EXPR_1(rexp_match_command_line, "^(((OPTIONS)|(GET)|(HEAD)|(POST)|(PUT)|(DELETE)|(TRACE)) (\\S+) HTTP/(\\d+).(\\d+))\r?\n", boost::regex::icase | boost::regex::normal);
|
||||
// 123 4 5 6 7 8 9 10 11 12
|
||||
|
@ -348,14 +352,15 @@ namespace net_utils
|
|||
}else
|
||||
{
|
||||
m_state = http_state_error;
|
||||
LOG_ERROR("simple_http_connection_handler::handle_invoke_query_line(): Failed to match first line: " << m_cache);
|
||||
LOG_ERROR("simple_http_connection_handler<t_connection_context>::handle_invoke_query_line(): Failed to match first line: " << m_cache);
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------
|
||||
inline std::string::size_type simple_http_connection_handler::match_end_of_header(const std::string& buf)
|
||||
template<class t_connection_context>
|
||||
std::string::size_type simple_http_connection_handler<t_connection_context>::match_end_of_header(const std::string& buf)
|
||||
{
|
||||
|
||||
//Here we returning head size, including terminating sequence (\r\n\r\n or \n\n)
|
||||
|
@ -368,18 +373,19 @@ namespace net_utils
|
|||
return res;
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------
|
||||
inline bool simple_http_connection_handler::analize_cached_request_header_and_invoke_state(size_t pos)
|
||||
template<class t_connection_context>
|
||||
bool simple_http_connection_handler<t_connection_context>::analize_cached_request_header_and_invoke_state(size_t pos)
|
||||
{
|
||||
//LOG_PRINT_L4("HTTP HEAD:\r\n" << m_cache.substr(0, pos));
|
||||
|
||||
LOG_FRAME("simple_http_connection_handler::analize_cached_request_header_and_invoke_state(*)", LOG_LEVEL_3);
|
||||
LOG_FRAME("simple_http_connection_handler<t_connection_context>::analize_cached_request_header_and_invoke_state(*)", LOG_LEVEL_3);
|
||||
|
||||
m_query_info.m_full_request_buf_size = pos;
|
||||
m_query_info.m_request_head.assign(m_cache.begin(), m_cache.begin()+pos);
|
||||
|
||||
if(!parse_cached_header(m_query_info.m_header_info, m_cache, pos))
|
||||
{
|
||||
LOG_ERROR("simple_http_connection_handler::analize_cached_request_header_and_invoke_state(): failed to anilize request header: " << m_cache);
|
||||
LOG_ERROR("simple_http_connection_handler<t_connection_context>::analize_cached_request_header_and_invoke_state(): failed to anilize request header: " << m_cache);
|
||||
m_state = http_state_error;
|
||||
}
|
||||
|
||||
|
@ -394,7 +400,7 @@ namespace net_utils
|
|||
m_body_transfer_type = http_body_transfer_measure;
|
||||
if(!get_len_from_content_lenght(m_query_info.m_header_info.m_content_length, m_len_summary))
|
||||
{
|
||||
LOG_ERROR("simple_http_connection_handler::analize_cached_request_header_and_invoke_state(): Failed to get_len_from_content_lenght();, m_query_info.m_content_length="<<m_query_info.m_header_info.m_content_length);
|
||||
LOG_ERROR("simple_http_connection_handler<t_connection_context>::analize_cached_request_header_and_invoke_state(): Failed to get_len_from_content_lenght();, m_query_info.m_content_length="<<m_query_info.m_header_info.m_content_length);
|
||||
m_state = http_state_error;
|
||||
return false;
|
||||
}
|
||||
|
@ -415,7 +421,8 @@ namespace net_utils
|
|||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
inline bool simple_http_connection_handler::handle_retriving_query_body()
|
||||
template<class t_connection_context>
|
||||
bool simple_http_connection_handler<t_connection_context>::handle_retriving_query_body()
|
||||
{
|
||||
switch(m_body_transfer_type)
|
||||
{
|
||||
|
@ -426,7 +433,7 @@ namespace net_utils
|
|||
case http_body_transfer_multipart:
|
||||
case http_body_transfer_undefined:
|
||||
default:
|
||||
LOG_ERROR("simple_http_connection_handler::handle_retriving_query_body(): Unexpected m_body_query_type state:" << m_body_transfer_type);
|
||||
LOG_ERROR("simple_http_connection_handler<t_connection_context>::handle_retriving_query_body(): Unexpected m_body_query_type state:" << m_body_transfer_type);
|
||||
m_state = http_state_error;
|
||||
return false;
|
||||
}
|
||||
|
@ -434,7 +441,8 @@ namespace net_utils
|
|||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
inline bool simple_http_connection_handler::handle_query_measure()
|
||||
template<class t_connection_context>
|
||||
bool simple_http_connection_handler<t_connection_context>::handle_query_measure()
|
||||
{
|
||||
|
||||
if(m_len_remain >= m_cache.size())
|
||||
|
@ -459,7 +467,8 @@ namespace net_utils
|
|||
return true;
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------
|
||||
inline bool simple_http_connection_handler::parse_cached_header(http_header_info& body_info, const std::string& m_cache_to_process, size_t pos)
|
||||
template<class t_connection_context>
|
||||
bool simple_http_connection_handler<t_connection_context>::parse_cached_header(http_header_info& body_info, const std::string& m_cache_to_process, size_t pos)
|
||||
{
|
||||
LOG_FRAME("http_stream_filter::parse_cached_header(*)", LOG_LEVEL_3);
|
||||
|
||||
|
@ -503,7 +512,7 @@ namespace net_utils
|
|||
body_info.m_etc_fields.push_back(std::pair<std::string, std::string>(result[field_etc_name], result[field_val]));
|
||||
else
|
||||
{
|
||||
LOG_ERROR("simple_http_connection_handler::parse_cached_header() not matched last entry in:"<<m_cache_to_process);
|
||||
LOG_ERROR("simple_http_connection_handler<t_connection_context>::parse_cached_header() not matched last entry in:"<<m_cache_to_process);
|
||||
}
|
||||
|
||||
it_current_bound = result[(int)result.size()-1]. first;
|
||||
|
@ -511,7 +520,8 @@ namespace net_utils
|
|||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
inline bool simple_http_connection_handler::get_len_from_content_lenght(const std::string& str, size_t& OUT len)
|
||||
template<class t_connection_context>
|
||||
bool simple_http_connection_handler<t_connection_context>::get_len_from_content_lenght(const std::string& str, size_t& OUT len)
|
||||
{
|
||||
STATIC_REGEXP_EXPR_1(rexp_mach_field, "\\d+", boost::regex::normal);
|
||||
std::string res;
|
||||
|
@ -523,7 +533,8 @@ namespace net_utils
|
|||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
inline bool simple_http_connection_handler::handle_request_and_send_response(const http::http_request_info& query_info)
|
||||
template<class t_connection_context>
|
||||
bool simple_http_connection_handler<t_connection_context>::handle_request_and_send_response(const http::http_request_info& query_info)
|
||||
{
|
||||
http_response_info response;
|
||||
bool res = handle_request(query_info, response);
|
||||
|
@ -540,7 +551,8 @@ namespace net_utils
|
|||
return res;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
inline bool simple_http_connection_handler::handle_request(const http::http_request_info& query_info, http_response_info& response)
|
||||
template<class t_connection_context>
|
||||
bool simple_http_connection_handler<t_connection_context>::handle_request(const http::http_request_info& query_info, http_response_info& response)
|
||||
{
|
||||
|
||||
std::string uri_to_path = query_info.m_uri_content.m_path;
|
||||
|
@ -570,7 +582,8 @@ namespace net_utils
|
|||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
inline std::string simple_http_connection_handler::get_response_header(const http_response_info& response)
|
||||
template<class t_connection_context>
|
||||
std::string simple_http_connection_handler<t_connection_context>::get_response_header(const http_response_info& response)
|
||||
{
|
||||
std::string buf = "HTTP/1.1 ";
|
||||
buf += boost::lexical_cast<std::string>(response.m_response_code) + " " + response.m_response_comment + "\r\n" +
|
||||
|
@ -607,7 +620,8 @@ namespace net_utils
|
|||
return buf;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
inline std::string simple_http_connection_handler::get_file_mime_tipe(const std::string& path)
|
||||
template<class t_connection_context>
|
||||
std::string simple_http_connection_handler<t_connection_context>::get_file_mime_tipe(const std::string& path)
|
||||
{
|
||||
std::string result;
|
||||
std::string ext = string_tools::get_extension(path);
|
||||
|
@ -632,7 +646,8 @@ namespace net_utils
|
|||
return result;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
inline std::string simple_http_connection_handler::get_not_found_response_body(const std::string& URI)
|
||||
template<class t_connection_context>
|
||||
std::string simple_http_connection_handler<t_connection_context>::get_not_found_response_body(const std::string& URI)
|
||||
{
|
||||
std::string body =
|
||||
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
|
||||
|
@ -648,7 +663,8 @@ namespace net_utils
|
|||
return body;
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------
|
||||
inline bool simple_http_connection_handler::slash_to_back_slash(std::string& str)
|
||||
template<class t_connection_context>
|
||||
bool simple_http_connection_handler<t_connection_context>::slash_to_back_slash(std::string& str)
|
||||
{
|
||||
for(std::string::iterator it = str.begin(); it!=str.end(); it++)
|
||||
if('/' == *it)
|
||||
|
|
|
@ -36,8 +36,8 @@ namespace epee
|
|||
{
|
||||
namespace net_utils
|
||||
{
|
||||
typedef boosted_tcp_server<http::simple_http_connection_handler> boosted_http_server_file_system;
|
||||
typedef boosted_tcp_server<http::http_custom_handler> boosted_http_server_custum_handling;
|
||||
typedef boosted_tcp_server<http::simple_http_connection_handler<> > boosted_http_server_file_system;
|
||||
typedef boosted_tcp_server<http::http_custom_handler<> > boosted_http_server_custum_handling;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,9 +31,9 @@
|
|||
#include "http_base.h"
|
||||
|
||||
|
||||
#define CHAIN_HTTP_TO_MAP2() bool handle_http_request(const epee::net_utils::http::http_request_info& query_info, \
|
||||
#define CHAIN_HTTP_TO_MAP2(context_type) bool handle_http_request(const epee::net_utils::http::http_request_info& query_info, \
|
||||
epee::net_utils::http::http_response_info& response, \
|
||||
const epee::net_utils::connection_context_base& m_conn_context) \
|
||||
context_type& m_conn_context) \
|
||||
{\
|
||||
LOG_PRINT_L2("HTTP [" << epee::string_tools::get_ip_string_from_int32(m_conn_context.m_remote_ip ) << "] " << query_info.m_http_method_str << " " << query_info.m_URI); \
|
||||
response.m_response_code = 200; \
|
||||
|
@ -44,9 +44,9 @@
|
|||
}
|
||||
|
||||
|
||||
#define BEGIN_URI_MAP2() bool handle_http_request_map(const epee::net_utils::http::http_request_info& query_info, \
|
||||
#define BEGIN_URI_MAP2() template<class t_context> bool handle_http_request_map(const epee::net_utils::http::http_request_info& query_info, \
|
||||
epee::net_utils::http::http_response_info& response_info, \
|
||||
const epee::net_utils::connection_context_base& m_conn_context) { \
|
||||
t_context& m_conn_context) { \
|
||||
bool handled = false; \
|
||||
if(false) return true; //just a stub to have "else if"
|
||||
|
||||
|
@ -58,22 +58,22 @@
|
|||
else if(query_info.m_URI == s_pattern) \
|
||||
{ \
|
||||
handled = true; \
|
||||
boost::uint64_t ticks = misc_utils::get_tick_count(); \
|
||||
uint64_t ticks = misc_utils::get_tick_count(); \
|
||||
boost::value_initialized<command_type::request> req; \
|
||||
bool parse_res = epee::serialization::load_t_from_json(static_cast<command_type::request&>(req), query_info.m_body); \
|
||||
CHECK_AND_ASSERT_MES(parse_res, false, "Failed to parse json: \r\n" << query_info.m_body); \
|
||||
boost::uint64_t ticks1 = epee::misc_utils::get_tick_count(); \
|
||||
uint64_t ticks1 = epee::misc_utils::get_tick_count(); \
|
||||
boost::value_initialized<command_type::response> resp;\
|
||||
if(!callback_f(static_cast<command_type::request&>(req), static_cast<command_type::response&>(resp))) \
|
||||
if(!callback_f(static_cast<command_type::request&>(req), static_cast<command_type::response&>(resp), m_conn_context)) \
|
||||
{ \
|
||||
LOG_ERROR("Failed to " << #callback_f << "()"); \
|
||||
response_info.m_response_code = 500; \
|
||||
response_info.m_response_comment = "Internal Server Error"; \
|
||||
return true; \
|
||||
} \
|
||||
boost::uint64_t ticks2 = epee::misc_utils::get_tick_count(); \
|
||||
uint64_t ticks2 = epee::misc_utils::get_tick_count(); \
|
||||
epee::serialization::store_t_to_json(static_cast<command_type::response&>(resp), response_info.m_body); \
|
||||
boost::uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
|
||||
uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
|
||||
response_info.m_mime_tipe = "application/json"; \
|
||||
response_info.m_header_info.m_content_type = " application/json"; \
|
||||
LOG_PRINT( s_pattern << " processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2); \
|
||||
|
@ -83,22 +83,22 @@
|
|||
else if(query_info.m_URI == s_pattern) \
|
||||
{ \
|
||||
handled = true; \
|
||||
boost::uint64_t ticks = misc_utils::get_tick_count(); \
|
||||
uint64_t ticks = misc_utils::get_tick_count(); \
|
||||
boost::value_initialized<command_type::request> req; \
|
||||
bool parse_res = epee::serialization::load_t_from_binary(static_cast<command_type::request&>(req), query_info.m_body); \
|
||||
CHECK_AND_ASSERT_MES(parse_res, false, "Failed to parse bin body data, body size=" << query_info.m_body.size()); \
|
||||
boost::uint64_t ticks1 = misc_utils::get_tick_count(); \
|
||||
uint64_t ticks1 = misc_utils::get_tick_count(); \
|
||||
boost::value_initialized<command_type::response> resp;\
|
||||
if(!callback_f(static_cast<command_type::request&>(req), static_cast<command_type::response&>(resp))) \
|
||||
if(!callback_f(static_cast<command_type::request&>(req), static_cast<command_type::response&>(resp), m_conn_context)) \
|
||||
{ \
|
||||
LOG_ERROR("Failed to " << #callback_f << "()"); \
|
||||
response_info.m_response_code = 500; \
|
||||
response_info.m_response_comment = "Internal Server Error"; \
|
||||
return true; \
|
||||
} \
|
||||
boost::uint64_t ticks2 = misc_utils::get_tick_count(); \
|
||||
uint64_t ticks2 = misc_utils::get_tick_count(); \
|
||||
epee::serialization::store_t_to_binary(static_cast<command_type::response&>(resp), response_info.m_body); \
|
||||
boost::uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
|
||||
uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
|
||||
response_info.m_mime_tipe = " application/octet-stream"; \
|
||||
response_info.m_header_info.m_content_type = " application/octet-stream"; \
|
||||
LOG_PRINT( s_pattern << "() processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2); \
|
||||
|
@ -170,7 +170,7 @@ namespace epee
|
|||
|
||||
#define BEGIN_JSON_RPC_MAP(uri) else if(query_info.m_URI == uri) \
|
||||
{ \
|
||||
boost::uint64_t ticks = epee::misc_utils::get_tick_count(); \
|
||||
uint64_t ticks = epee::misc_utils::get_tick_count(); \
|
||||
epee::serialization::portable_storage ps; \
|
||||
if(!ps.load_from_json(query_info.m_body)) \
|
||||
{ \
|
||||
|
@ -198,20 +198,20 @@ namespace epee
|
|||
boost::value_initialized<epee::json_rpc::request<command_type::request> > req_; \
|
||||
epee::json_rpc::request<command_type::request>& req = static_cast<epee::json_rpc::request<command_type::request>&>(req_);\
|
||||
req.load(ps); \
|
||||
boost::uint64_t ticks1 = epee::misc_utils::get_tick_count(); \
|
||||
uint64_t ticks1 = epee::misc_utils::get_tick_count(); \
|
||||
boost::value_initialized<epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error> > resp_; \
|
||||
epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error>& resp = static_cast<epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error> &>(resp_); \
|
||||
resp.id = req.id; \
|
||||
epee::json_rpc::error_response fail_resp = AUTO_VAL_INIT(fail_resp); \
|
||||
fail_resp.id = req.id; \
|
||||
if(!callback_f(req.params, resp.result, fail_resp.error)) \
|
||||
if(!callback_f(req.params, resp.result, fail_resp.error, m_conn_context)) \
|
||||
{ \
|
||||
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(fail_resp), response_info.m_body); \
|
||||
return true; \
|
||||
} \
|
||||
boost::uint64_t ticks2 = epee::misc_utils::get_tick_count(); \
|
||||
uint64_t ticks2 = epee::misc_utils::get_tick_count(); \
|
||||
epee::serialization::store_t_to_json(resp, response_info.m_body); \
|
||||
boost::uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
|
||||
uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
|
||||
response_info.m_mime_tipe = "application/json"; \
|
||||
response_info.m_header_info.m_content_type = " application/json"; \
|
||||
LOG_PRINT( query_info.m_URI << "[" << method_name << "] processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2); \
|
||||
|
@ -226,11 +226,11 @@ namespace epee
|
|||
boost::value_initialized<epee::json_rpc::request<command_type::request> > req_; \
|
||||
epee::json_rpc::request<command_type::request>& req = static_cast<epee::json_rpc::request<command_type::request>&>(req_);\
|
||||
req.load(ps); \
|
||||
boost::uint64_t ticks1 = epee::misc_utils::get_tick_count(); \
|
||||
uint64_t ticks1 = epee::misc_utils::get_tick_count(); \
|
||||
boost::value_initialized<epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error> > resp_; \
|
||||
epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error>& resp = static_cast<epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error> &>(resp_); \
|
||||
resp.id = req.id; \
|
||||
if(!callback_f(req.params, resp.result)) \
|
||||
if(!callback_f(req.params, resp.result, m_conn_context)) \
|
||||
{ \
|
||||
epee::json_rpc::error_response fail_resp = AUTO_VAL_INIT(fail_resp); \
|
||||
fail_resp.id = req.id; \
|
||||
|
@ -239,9 +239,9 @@ namespace epee
|
|||
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(fail_resp), response_info.m_body); \
|
||||
return true; \
|
||||
} \
|
||||
boost::uint64_t ticks2 = epee::misc_utils::get_tick_count(); \
|
||||
uint64_t ticks2 = epee::misc_utils::get_tick_count(); \
|
||||
epee::serialization::store_t_to_json(resp, response_info.m_body); \
|
||||
boost::uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
|
||||
uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
|
||||
response_info.m_mime_tipe = "application/json"; \
|
||||
response_info.m_header_info.m_content_type = " application/json"; \
|
||||
LOG_PRINT( query_info.m_URI << "[" << method_name << "] processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2); \
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
namespace epee
|
||||
{
|
||||
|
||||
template<class t_child_class>
|
||||
class http_server_impl_base: public net_utils::http::i_http_server_handler
|
||||
template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
|
||||
class http_server_impl_base: public net_utils::http::i_http_server_handler<t_connection_context>
|
||||
{
|
||||
|
||||
public:
|
||||
|
@ -107,6 +107,6 @@ namespace epee
|
|||
}
|
||||
|
||||
protected:
|
||||
net_utils::boosted_http_server_custum_handling m_net_server;
|
||||
net_utils::boosted_tcp_server<net_utils::http::http_custom_handler<t_connection_context> > m_net_server;
|
||||
};
|
||||
}
|
|
@ -41,13 +41,13 @@ namespace levin
|
|||
#pragma pack(1)
|
||||
struct bucket_head
|
||||
{
|
||||
boost::uint64_t m_signature;
|
||||
boost::uint64_t m_cb;
|
||||
bool m_have_to_return_data;
|
||||
boost::uint32_t m_command;
|
||||
boost::int32_t m_return_code;
|
||||
boost::uint32_t m_reservedA; //probably some flags in future
|
||||
boost::uint32_t m_reservedB; //probably some check sum in future
|
||||
uint64_t m_signature;
|
||||
uint64_t m_cb;
|
||||
bool m_have_to_return_data;
|
||||
uint32_t m_command;
|
||||
int32_t m_return_code;
|
||||
uint32_t m_reservedA; //probably some flags in future
|
||||
uint32_t m_reservedB; //probably some check sum in future
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
@ -56,13 +56,13 @@ namespace levin
|
|||
#pragma pack(1)
|
||||
struct bucket_head2
|
||||
{
|
||||
boost::uint64_t m_signature;
|
||||
boost::uint64_t m_cb;
|
||||
bool m_have_to_return_data;
|
||||
boost::uint32_t m_command;
|
||||
boost::int32_t m_return_code;
|
||||
boost::uint32_t m_flags;
|
||||
boost::uint32_t m_protocol_version;
|
||||
uint64_t m_signature;
|
||||
uint64_t m_cb;
|
||||
bool m_have_to_return_data;
|
||||
uint32_t m_command;
|
||||
int32_t m_return_code;
|
||||
uint32_t m_flags;
|
||||
uint32_t m_protocol_version;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
|
|
@ -49,16 +49,16 @@ namespace levin
|
|||
class levin_client_async
|
||||
{
|
||||
levin_commands_handler* m_pcommands_handler;
|
||||
volatile boost::uint32_t m_is_stop;
|
||||
volatile boost::uint32_t m_threads_count;
|
||||
volatile uint32_t m_is_stop;
|
||||
volatile uint32_t m_threads_count;
|
||||
::critical_section m_send_lock;
|
||||
|
||||
std::string m_local_invoke_buff;
|
||||
::critical_section m_local_invoke_buff_lock;
|
||||
volatile int m_invoke_res;
|
||||
|
||||
volatile boost::uint32_t m_invoke_data_ready;
|
||||
volatile boost::uint32_t m_invoke_is_active;
|
||||
volatile uint32_t m_invoke_data_ready;
|
||||
volatile uint32_t m_invoke_is_active;
|
||||
|
||||
boost::mutex m_invoke_event;
|
||||
boost::condition_variable m_invoke_cond;
|
||||
|
@ -69,14 +69,14 @@ namespace levin
|
|||
{
|
||||
bucket_head m_hd;
|
||||
std::string m_body;
|
||||
boost::uint32_t m_connection_index;
|
||||
uint32_t m_connection_index;
|
||||
};
|
||||
std::list<packet_entry> m_recieved_packets;
|
||||
/*
|
||||
m_current_connection_index needed when some connection was broken and reconnected - in this
|
||||
case we could have some received packets in que, which shoud not be handled
|
||||
*/
|
||||
volatile boost::uint32_t m_current_connection_index;
|
||||
volatile uint32_t m_current_connection_index;
|
||||
::critical_section m_invoke_lock;
|
||||
::critical_section m_reciev_packet_lock;
|
||||
::critical_section m_connection_lock;
|
||||
|
@ -101,7 +101,7 @@ namespace levin
|
|||
m_pcommands_handler = phandler;
|
||||
}
|
||||
|
||||
bool connect(boost::uint32_t ip, boost::uint32_t port, boost::uint32_t timeout)
|
||||
bool connect(uint32_t ip, uint32_t port, uint32_t timeout)
|
||||
{
|
||||
loop_call_guard();
|
||||
critical_region cr(m_connection_lock);
|
||||
|
@ -388,7 +388,7 @@ namespace levin
|
|||
bool reciev_and_process_incoming_data()
|
||||
{
|
||||
bucket_head head = {0};
|
||||
boost::uint32_t conn_index = 0;
|
||||
uint32_t conn_index = 0;
|
||||
bool is_request = false;
|
||||
std::string local_buff;
|
||||
CRITICAL_REGION_BEGIN(m_reciev_packet_lock);//to protect from socket reconnect between head and body
|
||||
|
@ -485,7 +485,7 @@ namespace levin
|
|||
return true;
|
||||
}
|
||||
|
||||
bool process_recieved_packet(bucket_head& head, const std::string& local_buff, boost::uint32_t conn_index)
|
||||
bool process_recieved_packet(bucket_head& head, const std::string& local_buff, uint32_t conn_index)
|
||||
{
|
||||
|
||||
net_utils::connection_context_base conn_context;
|
||||
|
@ -544,7 +544,7 @@ namespace levin
|
|||
bool have_some_work = false;
|
||||
std::string local_buff;
|
||||
bucket_head bh = {0};
|
||||
boost::uint32_t conn_index = 0;
|
||||
uint32_t conn_index = 0;
|
||||
|
||||
CRITICAL_REGION_BEGIN(m_recieved_packets_lock);
|
||||
if(m_recieved_packets.size())
|
||||
|
|
|
@ -98,7 +98,7 @@ namespace levin
|
|||
case conn_state_reading_head:
|
||||
if(m_cach_in_buffer.size() < sizeof(bucket_head))
|
||||
{
|
||||
if(m_cach_in_buffer.size() >= sizeof(boost::uint64_t) && *((boost::uint64_t*)m_cach_in_buffer.data()) != LEVIN_SIGNATURE)
|
||||
if(m_cach_in_buffer.size() >= sizeof(uint64_t) && *((uint64_t*)m_cach_in_buffer.data()) != LEVIN_SIGNATURE)
|
||||
{
|
||||
LOG_ERROR("Signature missmatch on accepted connection");
|
||||
return false;
|
||||
|
|
|
@ -64,8 +64,8 @@ class async_protocol_handler_config
|
|||
public:
|
||||
typedef t_connection_context connection_context;
|
||||
levin_commands_handler<t_connection_context>* m_pcommands_handler;
|
||||
boost::uint64_t m_max_packet_size;
|
||||
boost::uint64_t m_invoke_timeout;
|
||||
uint64_t m_max_packet_size;
|
||||
uint64_t m_invoke_timeout;
|
||||
|
||||
int invoke(int command, const std::string& in_buff, std::string& buff_out, boost::uuids::uuid connection_id);
|
||||
template<class callback_t>
|
||||
|
@ -122,7 +122,7 @@ public:
|
|||
std::string m_cache_in_buffer;
|
||||
stream_state m_state;
|
||||
|
||||
boost::int32_t m_oponent_protocol_ver;
|
||||
int32_t m_oponent_protocol_ver;
|
||||
bool m_connection_initialized;
|
||||
|
||||
struct invoke_response_handler_base
|
||||
|
@ -424,7 +424,7 @@ public:
|
|||
{
|
||||
if(m_cache_in_buffer.size() < sizeof(bucket_head2))
|
||||
{
|
||||
if(m_cache_in_buffer.size() >= sizeof(boost::uint64_t) && *((boost::uint64_t*)m_cache_in_buffer.data()) != LEVIN_SIGNATURE)
|
||||
if(m_cache_in_buffer.size() >= sizeof(uint64_t) && *((uint64_t*)m_cache_in_buffer.data()) != LEVIN_SIGNATURE)
|
||||
{
|
||||
LOG_ERROR_CC(m_connection_context, "Signature mismatch, connection will be closed");
|
||||
return false;
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace epee
|
|||
namespace net_utils
|
||||
{
|
||||
inline
|
||||
bool is_ip_local(boost::uint32_t ip)
|
||||
bool is_ip_local(uint32_t ip)
|
||||
{
|
||||
/*
|
||||
local ip area
|
||||
|
@ -55,7 +55,7 @@ namespace epee
|
|||
return false;
|
||||
}
|
||||
inline
|
||||
bool is_ip_loopback(boost::uint32_t ip)
|
||||
bool is_ip_loopback(uint32_t ip)
|
||||
{
|
||||
if( (ip | 0xffffff00) == 0xffffff7f)
|
||||
return true;
|
||||
|
|
|
@ -429,7 +429,7 @@ namespace net_utils
|
|||
|
||||
}
|
||||
|
||||
inline bool recv_n(std::string& buff, boost::int64_t sz)
|
||||
inline bool recv_n(std::string& buff, int64_t sz)
|
||||
{
|
||||
|
||||
try
|
||||
|
@ -564,7 +564,7 @@ namespace net_utils
|
|||
bool m_initialized;
|
||||
bool m_connected;
|
||||
boost::asio::deadline_timer m_deadline;
|
||||
volatile boost::uint32_t m_shutdowned;
|
||||
volatile uint32_t m_shutdowned;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ namespace net_utils
|
|||
}
|
||||
if(result[6].matched)
|
||||
{
|
||||
content.port = boost::lexical_cast<boost::uint64_t>(result[6]);
|
||||
content.port = boost::lexical_cast<uint64_t>(result[6]);
|
||||
}
|
||||
if(result[7].matched)
|
||||
{
|
||||
|
|
|
@ -47,23 +47,36 @@ namespace net_utils
|
|||
struct connection_context_base
|
||||
{
|
||||
const boost::uuids::uuid m_connection_id;
|
||||
const boost::uint32_t m_remote_ip;
|
||||
const boost::uint32_t m_remote_port;
|
||||
const bool m_is_income;
|
||||
const uint32_t m_remote_ip;
|
||||
const uint32_t m_remote_port;
|
||||
const bool m_is_income;
|
||||
const time_t m_started;
|
||||
time_t m_last_recv;
|
||||
time_t m_last_send;
|
||||
uint64_t m_recv_cnt;
|
||||
uint64_t m_send_cnt;
|
||||
|
||||
connection_context_base(boost::uuids::uuid connection_id, long remote_ip, int remote_port, bool is_income):
|
||||
connection_context_base(boost::uuids::uuid connection_id, long remote_ip, int remote_port, bool is_income, time_t last_recv = 0, time_t last_send = 0, uint64_t recv_cnt = 0, uint64_t send_cnt = 0):
|
||||
m_connection_id(connection_id),
|
||||
m_remote_ip(remote_ip),
|
||||
m_remote_port(remote_port),
|
||||
m_is_income(is_income)
|
||||
|
||||
|
||||
m_is_income(is_income),
|
||||
m_last_recv(last_recv),
|
||||
m_last_send(last_send),
|
||||
m_recv_cnt(recv_cnt),
|
||||
m_send_cnt(send_cnt),
|
||||
m_started(time(NULL))
|
||||
{}
|
||||
|
||||
connection_context_base(): m_connection_id(),
|
||||
m_remote_ip(0),
|
||||
m_remote_port(0),
|
||||
m_is_income(false)
|
||||
m_is_income(false),
|
||||
m_last_recv(0),
|
||||
m_last_send(0),
|
||||
m_recv_cnt(0),
|
||||
m_send_cnt(0),
|
||||
m_started(time(NULL))
|
||||
{}
|
||||
|
||||
connection_context_base& operator=(const connection_context_base& a)
|
||||
|
|
|
@ -95,10 +95,10 @@ namespace net_utils
|
|||
else
|
||||
{
|
||||
m_cached_buff.append((const char*)ptr, cb);
|
||||
if(m_cached_buff.size() < sizeof(boost::uint64_t))
|
||||
if(m_cached_buff.size() < sizeof(uint64_t))
|
||||
return true;
|
||||
|
||||
if(*((boost::uint64_t*)&m_cached_buff[0]) == LEVIN_SIGNATURE)
|
||||
if(*((uint64_t*)&m_cached_buff[0]) == LEVIN_SIGNATURE)
|
||||
{
|
||||
pcurrent_handler = &m_levin_handler;
|
||||
return pcurrent_handler->handle_recv(m_cached_buff.data(), m_cached_buff.size());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue