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.

71 lines
1.7 KiB

11 years ago
#ifndef NETDB_H__
#define NETDB_H__
#include <inttypes.h>
#include <map>
#include <string>
11 years ago
#include <thread>
#include "Queue.h"
#include "I2NPProtocol.h"
11 years ago
#include "RouterInfo.h"
#include "LeaseSet.h"
#include "Tunnel.h"
11 years ago
namespace i2p
{
namespace data
{
class NetDb
{
public:
NetDb ();
~NetDb ();
11 years ago
void Start ();
void Stop ();
11 years ago
void AddRouterInfo (uint8_t * buf, int len);
void AddLeaseSet (uint8_t * buf, int len);
RouterInfo * FindRouter (const IdentHash& ident) const;
LeaseSet * FindLeaseSet (const IdentHash& destination) const;
void RequestDestination (const char * b32, const uint8_t * router); // in base32
11 years ago
void RequestDestination (const uint8_t * destination, const uint8_t * router);
void RequestDestination (const IdentHash& destination);
void HandleDatabaseStoreMsg (uint8_t * buf, size_t len);
void HandleDatabaseSearchReplyMsg (I2NPMessage * msg);
11 years ago
11 years ago
const RouterInfo * GetRandomNTCPRouter (bool floodfillOnly = false) const;
const RouterInfo * GetRandomRouter () const;
void PostI2NPMsg (I2NPMessage * msg);
11 years ago
private:
void Load (const char * directory);
void SaveUpdated (const char * directory);
11 years ago
void Run (); // exploratory thread
void Explore ();
11 years ago
private:
std::map<IdentHash, LeaseSet *> m_LeaseSets;
std::map<IdentHash, RouterInfo *> m_RouterInfos;
11 years ago
bool m_IsRunning;
std::thread * m_Thread;
uint8_t m_Exploratory[32];
const RouterInfo * m_LastFloodfill;
i2p::tunnel::OutboundTunnel * m_LastOutboundTunnel;
i2p::tunnel::InboundTunnel * m_LastInboundTunnel;
i2p::util::Queue<I2NPMessage> m_Queue; // of I2NPDatabaseStoreMsg
11 years ago
};
extern NetDb netdb;
}
}
#endif