|
|
@ -617,7 +617,9 @@ namespace client |
|
|
|
SendNamingLookupReply (dest->GetIdentity ()); |
|
|
|
SendNamingLookupReply (dest->GetIdentity ()); |
|
|
|
else if ((identity = context.GetAddressBook ().GetFullAddress (name)) != nullptr) |
|
|
|
else if ((identity = context.GetAddressBook ().GetFullAddress (name)) != nullptr) |
|
|
|
SendNamingLookupReply (identity); |
|
|
|
SendNamingLookupReply (identity); |
|
|
|
else if ((addr = context.GetAddressBook ().GetAddress (name)) && addr->IsIdentHash ()) |
|
|
|
else if ((addr = context.GetAddressBook ().GetAddress (name))) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (addr->IsIdentHash ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto leaseSet = dest->FindLeaseSet (addr->identHash); |
|
|
|
auto leaseSet = dest->FindLeaseSet (addr->identHash); |
|
|
|
if (leaseSet) |
|
|
|
if (leaseSet) |
|
|
@ -625,7 +627,12 @@ namespace client |
|
|
|
else |
|
|
|
else |
|
|
|
dest->RequestDestination (addr->identHash, |
|
|
|
dest->RequestDestination (addr->identHash, |
|
|
|
std::bind (&SAMSocket::HandleNamingLookupLeaseSetRequestComplete, |
|
|
|
std::bind (&SAMSocket::HandleNamingLookupLeaseSetRequestComplete, |
|
|
|
shared_from_this (), std::placeholders::_1, addr->identHash)); |
|
|
|
shared_from_this (), std::placeholders::_1, name)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
dest->RequestDestinationWithEncryptedLeaseSet (addr->blindedPublicKey, |
|
|
|
|
|
|
|
std::bind (&SAMSocket::HandleNamingLookupLeaseSetRequestComplete, |
|
|
|
|
|
|
|
shared_from_this (), std::placeholders::_1, name)); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
@ -650,7 +657,7 @@ namespace client |
|
|
|
SendMessageReply (m_Buffer, len, true); |
|
|
|
SendMessageReply (m_Buffer, len, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SAMSocket::HandleNamingLookupLeaseSetRequestComplete (std::shared_ptr<i2p::data::LeaseSet> leaseSet, i2p::data::IdentHash ident) |
|
|
|
void SAMSocket::HandleNamingLookupLeaseSetRequestComplete (std::shared_ptr<i2p::data::LeaseSet> leaseSet, std::string name) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (leaseSet) |
|
|
|
if (leaseSet) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -659,13 +666,11 @@ namespace client |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogError, "SAM: naming lookup failed. LeaseSet for ", ident.ToBase32 (), " not found"); |
|
|
|
LogPrint (eLogError, "SAM: naming lookup failed. LeaseSet for ", name, " not found"); |
|
|
|
#ifdef _MSC_VER |
|
|
|
#ifdef _MSC_VER |
|
|
|
size_t len = sprintf_s (m_Buffer, SAM_SOCKET_BUFFER_SIZE, SAM_NAMING_REPLY_INVALID_KEY, |
|
|
|
size_t len = sprintf_s (m_Buffer, SAM_SOCKET_BUFFER_SIZE, SAM_NAMING_REPLY_INVALID_KEY, name.c_str()); |
|
|
|
context.GetAddressBook ().ToAddress (ident).c_str()); |
|
|
|
|
|
|
|
#else |
|
|
|
#else |
|
|
|
size_t len = snprintf (m_Buffer, SAM_SOCKET_BUFFER_SIZE, SAM_NAMING_REPLY_INVALID_KEY, |
|
|
|
size_t len = snprintf (m_Buffer, SAM_SOCKET_BUFFER_SIZE, SAM_NAMING_REPLY_INVALID_KEY, name.c_str()); |
|
|
|
context.GetAddressBook ().ToAddress (ident).c_str()); |
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
SendMessageReply (m_Buffer, len, false); |
|
|
|
SendMessageReply (m_Buffer, len, false); |
|
|
|
} |
|
|
|
} |
|
|
|