mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-08 18:47:52 +00:00
address lookup
This commit is contained in:
parent
26a6c9e932
commit
aa6bc8042a
48
I2CP.cpp
48
I2CP.cpp
@ -13,6 +13,7 @@
|
|||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Timestamp.h"
|
#include "Timestamp.h"
|
||||||
#include "LeaseSet.h"
|
#include "LeaseSet.h"
|
||||||
|
#include "ClientContext.h"
|
||||||
#include "I2CP.h"
|
#include "I2CP.h"
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
@ -390,31 +391,46 @@ namespace client
|
|||||||
{
|
{
|
||||||
uint32_t requestID = bufbe32toh (buf + 2);
|
uint32_t requestID = bufbe32toh (buf + 2);
|
||||||
//uint32_t timeout = bufbe32toh (buf + 6);
|
//uint32_t timeout = bufbe32toh (buf + 6);
|
||||||
if (!buf[10]) // request type = 0 (hash)
|
i2p::data::IdentHash ident;
|
||||||
|
switch (buf[10])
|
||||||
{
|
{
|
||||||
if (m_Destination)
|
case 0: // hash
|
||||||
|
ident = i2p::data::IdentHash (buf + 11);
|
||||||
|
break;
|
||||||
|
case 1: // address
|
||||||
{
|
{
|
||||||
auto ls = m_Destination->FindLeaseSet (buf + 11);
|
auto name = ExtractString (buf + 11, len - 11);
|
||||||
if (ls)
|
if (!i2p::client::context.GetAddressBook ().GetIdentHash (name, ident))
|
||||||
SendHostReplyMessage (requestID, ls->GetIdentity ());
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
auto s = shared_from_this ();
|
LogPrint (eLogError, "I2CP: address ", name, " not found");
|
||||||
m_Destination->RequestDestination (buf + 11,
|
SendHostReplyMessage (requestID, nullptr);
|
||||||
[s, requestID](std::shared_ptr<i2p::data::LeaseSet> leaseSet)
|
return;
|
||||||
{
|
|
||||||
s->SendHostReplyMessage (requestID, leaseSet ? leaseSet->GetIdentity () : nullptr);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
default:
|
||||||
|
LogPrint (eLogError, "I2CP: request type ", (int)buf[10], " is not supported");
|
||||||
SendHostReplyMessage (requestID, nullptr);
|
SendHostReplyMessage (requestID, nullptr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_Destination)
|
||||||
|
{
|
||||||
|
auto ls = m_Destination->FindLeaseSet (ident);
|
||||||
|
if (ls)
|
||||||
|
SendHostReplyMessage (requestID, ls->GetIdentity ());
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto s = shared_from_this ();
|
||||||
|
m_Destination->RequestDestination (ident,
|
||||||
|
[s, requestID](std::shared_ptr<i2p::data::LeaseSet> leaseSet)
|
||||||
|
{
|
||||||
|
s->SendHostReplyMessage (requestID, leaseSet ? leaseSet->GetIdentity () : nullptr);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
LogPrint (eLogError, "I2CP: request type ", (int)buf[8], " is not supported");
|
|
||||||
SendHostReplyMessage (requestID, nullptr);
|
SendHostReplyMessage (requestID, nullptr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "I2CP: unexpected sessionID ", sessionID);
|
LogPrint (eLogError, "I2CP: unexpected sessionID ", sessionID);
|
||||||
|
Loading…
Reference in New Issue
Block a user