mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
delivery type Destination for garlic cloves
This commit is contained in:
parent
7f92a847c2
commit
01cb5e02e9
12
Garlic.cpp
12
Garlic.cpp
@ -95,8 +95,18 @@ namespace garlic
|
|||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
payload[size] = 1; // 1 clove
|
payload[size] = 1; // 1 clove
|
||||||
size++;
|
size++;
|
||||||
payload[size] = 0;// delivery instructions flag
|
if (m_Destination->IsDestination ())
|
||||||
|
{
|
||||||
|
payload[size] = eGarlicDeliveryTypeDestination << 5;// delivery instructions flag destination
|
||||||
size++;
|
size++;
|
||||||
|
memcpy (payload + size, m_Destination->GetIdentHash (), 32);
|
||||||
|
size += 32;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
payload[size] = 0;// delivery instructions flag local
|
||||||
|
size++;
|
||||||
|
}
|
||||||
memcpy (payload + size, msg->GetBuffer (), msg->GetLength ());
|
memcpy (payload + size, msg->GetBuffer (), msg->GetLength ());
|
||||||
size += msg->GetLength ();
|
size += msg->GetLength ();
|
||||||
*(uint32_t *)(payload + size) = htobe32 (m_Rnd.GenerateWord32 ()); // CloveID
|
*(uint32_t *)(payload + size) = htobe32 (m_Rnd.GenerateWord32 ()); // CloveID
|
||||||
|
@ -22,6 +22,7 @@ namespace data
|
|||||||
public:
|
public:
|
||||||
virtual const uint8_t * GetIdentHash () const = 0;
|
virtual const uint8_t * GetIdentHash () const = 0;
|
||||||
virtual const uint8_t * GetEncryptionPublicKey () const = 0;
|
virtual const uint8_t * GetEncryptionPublicKey () const = 0;
|
||||||
|
virtual bool IsDestination () const = 0; // for garlic
|
||||||
};
|
};
|
||||||
|
|
||||||
class LeaseSet: public RoutingDestination
|
class LeaseSet: public RoutingDestination
|
||||||
@ -33,6 +34,7 @@ namespace data
|
|||||||
// implements RoutingDestination
|
// implements RoutingDestination
|
||||||
const uint8_t * GetIdentHash () const { return m_IdentHash; };
|
const uint8_t * GetIdentHash () const { return m_IdentHash; };
|
||||||
const uint8_t * GetEncryptionPublicKey () const { return m_EncryptionKey; };
|
const uint8_t * GetEncryptionPublicKey () const { return m_EncryptionKey; };
|
||||||
|
bool IsDestination () const { return true; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -126,6 +126,8 @@ namespace data
|
|||||||
CryptoPP::SHA256().CalculateDigest(m_IdentHash, (uint8_t *)&m_RouterIdentity, sizeof (m_RouterIdentity));
|
CryptoPP::SHA256().CalculateDigest(m_IdentHash, (uint8_t *)&m_RouterIdentity, sizeof (m_RouterIdentity));
|
||||||
size_t l = i2p::data::ByteStreamToBase64 (m_IdentHash, 32, m_IdentHashBase64, 48);
|
size_t l = i2p::data::ByteStreamToBase64 (m_IdentHash, 32, m_IdentHashBase64, 48);
|
||||||
m_IdentHashBase64[l] = 0;
|
m_IdentHashBase64[l] = 0;
|
||||||
|
memcpy (m_IdentHashAbbreviation, m_IdentHashBase64, 4);
|
||||||
|
m_IdentHashAbbreviation[4] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouterInfo::WriteToStream (std::ostream& s)
|
void RouterInfo::WriteToStream (std::ostream& s)
|
||||||
|
@ -52,6 +52,7 @@ namespace data
|
|||||||
const RouterIdentity& GetRouterIdentity () const { return m_RouterIdentity; };
|
const RouterIdentity& GetRouterIdentity () const { return m_RouterIdentity; };
|
||||||
void SetRouterIdentity (const RouterIdentity& identity);
|
void SetRouterIdentity (const RouterIdentity& identity);
|
||||||
const char * GetIdentHashBase64 () const { return m_IdentHashBase64; };
|
const char * GetIdentHashBase64 () const { return m_IdentHashBase64; };
|
||||||
|
const char * GetIdentHashAbbreviation () const { return m_IdentHashAbbreviation; };
|
||||||
const std::vector<Address>& GetAddresses () const { return m_Addresses; };
|
const std::vector<Address>& GetAddresses () const { return m_Addresses; };
|
||||||
Address * GetNTCPAddress ();
|
Address * GetNTCPAddress ();
|
||||||
|
|
||||||
@ -71,6 +72,7 @@ namespace data
|
|||||||
// implements RoutingDestination
|
// implements RoutingDestination
|
||||||
const uint8_t * GetIdentHash () const { return m_IdentHash; };
|
const uint8_t * GetIdentHash () const { return m_IdentHash; };
|
||||||
const uint8_t * GetEncryptionPublicKey () const { return m_RouterIdentity.publicKey; };
|
const uint8_t * GetEncryptionPublicKey () const { return m_RouterIdentity.publicKey; };
|
||||||
|
bool IsDestination () const { return false; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -85,7 +87,7 @@ namespace data
|
|||||||
|
|
||||||
RouterIdentity m_RouterIdentity;
|
RouterIdentity m_RouterIdentity;
|
||||||
uint8_t m_IdentHash[32];
|
uint8_t m_IdentHash[32];
|
||||||
char m_IdentHashBase64[48];
|
char m_IdentHashBase64[48], m_IdentHashAbbreviation[5];
|
||||||
char m_Buffer[2048];
|
char m_Buffer[2048];
|
||||||
int m_BufferLen;
|
int m_BufferLen;
|
||||||
uint64_t m_Timestamp;
|
uint64_t m_Timestamp;
|
||||||
|
Loading…
Reference in New Issue
Block a user