mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
async handshake
This commit is contained in:
parent
e194854c6d
commit
ad79ec7b1f
|
@ -134,20 +134,29 @@ namespace client
|
|||
if (!ecode)
|
||||
{
|
||||
LogPrint (eLogInfo, "New I2PControl request from ", socket->lowest_layer ().remote_endpoint ());
|
||||
boost::system::error_code ec;
|
||||
socket->handshake (boost::asio::ssl::stream_base::server, ec);
|
||||
if (!ec)
|
||||
{
|
||||
std::this_thread::sleep_for (std::chrono::milliseconds(5));
|
||||
ReadRequest (socket);
|
||||
}
|
||||
else
|
||||
LogPrint (eLogError, "I2PControl handshake error: ", ec.message ());
|
||||
Handshake (socket);
|
||||
}
|
||||
else
|
||||
LogPrint (eLogError, "I2PControl accept error: ", ecode.message ());
|
||||
}
|
||||
|
||||
void I2PControlService::Handshake (std::shared_ptr<ssl_socket> socket)
|
||||
{
|
||||
socket->async_handshake(boost::asio::ssl::stream_base::server,
|
||||
std::bind( &I2PControlService::HandleHandshake, this, std::placeholders::_1, socket));
|
||||
}
|
||||
|
||||
void I2PControlService::HandleHandshake (const boost::system::error_code& ecode, std::shared_ptr<ssl_socket> socket)
|
||||
{
|
||||
if (!ecode)
|
||||
{
|
||||
//std::this_thread::sleep_for (std::chrono::milliseconds(5));
|
||||
ReadRequest (socket);
|
||||
}
|
||||
else
|
||||
LogPrint (eLogError, "I2PControl handshake error: ", ecode.message ());
|
||||
}
|
||||
|
||||
void I2PControlService::ReadRequest (std::shared_ptr<ssl_socket> socket)
|
||||
{
|
||||
auto request = std::make_shared<I2PControlBuffer>();
|
||||
|
|
|
@ -89,6 +89,8 @@ namespace client
|
|||
void Run ();
|
||||
void Accept ();
|
||||
void HandleAccept(const boost::system::error_code& ecode, std::shared_ptr<ssl_socket> socket);
|
||||
void Handshake (std::shared_ptr<ssl_socket> socket);
|
||||
void HandleHandshake (const boost::system::error_code& ecode, std::shared_ptr<ssl_socket> socket);
|
||||
void ReadRequest (std::shared_ptr<ssl_socket> socket);
|
||||
void HandleRequestReceived (const boost::system::error_code& ecode, size_t bytes_transferred,
|
||||
std::shared_ptr<ssl_socket> socket, std::shared_ptr<I2PControlBuffer> buf);
|
||||
|
|
Loading…
Reference in a new issue