mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
begins work on timeouts
This commit is contained in:
@@ -61,8 +61,8 @@ int main(int argc, char* argv[]) {
|
||||
);
|
||||
|
||||
// setup server settings
|
||||
server->set_alog_level(websocketpp::ALOG_OFF);
|
||||
server->set_elog_level(websocketpp::LOG_OFF);
|
||||
//server->set_alog_level(websocketpp::ALOG_OFF);
|
||||
//server->set_elog_level(websocketpp::LOG_OFF);
|
||||
|
||||
server->add_host(host);
|
||||
server->add_host(full_host);
|
||||
|
||||
@@ -37,8 +37,8 @@ using websocketpp::server;
|
||||
server::server(boost::asio::io_service& io_service,
|
||||
const tcp::endpoint& endpoint,
|
||||
websocketpp::connection_handler_ptr defc)
|
||||
: m_elog_level(LOG_OFF),
|
||||
m_alog_level(ALOG_OFF),
|
||||
: m_elog_level(LOG_ALL),
|
||||
m_alog_level(ALOG_ALL),
|
||||
m_max_message_size(DEFAULT_MAX_MESSAGE_SIZE),
|
||||
m_io_service(io_service),
|
||||
m_acceptor(io_service, endpoint),
|
||||
|
||||
@@ -92,7 +92,16 @@ void server_session::select_extension(const std::string& val) {
|
||||
}
|
||||
|
||||
void server_session::read_handshake() {
|
||||
// TODO: pass maximum size to m_buf cosntructor to prevent DoS here
|
||||
m_timer.expires_from_now(boost::posix_time::seconds(5));
|
||||
|
||||
m_timer.async_wait(
|
||||
boost::bind(
|
||||
&session::handle_timer_expired,
|
||||
this,
|
||||
boost::asio::placeholders::error
|
||||
)
|
||||
);
|
||||
|
||||
boost::asio::async_read_until(
|
||||
m_socket,
|
||||
m_buf,
|
||||
|
||||
@@ -56,6 +56,7 @@ session::session (boost::asio::io_service& io_service,
|
||||
m_socket(io_service),
|
||||
m_io_service(io_service),
|
||||
m_local_interface(defc),
|
||||
m_timer(io_service,boost::posix_time::seconds(0)),
|
||||
m_buf(buf_size), // maximum buffered (unconsumed) bytes from network
|
||||
m_utf8_state(utf8_validator::UTF8_ACCEPT),
|
||||
m_utf8_codepoint(0) {}
|
||||
@@ -389,6 +390,24 @@ void session::handle_write_frame (const boost::system::error_code& error) {
|
||||
m_writing = false;
|
||||
}
|
||||
|
||||
|
||||
void session::handle_timer_expired (const boost::system::error_code& error) {
|
||||
if (error) {
|
||||
if (error == boost::asio::error::operation_aborted) {
|
||||
log("timer was aborted",LOG_DEBUG);
|
||||
//drop_tcp(false);
|
||||
} else {
|
||||
log("timer ended with error",LOG_DEBUG);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
log("timer ended without error",LOG_DEBUG);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void session::process_ping() {
|
||||
access_log("Ping",ALOG_MISC_CONTROL);
|
||||
// TODO: on_ping
|
||||
|
||||
@@ -193,6 +193,8 @@ protected:
|
||||
void write_frame();
|
||||
void handle_write_frame (const boost::system::error_code& error);
|
||||
|
||||
void handle_timer_expired(const boost::system::error_code& error);
|
||||
|
||||
// helper functions for processing each opcode
|
||||
void process_frame();
|
||||
void process_ping();
|
||||
@@ -267,6 +269,7 @@ protected:
|
||||
tcp::socket m_socket;
|
||||
boost::asio::io_service& m_io_service;
|
||||
connection_handler_ptr m_local_interface;
|
||||
boost::asio::deadline_timer m_timer;
|
||||
|
||||
// Buffers
|
||||
boost::asio::streambuf m_buf;
|
||||
|
||||
@@ -496,7 +496,7 @@
|
||||
B6DF1C471434A5940029A1B1 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0410;
|
||||
LastUpgradeCheck = 0420;
|
||||
};
|
||||
buildConfigurationList = B6DF1C4A1434A5940029A1B1 /* Build configuration list for PBXProject "websocketpp" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
@@ -835,6 +835,7 @@
|
||||
B6CF18251437C397009295BE /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
B6DF1C4A1434A5940029A1B1 /* Build configuration list for PBXProject "websocketpp" */ = {
|
||||
isa = XCConfigurationList;
|
||||
|
||||
Reference in New Issue
Block a user