| 739 | } |
| 740 | |
| 741 | void BOBCommandSession::LookupCommandHandler (const char * operand, size_t len) |
| 742 | { |
| 743 | LogPrint (eLogDebug, "BOB: lookup ", operand); |
| 744 | if (*operand) |
| 745 | { |
| 746 | auto addr = context.GetAddressBook ().GetAddress (operand); |
| 747 | if (!addr) |
| 748 | { |
| 749 | SendReplyError ("Address Not found"); |
| 750 | return; |
| 751 | } |
| 752 | auto localDestination = (m_CurrentDestination && m_CurrentDestination->IsRunning ()) ? |
| 753 | m_CurrentDestination->GetLocalDestination () : i2p::client::context.GetSharedLocalDestination (); |
| 754 | if (!localDestination) |
| 755 | { |
| 756 | SendReplyError ("No local destination"); |
| 757 | return; |
| 758 | } |
| 759 | if (addr->IsIdentHash ()) |
| 760 | { |
| 761 | // we might have leaseset already |
| 762 | auto leaseSet = localDestination->FindLeaseSet (addr->identHash); |
| 763 | if (leaseSet) |
| 764 | { |
| 765 | SendReplyOK (leaseSet->GetIdentity ()->ToBase64 ()); |
| 766 | return; |
| 767 | } |
| 768 | } |
| 769 | // trying to request |
| 770 | auto s = shared_from_this (); |
| 771 | auto requstCallback = [s](std::shared_ptr<i2p::data::LeaseSet> ls) |
| 772 | { |
| 773 | if (ls) |
| 774 | s->SendReplyOK (ls->GetIdentity ()->ToBase64 ()); |
| 775 | else |
| 776 | s->SendReplyError ("LeaseSet Not found"); |
| 777 | }; |
| 778 | if (addr->IsIdentHash ()) |
| 779 | localDestination->RequestDestination (addr->identHash, requstCallback); |
| 780 | else |
| 781 | localDestination->RequestDestinationWithEncryptedLeaseSet (addr->blindedPublicKey, requstCallback); |
| 782 | } |
| 783 | else |
| 784 | SendReplyError ("empty lookup address"); |
| 785 | } |
| 786 | |
| 787 | void BOBCommandSession::LookupLocalCommandHandler (const char * operand, size_t len) |
| 788 | { |
nothing calls this directly
no test coverage detected