Browse Source

show uptime

pull/163/head
orignal 10 years ago
parent
commit
c46a82420d
  1. 6
      HTTPServer.cpp
  2. 8
      RouterContext.cpp
  3. 2
      RouterContext.h

6
HTTPServer.cpp

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#include <boost/bind.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include "base64.h"
#include "Log.h"
#include "Tunnel.h"
@ -646,8 +647,11 @@ namespace util @@ -646,8 +647,11 @@ namespace util
void HTTPConnection::FillContent (std::stringstream& s)
{
s << "<h2>Welcome to the Webconsole!</h2><br><br>";
s << "<b>Uptime:</b> " <<
s << "<b>Data path:</b> " << i2p::util::filesystem::GetDataDir().string() << "<br>" << "<br>";
s << "<b>Our external address:</b>" << "<br>";
s << "<b>Our external address:</b>" << boost::posix_time::to_simple_string (
boost::posix_time::time_duration (boost::posix_time::seconds (
i2p::context.GetUptime ()))) << "<br><br>";
for (auto& address : i2p::context.GetRouterInfo().GetAddresses())
{
switch (address.transportStyle)

8
RouterContext.cpp

@ -14,12 +14,13 @@ namespace i2p @@ -14,12 +14,13 @@ namespace i2p
RouterContext::RouterContext ():
m_LastUpdateTime (0), m_IsUnreachable (false), m_AcceptsTunnels (true),
m_IsFloodfill (false)
m_IsFloodfill (false), m_StartupTime (0)
{
}
void RouterContext::Init ()
{
m_StartupTime = i2p::util::GetSecondsSinceEpoch ();
if (!Load ())
CreateNewRouter ();
UpdateRouterInfo ();
@ -218,5 +219,10 @@ namespace i2p @@ -218,5 +219,10 @@ namespace i2p
void RouterContext::HandleI2NPMessage (const uint8_t * buf, size_t len, std::shared_ptr<i2p::tunnel::InboundTunnel> from)
{
i2p::HandleI2NPMessage (CreateI2NPMessage (buf, GetI2NPMessageLength (buf), from));
}
uint32_t RouterContext::GetUptime () const
{
return i2p::util::GetSecondsSinceEpoch () - m_StartupTime;
}
}

2
RouterContext.h

@ -31,6 +31,7 @@ namespace i2p @@ -31,6 +31,7 @@ namespace i2p
[](const i2p::data::RouterInfo *) {});
}
CryptoPP::RandomNumberGenerator& GetRandomNumberGenerator () { return m_Rnd; };
uint32_t GetUptime () const;
void UpdatePort (int port); // called from Daemon
void UpdateAddress (const boost::asio::ip::address& host); // called from SSU or Daemon
@ -71,6 +72,7 @@ namespace i2p @@ -71,6 +72,7 @@ namespace i2p
CryptoPP::AutoSeededRandomPool m_Rnd;
uint64_t m_LastUpdateTime;
bool m_IsUnreachable, m_AcceptsTunnels, m_IsFloodfill;
uint64_t m_StartupTime; // in seconds since epoch
};
extern RouterContext context;

Loading…
Cancel
Save