mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
check expiration of lease
This commit is contained in:
parent
68a0643310
commit
659177e2fd
4 changed files with 52 additions and 7 deletions
|
@ -149,14 +149,14 @@ namespace util
|
|||
uint8_t destination[32];
|
||||
i2p::data::Base32ToByteStream (b32.c_str (), b32.length (), destination, 32);
|
||||
auto leaseSet = i2p::data::netdb.FindLeaseSet (destination);
|
||||
if (!leaseSet)
|
||||
if (!leaseSet || !leaseSet->HasNonExpiredLeases ())
|
||||
{
|
||||
i2p::data::netdb.RequestDestination (i2p::data::IdentHash (destination), true);
|
||||
std::this_thread::sleep_for (std::chrono::seconds(10)); // wait for 10 seconds
|
||||
leaseSet = i2p::data::netdb.FindLeaseSet (destination);
|
||||
if (!leaseSet) // still no LeaseSet
|
||||
if (!leaseSet || !leaseSet->HasNonExpiredLeases ()) // still no LeaseSet
|
||||
{
|
||||
m_Reply.content = "<html>LeaseSet not found</html>";
|
||||
m_Reply.content = leaseSet ? "<html>Leases expired</html>" : "<html>LeaseSet not found</html>";
|
||||
m_Reply.headers.resize(2);
|
||||
m_Reply.headers[0].name = "Content-Length";
|
||||
m_Reply.headers[0].value = boost::lexical_cast<std::string>(m_Reply.content.size());
|
||||
|
@ -166,6 +166,12 @@ namespace util
|
|||
}
|
||||
}
|
||||
// we found LeaseSet
|
||||
if (leaseSet->HasExpiredLeases ())
|
||||
{
|
||||
// we should re-request LeaseSet
|
||||
LogPrint ("LeaseSet re-requested");
|
||||
i2p::data::netdb.RequestDestination (i2p::data::IdentHash (destination), true);
|
||||
}
|
||||
auto s = i2p::stream::CreateStream (leaseSet);
|
||||
if (s)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue