mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-24 01:46:36 +02:00
Merge 476ff62015
into 4163542125
This commit is contained in:
commit
e27a0712f9
3 changed files with 17 additions and 3 deletions
|
@ -22,7 +22,9 @@ namespace i2p
|
||||||
{
|
{
|
||||||
namespace data
|
namespace data
|
||||||
{
|
{
|
||||||
typedef Tag<32> IdentHash;
|
const uint8_t IDENTITY_HASH_SIZE = 32;
|
||||||
|
|
||||||
|
typedef Tag<IDENTITY_HASH_SIZE> IdentHash;
|
||||||
inline std::string GetIdentHashAbbreviation (const IdentHash& ident)
|
inline std::string GetIdentHashAbbreviation (const IdentHash& ident)
|
||||||
{
|
{
|
||||||
return ident.ToBase64 ().substr (0, 4);
|
return ident.ToBase64 ().substr (0, 4);
|
||||||
|
|
|
@ -394,6 +394,10 @@ namespace data
|
||||||
size_t LeaseSet2::ReadStandardLS2TypeSpecificPart (const uint8_t * buf, size_t len)
|
size_t LeaseSet2::ReadStandardLS2TypeSpecificPart (const uint8_t * buf, size_t len)
|
||||||
{
|
{
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
|
|
||||||
|
if(offset + 2 > len) // AKA (len < 2)
|
||||||
|
return 0;
|
||||||
|
|
||||||
// properties
|
// properties
|
||||||
uint16_t propertiesLen = bufbe16toh (buf + offset); offset += 2;
|
uint16_t propertiesLen = bufbe16toh (buf + offset); offset += 2;
|
||||||
offset += propertiesLen; // skip for now. TODO: implement properties
|
offset += propertiesLen; // skip for now. TODO: implement properties
|
||||||
|
@ -448,6 +452,10 @@ namespace data
|
||||||
size_t LeaseSet2::ReadMetaLS2TypeSpecificPart (const uint8_t * buf, size_t len)
|
size_t LeaseSet2::ReadMetaLS2TypeSpecificPart (const uint8_t * buf, size_t len)
|
||||||
{
|
{
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
|
|
||||||
|
if(offset + 2 > len) // AKA (len < 2)
|
||||||
|
return 0;
|
||||||
|
|
||||||
// properties
|
// properties
|
||||||
uint16_t propertiesLen = bufbe16toh (buf + offset); offset += 2;
|
uint16_t propertiesLen = bufbe16toh (buf + offset); offset += 2;
|
||||||
offset += propertiesLen; // skip for now. TODO: implement properties
|
offset += propertiesLen; // skip for now. TODO: implement properties
|
||||||
|
|
|
@ -1057,6 +1057,10 @@ namespace data
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// All peers hashs in buffer?
|
||||||
|
if(msg->GetPayloadLength() < (size_t) (33 + num * IDENTITY_HASH_SIZE))
|
||||||
|
return;
|
||||||
|
|
||||||
// try responses
|
// try responses
|
||||||
if (num > NETDB_MAX_NUM_SEARCH_REPLY_PEER_HASHES)
|
if (num > NETDB_MAX_NUM_SEARCH_REPLY_PEER_HASHES)
|
||||||
{
|
{
|
||||||
|
@ -1065,9 +1069,9 @@ namespace data
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < num; i++)
|
for (size_t i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
const uint8_t * router = buf + 33 + i*32;
|
const uint8_t * router = buf + 33 + i*IDENTITY_HASH_SIZE;
|
||||||
char peerHash[48];
|
char peerHash[48];
|
||||||
int l1 = i2p::data::ByteStreamToBase64 (router, 32, peerHash, 48);
|
int l1 = i2p::data::ByteStreamToBase64 (router, IDENTITY_HASH_SIZE, peerHash, 48);
|
||||||
peerHash[l1] = 0;
|
peerHash[l1] = 0;
|
||||||
LogPrint (eLogDebug, "NetDb: ", i, ": ", peerHash);
|
LogPrint (eLogDebug, "NetDb: ", i, ": ", peerHash);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue