mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
hold I2NP message for 5 seconds if router is not in netDb
This commit is contained in:
parent
2640dff22a
commit
9557adf8c2
@ -258,11 +258,31 @@ namespace i2p
|
|||||||
{
|
{
|
||||||
LogPrint ("Router not found. Requested");
|
LogPrint ("Router not found. Requested");
|
||||||
i2p::data::netdb.RequestDestination (ident);
|
i2p::data::netdb.RequestDestination (ident);
|
||||||
DeleteI2NPMessage (msg); // TODO: implement a placeholder for router and send once it's available
|
auto resendTimer = new boost::asio::deadline_timer (m_Service);
|
||||||
|
resendTimer->expires_from_now (boost::posix_time::seconds(5)); // 5 seconds
|
||||||
|
resendTimer->async_wait (boost::bind (&Transports::HandleResendTimer,
|
||||||
|
this, boost::asio::placeholders::error, resendTimer, ident, msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Transports::HandleResendTimer (const boost::system::error_code& ecode,
|
||||||
|
boost::asio::deadline_timer * timer, const i2p::data::IdentHash& ident, i2p::I2NPMessage * msg)
|
||||||
|
{
|
||||||
|
RouterInfo * r = netdb.FindRouter (ident);
|
||||||
|
if (r)
|
||||||
|
{
|
||||||
|
LogPrint ("Router found. Sending message");
|
||||||
|
PostMessage (ident, msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogPrint ("Router not found. Failed to send message");
|
||||||
|
DeleteI2NPMessage (msg);
|
||||||
|
}
|
||||||
|
delete timer;
|
||||||
|
}
|
||||||
|
|
||||||
void Transports::CloseSession (const i2p::data::RouterInfo * router)
|
void Transports::CloseSession (const i2p::data::RouterInfo * router)
|
||||||
{
|
{
|
||||||
if (!router) return;
|
if (!router) return;
|
||||||
|
@ -69,6 +69,8 @@ namespace i2p
|
|||||||
|
|
||||||
void Run ();
|
void Run ();
|
||||||
void HandleAccept (i2p::ntcp::NTCPServerConnection * conn, const boost::system::error_code& error);
|
void HandleAccept (i2p::ntcp::NTCPServerConnection * conn, const boost::system::error_code& error);
|
||||||
|
void HandleResendTimer (const boost::system::error_code& ecode, boost::asio::deadline_timer * timer,
|
||||||
|
const i2p::data::IdentHash& ident, i2p::I2NPMessage * msg);
|
||||||
void PostMessage (const i2p::data::IdentHash& ident, i2p::I2NPMessage * msg);
|
void PostMessage (const i2p::data::IdentHash& ident, i2p::I2NPMessage * msg);
|
||||||
void PostCloseSession (const i2p::data::RouterInfo * router);
|
void PostCloseSession (const i2p::data::RouterInfo * router);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user