| 602 | } |
| 603 | |
| 604 | std::shared_ptr<i2p::garlic::GarlicRoutingPath> DatagramSession::GetSharedRoutingPath () |
| 605 | { |
| 606 | if (!m_RemoteLeaseSet || m_RemoteLeaseSet->IsExpired ()) |
| 607 | { |
| 608 | m_RemoteLeaseSet = m_LocalDestination->FindLeaseSet(m_RemoteIdent); |
| 609 | if (!m_RemoteLeaseSet) |
| 610 | { |
| 611 | if(!m_RequestingLS) |
| 612 | { |
| 613 | m_RequestingLS = true; |
| 614 | m_LocalDestination->RequestDestination(m_RemoteIdent, std::bind(&DatagramSession::HandleLeaseSetUpdated, this, std::placeholders::_1)); |
| 615 | } |
| 616 | return nullptr; |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | if (!m_RoutingSession || m_RoutingSession->IsTerminated () || !m_RoutingSession->IsReadyToSend ()) |
| 621 | { |
| 622 | bool found = false; |
| 623 | if (!m_PendingRoutingSessions.empty ()) |
| 624 | { |
| 625 | std::vector<std::weak_ptr<i2p::garlic::GarlicRoutingSession> > tmp; |
| 626 | for (auto& it: m_PendingRoutingSessions) |
| 627 | { |
| 628 | auto s = it.lock (); |
| 629 | if (s) |
| 630 | { |
| 631 | if (s->GetOwner () && s->IsReadyToSend ()) // found established session |
| 632 | { |
| 633 | m_RoutingSession = s; |
| 634 | tmp.clear (); |
| 635 | found = true; |
| 636 | break; |
| 637 | } |
| 638 | tmp.push_back (s); |
| 639 | } |
| 640 | } |
| 641 | m_PendingRoutingSessions.swap (tmp); |
| 642 | } |
| 643 | if (!found) |
| 644 | { |
| 645 | m_RoutingSession = m_LocalDestination->GetRoutingSession(m_RemoteLeaseSet, true); |
| 646 | if (m_RoutingSession) |
| 647 | { |
| 648 | m_RoutingSession->SetAckRequestInterval (DATAGRAM_SESSION_ACK_REQUEST_INTERVAL); |
| 649 | if (!m_RoutingSession->GetOwner () || !m_RoutingSession->IsReadyToSend ()) |
| 650 | m_PendingRoutingSessions.push_back (m_RoutingSession); |
| 651 | } |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | auto path = m_RoutingSession->GetSharedRoutingPath(); |
| 656 | if (path && m_RoutingSession->IsRatchets () && m_RoutingSession->CleanupUnconfirmedTags ()) |
| 657 | { |
| 658 | LogPrint (eLogDebug, "Datagram: path reset"); |
| 659 | m_RoutingSession->SetSharedRoutingPath (nullptr); |
| 660 | path = nullptr; |
| 661 | } |
no test coverage detected