i2pd/RouterContext.h

50 lines
1.3 KiB
C
Raw Normal View History

2013-10-23 02:45:40 +00:00
#ifndef ROUTER_CONTEXT_H__
#define ROUTER_CONTEXT_H__
#include <inttypes.h>
#include <cryptopp/dsa.h>
#include <cryptopp/osrng.h>
#include "RouterInfo.h"
namespace i2p
{
const char ROUTER_INFO[] = "router.info";
const char ROUTER_KEYS[] = "router.keys";
class RouterContext
{
public:
RouterContext ();
i2p::data::RouterInfo& GetRouterInfo () { return m_RouterInfo; };
2013-12-21 01:22:55 +00:00
const uint8_t * GetPrivateKey () const { return m_Keys.privateKey; };
const uint8_t * GetSigningPrivateKey () const { return m_Keys.signingPrivateKey; };
const i2p::data::Identity& GetRouterIdentity () const { return m_RouterInfo.GetRouterIdentity (); };
2013-10-23 02:45:40 +00:00
CryptoPP::RandomNumberGenerator& GetRandomNumberGenerator () { return m_Rnd; };
void Sign (uint8_t * buf, int len, uint8_t * signature);
2013-12-10 13:10:49 +00:00
void OverrideNTCPAddress (const char * host, int port); // temporary
2014-02-09 02:06:40 +00:00
void UpdateAddress (const char * host); // called from SSU
2013-10-23 02:45:40 +00:00
private:
void CreateNewRouter ();
2014-02-23 16:48:09 +00:00
void UpdateRouterInfo ();
2013-10-23 02:45:40 +00:00
bool Load ();
2014-02-23 16:48:09 +00:00
void Save (bool infoOnly = false);
2013-10-23 02:45:40 +00:00
private:
i2p::data::RouterInfo m_RouterInfo;
2013-12-21 01:22:55 +00:00
i2p::data::Keys m_Keys;
2013-10-23 02:45:40 +00:00
CryptoPP::DSA::PrivateKey m_SigningPrivateKey;
CryptoPP::AutoSeededRandomPool m_Rnd;
};
extern RouterContext context;
}
#endif