mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-14 12:57:52 +00:00
publish number of leasets and routers for floodfill
This commit is contained in:
parent
647bb501d1
commit
0b754ec65d
@ -173,7 +173,8 @@ namespace data
|
|||||||
}
|
}
|
||||||
lastSave = ts;
|
lastSave = ts;
|
||||||
}
|
}
|
||||||
if (ts - lastPublish >= 2400) // publish every 40 minutes
|
if (i2p::context.GetLastUpdateTime () > lastPublish || // our router has been updated
|
||||||
|
ts - lastPublish >= 2400) // or publish every 40 minutes
|
||||||
{
|
{
|
||||||
Publish ();
|
Publish ();
|
||||||
lastPublish = ts;
|
lastPublish = ts;
|
||||||
|
2
NetDb.h
2
NetDb.h
@ -90,7 +90,7 @@ namespace data
|
|||||||
|
|
||||||
void Reseed ();
|
void Reseed ();
|
||||||
|
|
||||||
// for web interface
|
// for web interface and stats
|
||||||
int GetNumRouters () const { return m_RouterInfos.size (); };
|
int GetNumRouters () const { return m_RouterInfos.size (); };
|
||||||
int GetNumFloodfills () const { return m_Floodfills.size (); };
|
int GetNumFloodfills () const { return m_Floodfills.size (); };
|
||||||
int GetNumLeaseSets () const { return m_LeaseSets.size (); };
|
int GetNumLeaseSets () const { return m_LeaseSets.size (); };
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <cryptopp/dh.h>
|
#include <cryptopp/dh.h>
|
||||||
#include <cryptopp/dsa.h>
|
#include <cryptopp/dsa.h>
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
#include "CryptoConst.h"
|
#include "CryptoConst.h"
|
||||||
#include "RouterContext.h"
|
#include "RouterContext.h"
|
||||||
#include "Timestamp.h"
|
#include "Timestamp.h"
|
||||||
#include "I2NPProtocol.h"
|
#include "I2NPProtocol.h"
|
||||||
|
#include "NetDb.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
@ -54,6 +56,12 @@ namespace i2p
|
|||||||
|
|
||||||
void RouterContext::UpdateRouterInfo ()
|
void RouterContext::UpdateRouterInfo ()
|
||||||
{
|
{
|
||||||
|
if (m_IsFloodfill)
|
||||||
|
{
|
||||||
|
// update routers and leasesets
|
||||||
|
m_RouterInfo.SetProperty (ROUTER_INFO_PROPERTY_LEASESETS, boost::lexical_cast<std::string>(i2p::data::netdb.GetNumLeaseSets ()));
|
||||||
|
m_RouterInfo.SetProperty (ROUTER_INFO_PROPERTY_ROUTERS, boost::lexical_cast<std::string>(i2p::data::netdb.GetNumRouters ()));
|
||||||
|
}
|
||||||
m_RouterInfo.CreateBuffer (m_Keys);
|
m_RouterInfo.CreateBuffer (m_Keys);
|
||||||
m_RouterInfo.SaveToFile (i2p::util::filesystem::GetFullPath (ROUTER_INFO));
|
m_RouterInfo.SaveToFile (i2p::util::filesystem::GetFullPath (ROUTER_INFO));
|
||||||
m_LastUpdateTime = i2p::util::GetSecondsSinceEpoch ();
|
m_LastUpdateTime = i2p::util::GetSecondsSinceEpoch ();
|
||||||
@ -115,7 +123,12 @@ namespace i2p
|
|||||||
if (floodfill)
|
if (floodfill)
|
||||||
m_RouterInfo.SetCaps (m_RouterInfo.GetCaps () | i2p::data::RouterInfo::eFloodfill);
|
m_RouterInfo.SetCaps (m_RouterInfo.GetCaps () | i2p::data::RouterInfo::eFloodfill);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
m_RouterInfo.SetCaps (m_RouterInfo.GetCaps () & ~i2p::data::RouterInfo::eFloodfill);
|
m_RouterInfo.SetCaps (m_RouterInfo.GetCaps () & ~i2p::data::RouterInfo::eFloodfill);
|
||||||
|
// we don't publish number of routers and leaseset for non-floodfill
|
||||||
|
m_RouterInfo.DeleteProperty (ROUTER_INFO_PROPERTY_LEASESETS);
|
||||||
|
m_RouterInfo.DeleteProperty (ROUTER_INFO_PROPERTY_ROUTERS);
|
||||||
|
}
|
||||||
UpdateRouterInfo ();
|
UpdateRouterInfo ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,9 @@ namespace i2p
|
|||||||
const char ROUTER_KEYS[] = "router.keys";
|
const char ROUTER_KEYS[] = "router.keys";
|
||||||
const int ROUTER_INFO_UPDATE_INTERVAL = 1800; // 30 minutes
|
const int ROUTER_INFO_UPDATE_INTERVAL = 1800; // 30 minutes
|
||||||
|
|
||||||
|
const char ROUTER_INFO_PROPERTY_LEASESETS[] = "netdb.knownLeaseSets";
|
||||||
|
const char ROUTER_INFO_PROPERTY_ROUTERS[] = "netdb.knownRouters";
|
||||||
|
|
||||||
enum RouterStatus
|
enum RouterStatus
|
||||||
{
|
{
|
||||||
eRouterStatusOK = 0,
|
eRouterStatusOK = 0,
|
||||||
@ -40,6 +43,7 @@ namespace i2p
|
|||||||
CryptoPP::RandomNumberGenerator& GetRandomNumberGenerator () { return m_Rnd; };
|
CryptoPP::RandomNumberGenerator& GetRandomNumberGenerator () { return m_Rnd; };
|
||||||
uint32_t GetUptime () const;
|
uint32_t GetUptime () const;
|
||||||
uint32_t GetStartupTime () const { return m_StartupTime; };
|
uint32_t GetStartupTime () const { return m_StartupTime; };
|
||||||
|
uint64_t GetLastUpdateTime () const { return m_LastUpdateTime; };
|
||||||
RouterStatus GetStatus () const { return m_Status; };
|
RouterStatus GetStatus () const { return m_Status; };
|
||||||
void SetStatus (RouterStatus status) { m_Status = status; };
|
void SetStatus (RouterStatus status) { m_Status = status; };
|
||||||
|
|
||||||
|
@ -548,11 +548,16 @@ namespace data
|
|||||||
ExtractCaps (caps);
|
ExtractCaps (caps);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouterInfo::SetProperty (const char * key, const char * value)
|
void RouterInfo::SetProperty (const std::string& key, const std::string& value)
|
||||||
{
|
{
|
||||||
m_Properties[key] = value;
|
m_Properties[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RouterInfo::DeleteProperty (const std::string& key)
|
||||||
|
{
|
||||||
|
m_Properties.erase (key);
|
||||||
|
}
|
||||||
|
|
||||||
bool RouterInfo::IsFloodfill () const
|
bool RouterInfo::IsFloodfill () const
|
||||||
{
|
{
|
||||||
return m_Caps & Caps::eFloodfill;
|
return m_Caps & Caps::eFloodfill;
|
||||||
|
@ -105,7 +105,8 @@ namespace data
|
|||||||
void AddSSUAddress (const char * host, int port, const uint8_t * key, int mtu = 0);
|
void AddSSUAddress (const char * host, int port, const uint8_t * key, int mtu = 0);
|
||||||
bool AddIntroducer (const Address * address, uint32_t tag);
|
bool AddIntroducer (const Address * address, uint32_t tag);
|
||||||
bool RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
|
bool RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
|
||||||
void SetProperty (const char * key, const char * value); // called from RouterContext only
|
void SetProperty (const std::string& key, const std::string& value); // called from RouterContext only
|
||||||
|
void DeleteProperty (const std::string& key); // called from RouterContext only
|
||||||
void ClearProperties () { m_Properties.clear (); };
|
void ClearProperties () { m_Properties.clear (); };
|
||||||
bool IsFloodfill () const;
|
bool IsFloodfill () const;
|
||||||
bool IsNTCP (bool v4only = true) const;
|
bool IsNTCP (bool v4only = true) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user