mirror of https://github.com/PurpleI2P/i2pd.git
I2P: End-to-End encrypted and anonymous Internet
https://i2pd.website/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.0 KiB
75 lines
2.0 KiB
11 years ago
|
#ifndef LEASE_SET_H__
|
||
|
#define LEASE_SET_H__
|
||
|
|
||
|
#include <inttypes.h>
|
||
11 years ago
|
#include <string.h>
|
||
11 years ago
|
#include <vector>
|
||
11 years ago
|
#include "Identity.h"
|
||
11 years ago
|
|
||
|
namespace i2p
|
||
|
{
|
||
10 years ago
|
|
||
|
namespace tunnel
|
||
|
{
|
||
10 years ago
|
class TunnelPool;
|
||
10 years ago
|
}
|
||
|
|
||
11 years ago
|
namespace data
|
||
10 years ago
|
{
|
||
|
struct Lease
|
||
|
{
|
||
|
IdentHash tunnelGateway;
|
||
|
uint32_t tunnelID;
|
||
|
uint64_t endDate;
|
||
11 years ago
|
|
||
10 years ago
|
bool operator< (const Lease& other) const
|
||
|
{
|
||
|
if (endDate != other.endDate)
|
||
|
return endDate > other.endDate;
|
||
|
else
|
||
|
return tunnelID < other.tunnelID;
|
||
|
}
|
||
|
};
|
||
11 years ago
|
|
||
10 years ago
|
const int MAX_LS_BUFFER_SIZE = 3072;
|
||
|
class LeaseSet: public RoutingDestination
|
||
|
{
|
||
|
public:
|
||
11 years ago
|
|
||
10 years ago
|
LeaseSet (const uint8_t * buf, size_t len);
|
||
|
LeaseSet (const i2p::tunnel::TunnelPool& pool);
|
||
|
~LeaseSet () { delete[] m_Buffer; };
|
||
|
void Update (const uint8_t * buf, size_t len);
|
||
|
const IdentityEx& GetIdentity () const { return m_Identity; };
|
||
10 years ago
|
|
||
10 years ago
|
const uint8_t * GetBuffer () const { return m_Buffer; };
|
||
|
size_t GetBufferLen () const { return m_BufferLen; };
|
||
|
bool IsValid () const { return m_IsValid; };
|
||
10 years ago
|
|
||
10 years ago
|
// implements RoutingDestination
|
||
|
const IdentHash& GetIdentHash () const { return m_Identity.GetIdentHash (); };
|
||
|
const std::vector<Lease>& GetLeases () const { return m_Leases; };
|
||
|
const std::vector<Lease> GetNonExpiredLeases (bool withThreshold = true) const;
|
||
|
bool HasExpiredLeases () const;
|
||
|
bool HasNonExpiredLeases () const;
|
||
|
const uint8_t * GetEncryptionPublicKey () const { return m_EncryptionKey; };
|
||
|
bool IsDestination () const { return true; };
|
||
11 years ago
|
|
||
10 years ago
|
private:
|
||
11 years ago
|
|
||
10 years ago
|
void ReadFromBuffer ();
|
||
|
|
||
|
private:
|
||
11 years ago
|
|
||
10 years ago
|
bool m_IsValid;
|
||
|
std::vector<Lease> m_Leases;
|
||
|
IdentityEx m_Identity;
|
||
|
uint8_t m_EncryptionKey[256];
|
||
|
uint8_t * m_Buffer;
|
||
|
size_t m_BufferLen;
|
||
|
};
|
||
|
}
|
||
|
}
|
||
11 years ago
|
|
||
|
#endif
|