mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 20:44:39 +00:00
more
This commit is contained in:
parent
91fdb038d9
commit
8d7fde0287
@ -196,7 +196,7 @@ namespace transport
|
|||||||
|
|
||||||
m_Encryption.SetIV (y + 240);
|
m_Encryption.SetIV (y + 240);
|
||||||
m_Decryption.SetIV (m_Establisher->phase1.HXxorHI + 16);
|
m_Decryption.SetIV (m_Establisher->phase1.HXxorHI + 16);
|
||||||
|
|
||||||
m_Encryption.Encrypt ((uint8_t *)&m_Establisher->phase2.encrypted, sizeof(m_Establisher->phase2.encrypted), (uint8_t *)&m_Establisher->phase2.encrypted);
|
m_Encryption.Encrypt ((uint8_t *)&m_Establisher->phase2.encrypted, sizeof(m_Establisher->phase2.encrypted), (uint8_t *)&m_Establisher->phase2.encrypted);
|
||||||
boost::asio::async_write (m_Socket, boost::asio::buffer (&m_Establisher->phase2, sizeof (NTCPPhase2)), boost::asio::transfer_all (),
|
boost::asio::async_write (m_Socket, boost::asio::buffer (&m_Establisher->phase2, sizeof (NTCPPhase2)), boost::asio::transfer_all (),
|
||||||
std::bind(&NTCPSession::HandlePhase2Sent, shared_from_this (), std::placeholders::_1, std::placeholders::_2, tsB));
|
std::bind(&NTCPSession::HandlePhase2Sent, shared_from_this (), std::placeholders::_1, std::placeholders::_2, tsB));
|
||||||
@ -237,24 +237,11 @@ namespace transport
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if ((__GNUC__ == 4) && (__GNUC_MINOR__ <= 7)) || defined(__NetBSD__)
|
|
||||||
// due the bug in gcc 4.7. std::shared_future.get() is not const
|
|
||||||
CreateAESKey (m_Establisher->phase2.pubKey);
|
|
||||||
HandlePhase2 ();
|
|
||||||
#else
|
|
||||||
auto s = shared_from_this ();
|
auto s = shared_from_this ();
|
||||||
// create AES key in separate thread
|
m_Server.Work(s, [s]() -> std::function<void(void)> {
|
||||||
auto keyCreated = std::async (std::launch::async, [s] ()
|
s->CreateAESKey (s->m_Establisher->phase2.pubKey);
|
||||||
{
|
return std::bind(&NTCPSession::HandlePhase2, s);
|
||||||
s->CreateAESKey (s->m_Establisher->phase2.pubKey);
|
});
|
||||||
}).share (); // TODO: use move capture in C++ 14 instead shared_future
|
|
||||||
// let other operations execute while a key gets created
|
|
||||||
m_Server.GetService ().post ([s, keyCreated]()
|
|
||||||
{
|
|
||||||
keyCreated.get (); // we might wait if no more pending operations
|
|
||||||
s->HandlePhase2 ();
|
|
||||||
});
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user