mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 08:00:38 +03:00
request LeaseSet through destination's tunnels
This commit is contained in:
parent
6af5fa3d27
commit
05148a2579
@ -742,7 +742,7 @@ namespace util
|
|||||||
auto leaseSet = i2p::data::netdb.FindLeaseSet (destination);
|
auto leaseSet = i2p::data::netdb.FindLeaseSet (destination);
|
||||||
if (!leaseSet || !leaseSet->HasNonExpiredLeases ())
|
if (!leaseSet || !leaseSet->HasNonExpiredLeases ())
|
||||||
{
|
{
|
||||||
i2p::data::netdb.Subscribe(destination);
|
i2p::data::netdb.Subscribe(destination, i2p::stream::GetSharedLocalDestination ()->GetTunnelPool ());
|
||||||
std::this_thread::sleep_for (std::chrono::seconds(10)); // wait for 10 seconds
|
std::this_thread::sleep_for (std::chrono::seconds(10)); // wait for 10 seconds
|
||||||
leaseSet = i2p::data::netdb.FindLeaseSet (destination);
|
leaseSet = i2p::data::netdb.FindLeaseSet (destination);
|
||||||
if (!leaseSet || !leaseSet->HasNonExpiredLeases ()) // still no LeaseSet
|
if (!leaseSet || !leaseSet->HasNonExpiredLeases ()) // still no LeaseSet
|
||||||
|
@ -170,7 +170,7 @@ namespace stream
|
|||||||
}
|
}
|
||||||
if (m_DestinationIdentHash)
|
if (m_DestinationIdentHash)
|
||||||
{
|
{
|
||||||
i2p::data::netdb.Subscribe (*m_DestinationIdentHash);
|
i2p::data::netdb.Subscribe (*m_DestinationIdentHash, GetSharedLocalDestination ()->GetTunnelPool ());
|
||||||
m_RemoteLeaseSet = i2p::data::netdb.FindLeaseSet (*m_DestinationIdentHash);
|
m_RemoteLeaseSet = i2p::data::netdb.FindLeaseSet (*m_DestinationIdentHash);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -208,7 +208,7 @@ namespace stream
|
|||||||
if (identHash)
|
if (identHash)
|
||||||
{
|
{
|
||||||
m_DestinationIdentHash = new i2p::data::IdentHash (*identHash);
|
m_DestinationIdentHash = new i2p::data::IdentHash (*identHash);
|
||||||
i2p::data::netdb.Subscribe (*m_DestinationIdentHash);
|
i2p::data::netdb.Subscribe (*m_DestinationIdentHash, GetSharedLocalDestination ()->GetTunnelPool ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
NetDb.cpp
10
NetDb.cpp
@ -368,7 +368,7 @@ namespace data
|
|||||||
i2p::tunnel::InboundTunnel * inbound = pool ? pool->GetNextInboundTunnel () :i2p::tunnel::tunnels.GetNextInboundTunnel ();
|
i2p::tunnel::InboundTunnel * inbound = pool ? pool->GetNextInboundTunnel () :i2p::tunnel::tunnels.GetNextInboundTunnel ();
|
||||||
if (inbound)
|
if (inbound)
|
||||||
{
|
{
|
||||||
RequestedDestination * dest = CreateRequestedDestination (destination, isLeaseSet, pool);
|
RequestedDestination * dest = CreateRequestedDestination (destination, true, false, pool);
|
||||||
std::vector<i2p::tunnel::TunnelMessageBlock> msgs;
|
std::vector<i2p::tunnel::TunnelMessageBlock> msgs;
|
||||||
// request 3 closests floodfills
|
// request 3 closests floodfills
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
@ -401,7 +401,7 @@ namespace data
|
|||||||
}
|
}
|
||||||
else // RouterInfo is requested directly
|
else // RouterInfo is requested directly
|
||||||
{
|
{
|
||||||
RequestedDestination * dest = CreateRequestedDestination (destination, false, pool);
|
RequestedDestination * dest = CreateRequestedDestination (destination, false, false, pool);
|
||||||
auto floodfill = GetClosestFloodfill (destination, dest->GetExcludedPeers ());
|
auto floodfill = GetClosestFloodfill (destination, dest->GetExcludedPeers ());
|
||||||
if (floodfill)
|
if (floodfill)
|
||||||
i2p::transports.SendMessage (floodfill->GetIdentHash (), dest->CreateRequestMessage (floodfill->GetIdentHash ()));
|
i2p::transports.SendMessage (floodfill->GetIdentHash (), dest->CreateRequestMessage (floodfill->GetIdentHash ()));
|
||||||
@ -874,7 +874,7 @@ namespace data
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
leaseSet->SetUnsolicited (false);
|
leaseSet->SetUnsolicited (false);
|
||||||
m_Subscriptions.insert (ident);
|
m_Subscriptions[ident] = pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetDb::Unsubscribe (const IdentHash& ident)
|
void NetDb::Unsubscribe (const IdentHash& ident)
|
||||||
@ -886,11 +886,11 @@ namespace data
|
|||||||
{
|
{
|
||||||
for (auto it : m_Subscriptions)
|
for (auto it : m_Subscriptions)
|
||||||
{
|
{
|
||||||
LeaseSet * leaseSet = FindLeaseSet (it);
|
LeaseSet * leaseSet = FindLeaseSet (it.first);
|
||||||
if (!leaseSet || leaseSet->HasExpiredLeases ())
|
if (!leaseSet || leaseSet->HasExpiredLeases ())
|
||||||
{
|
{
|
||||||
LogPrint ("LeaseSet re-requested");
|
LogPrint ("LeaseSet re-requested");
|
||||||
RequestDestination (it, true);
|
RequestDestination (it.first, true, it.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
NetDb.h
2
NetDb.h
@ -118,7 +118,7 @@ namespace data
|
|||||||
std::vector<RouterInfo *> m_Floodfills;
|
std::vector<RouterInfo *> m_Floodfills;
|
||||||
std::mutex m_RequestedDestinationsMutex;
|
std::mutex m_RequestedDestinationsMutex;
|
||||||
std::map<IdentHash, RequestedDestination *> m_RequestedDestinations;
|
std::map<IdentHash, RequestedDestination *> m_RequestedDestinations;
|
||||||
std::set<IdentHash> m_Subscriptions;
|
std::map<IdentHash, i2p::tunnel::TunnelPool *> m_Subscriptions;
|
||||||
|
|
||||||
bool m_IsRunning;
|
bool m_IsRunning;
|
||||||
int m_ReseedRetries;
|
int m_ReseedRetries;
|
||||||
|
Loading…
Reference in New Issue
Block a user