mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
reuse tunnel pair for LS request
This commit is contained in:
parent
bb33760e87
commit
190e26276a
|
@ -654,13 +654,14 @@ namespace client
|
||||||
bool ClientDestination::SendLeaseSetRequest (const i2p::data::IdentHash& dest,
|
bool ClientDestination::SendLeaseSetRequest (const i2p::data::IdentHash& dest,
|
||||||
std::shared_ptr<const i2p::data::RouterInfo> nextFloodfill, std::shared_ptr<LeaseSetRequest> request)
|
std::shared_ptr<const i2p::data::RouterInfo> nextFloodfill, std::shared_ptr<LeaseSetRequest> request)
|
||||||
{
|
{
|
||||||
auto replyTunnel = m_Pool->GetNextInboundTunnel ();
|
if (!request->replyTunnel || !request->replyTunnel->IsEstablished ())
|
||||||
if (!replyTunnel) LogPrint (eLogError, "Destination: Can't send LeaseSet request, no inbound tunnels found");
|
request->replyTunnel = m_Pool->GetNextInboundTunnel ();
|
||||||
|
if (!request->replyTunnel) LogPrint (eLogError, "Destination: Can't send LeaseSet request, no inbound tunnels found");
|
||||||
auto outboundTunnel = m_Pool->GetNextOutboundTunnel ();
|
if (!request->outboundTunnel || !request->outboundTunnel->IsEstablished ())
|
||||||
if (!outboundTunnel) LogPrint (eLogError, "Destination: Can't send LeaseSet request, no outbound tunnels found");
|
request->outboundTunnel = m_Pool->GetNextOutboundTunnel ();
|
||||||
|
if (!request->outboundTunnel) LogPrint (eLogError, "Destination: Can't send LeaseSet request, no outbound tunnels found");
|
||||||
|
|
||||||
if (replyTunnel && outboundTunnel)
|
if (request->replyTunnel && request->outboundTunnel)
|
||||||
{
|
{
|
||||||
request->excluded.insert (nextFloodfill->GetIdentHash ());
|
request->excluded.insert (nextFloodfill->GetIdentHash ());
|
||||||
request->requestTime = i2p::util::GetSecondsSinceEpoch ();
|
request->requestTime = i2p::util::GetSecondsSinceEpoch ();
|
||||||
|
@ -673,8 +674,8 @@ namespace client
|
||||||
|
|
||||||
auto msg = WrapMessage (nextFloodfill,
|
auto msg = WrapMessage (nextFloodfill,
|
||||||
CreateLeaseSetDatabaseLookupMsg (dest, request->excluded,
|
CreateLeaseSetDatabaseLookupMsg (dest, request->excluded,
|
||||||
replyTunnel.get (), replyKey, replyTag));
|
request->replyTunnel, replyKey, replyTag));
|
||||||
outboundTunnel->SendTunnelDataMsg (
|
request->outboundTunnel->SendTunnelDataMsg (
|
||||||
{
|
{
|
||||||
i2p::tunnel::TunnelMessageBlock
|
i2p::tunnel::TunnelMessageBlock
|
||||||
{
|
{
|
||||||
|
@ -704,7 +705,12 @@ namespace client
|
||||||
{
|
{
|
||||||
auto floodfill = i2p::data::netdb.GetClosestFloodfill (dest, it->second->excluded);
|
auto floodfill = i2p::data::netdb.GetClosestFloodfill (dest, it->second->excluded);
|
||||||
if (floodfill)
|
if (floodfill)
|
||||||
done = !SendLeaseSetRequest (dest, floodfill, it->second);
|
{
|
||||||
|
// reset tunnels, because one them might fail
|
||||||
|
it->second->outboundTunnel = nullptr;
|
||||||
|
it->second->replyTunnel = nullptr;
|
||||||
|
done = !SendLeaseSetRequest (dest, floodfill, it->second);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,8 @@ namespace client
|
||||||
uint64_t requestTime;
|
uint64_t requestTime;
|
||||||
boost::asio::deadline_timer requestTimeoutTimer;
|
boost::asio::deadline_timer requestTimeoutTimer;
|
||||||
RequestComplete requestComplete;
|
RequestComplete requestComplete;
|
||||||
|
std::shared_ptr<i2p::tunnel::OutboundTunnel> outboundTunnel;
|
||||||
|
std::shared_ptr<i2p::tunnel::InboundTunnel> replyTunnel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ namespace i2p
|
||||||
|
|
||||||
std::shared_ptr<I2NPMessage> CreateLeaseSetDatabaseLookupMsg (const i2p::data::IdentHash& dest,
|
std::shared_ptr<I2NPMessage> CreateLeaseSetDatabaseLookupMsg (const i2p::data::IdentHash& dest,
|
||||||
const std::set<i2p::data::IdentHash>& excludedFloodfills,
|
const std::set<i2p::data::IdentHash>& excludedFloodfills,
|
||||||
const i2p::tunnel::InboundTunnel * replyTunnel, const uint8_t * replyKey, const uint8_t * replyTag)
|
std::shared_ptr<const i2p::tunnel::InboundTunnel> replyTunnel, const uint8_t * replyKey, const uint8_t * replyTag)
|
||||||
{
|
{
|
||||||
int cnt = excludedFloodfills.size ();
|
int cnt = excludedFloodfills.size ();
|
||||||
auto m = cnt > 0 ? NewI2NPMessage () : NewI2NPShortMessage ();
|
auto m = cnt > 0 ? NewI2NPMessage () : NewI2NPShortMessage ();
|
||||||
|
|
|
@ -222,7 +222,7 @@ namespace tunnel
|
||||||
uint32_t replyTunnelID, bool exploratory = false, std::set<i2p::data::IdentHash> * excludedPeers = nullptr);
|
uint32_t replyTunnelID, bool exploratory = false, std::set<i2p::data::IdentHash> * excludedPeers = nullptr);
|
||||||
std::shared_ptr<I2NPMessage> CreateLeaseSetDatabaseLookupMsg (const i2p::data::IdentHash& dest,
|
std::shared_ptr<I2NPMessage> CreateLeaseSetDatabaseLookupMsg (const i2p::data::IdentHash& dest,
|
||||||
const std::set<i2p::data::IdentHash>& excludedFloodfills,
|
const std::set<i2p::data::IdentHash>& excludedFloodfills,
|
||||||
const i2p::tunnel::InboundTunnel * replyTunnel, const uint8_t * replyKey, const uint8_t * replyTag);
|
std::shared_ptr<const i2p::tunnel::InboundTunnel> replyTunnel, const uint8_t * replyKey, const uint8_t * replyTag);
|
||||||
std::shared_ptr<I2NPMessage> CreateDatabaseSearchReply (const i2p::data::IdentHash& ident, std::vector<i2p::data::IdentHash> routers);
|
std::shared_ptr<I2NPMessage> CreateDatabaseSearchReply (const i2p::data::IdentHash& ident, std::vector<i2p::data::IdentHash> routers);
|
||||||
|
|
||||||
std::shared_ptr<I2NPMessage> CreateDatabaseStoreMsg (std::shared_ptr<const i2p::data::RouterInfo> router = nullptr, uint32_t replyToken = 0);
|
std::shared_ptr<I2NPMessage> CreateDatabaseStoreMsg (std::shared_ptr<const i2p::data::RouterInfo> router = nullptr, uint32_t replyToken = 0);
|
||||||
|
|
Loading…
Reference in a new issue