MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / LookupCommandHandler

Method LookupCommandHandler

libi2pd_client/BOB.cpp:741–785  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 13

LogPrintFunction · 0.85
IsIdentHashMethod · 0.80
ToBase64Method · 0.80
SendReplyOKMethod · 0.80
SendReplyErrorMethod · 0.80
GetAddressMethod · 0.45
IsRunningMethod · 0.45
GetLocalDestinationMethod · 0.45
FindLeaseSetMethod · 0.45
GetIdentityMethod · 0.45

Tested by

no test coverage detected