| 806 | } |
| 807 | |
| 808 | void BOBCommandSession::PingCommandHandler (const char * operand, size_t len) |
| 809 | { |
| 810 | LogPrint (eLogDebug, "BOB: ping ", operand); |
| 811 | if (*operand) |
| 812 | { |
| 813 | auto addr = context.GetAddressBook ().GetAddress (operand); |
| 814 | if (!addr) |
| 815 | { |
| 816 | SendReplyError ("Address Not found"); |
| 817 | return; |
| 818 | } |
| 819 | auto localDestination = (m_CurrentDestination && m_CurrentDestination->IsRunning ()) ? |
| 820 | m_CurrentDestination->GetLocalDestination () : i2p::client::context.GetSharedLocalDestination (); |
| 821 | if (!localDestination) |
| 822 | { |
| 823 | SendReplyError ("No local destination"); |
| 824 | return; |
| 825 | } |
| 826 | if (addr->IsIdentHash ()) |
| 827 | { |
| 828 | // we might have leaseset already |
| 829 | auto leaseSet = localDestination->FindLeaseSet (addr->identHash); |
| 830 | if (leaseSet) |
| 831 | { |
| 832 | boost::asio::post (localDestination->GetService (), |
| 833 | std::bind (&BOBCommandSession::SendPing, shared_from_this (), leaseSet)); |
| 834 | return; |
| 835 | } |
| 836 | } |
| 837 | // request LeaseSet |
| 838 | if (addr->IsIdentHash ()) |
| 839 | localDestination->RequestDestination (addr->identHash, |
| 840 | std::bind (&BOBCommandSession::SendPing, shared_from_this (), std::placeholders::_1)); |
| 841 | else |
| 842 | localDestination->RequestDestinationWithEncryptedLeaseSet (addr->blindedPublicKey, |
| 843 | std::bind (&BOBCommandSession::SendPing, shared_from_this (), std::placeholders::_1)); |
| 844 | } |
| 845 | else |
| 846 | SendReplyError ("empty ping address"); |
| 847 | } |
| 848 | |
| 849 | void BOBCommandSession::SendPing (std::shared_ptr<const i2p::data::LeaseSet> ls) |
| 850 | { |
nothing calls this directly
no test coverage detected