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 @@
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include "base64.h" #include "base64.h"
#include "Log.h" #include "Log.h"
#include "Tunnel.h" #include "Tunnel.h"
@ -646,8 +647,11 @@ namespace util
void HTTPConnection::FillContent (std::stringstream& s) void HTTPConnection::FillContent (std::stringstream& s)
{ {
s << "<h2>Welcome to the Webconsole!</h2><br><br>"; 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>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()) for (auto& address : i2p::context.GetRouterInfo().GetAddresses())
{ {
switch (address.transportStyle) switch (address.transportStyle)

8
RouterContext.cpp

@ -14,12 +14,13 @@ namespace i2p
RouterContext::RouterContext (): RouterContext::RouterContext ():
m_LastUpdateTime (0), m_IsUnreachable (false), m_AcceptsTunnels (true), m_LastUpdateTime (0), m_IsUnreachable (false), m_AcceptsTunnels (true),
m_IsFloodfill (false) m_IsFloodfill (false), m_StartupTime (0)
{ {
} }
void RouterContext::Init () void RouterContext::Init ()
{ {
m_StartupTime = i2p::util::GetSecondsSinceEpoch ();
if (!Load ()) if (!Load ())
CreateNewRouter (); CreateNewRouter ();
UpdateRouterInfo (); UpdateRouterInfo ();
@ -219,4 +220,9 @@ namespace i2p
{ {
i2p::HandleI2NPMessage (CreateI2NPMessage (buf, GetI2NPMessageLength (buf), 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
[](const i2p::data::RouterInfo *) {}); [](const i2p::data::RouterInfo *) {});
} }
CryptoPP::RandomNumberGenerator& GetRandomNumberGenerator () { return m_Rnd; }; CryptoPP::RandomNumberGenerator& GetRandomNumberGenerator () { return m_Rnd; };
uint32_t GetUptime () const;
void UpdatePort (int port); // called from Daemon void UpdatePort (int port); // called from Daemon
void UpdateAddress (const boost::asio::ip::address& host); // called from SSU or Daemon void UpdateAddress (const boost::asio::ip::address& host); // called from SSU or Daemon
@ -71,6 +72,7 @@ namespace i2p
CryptoPP::AutoSeededRandomPool m_Rnd; CryptoPP::AutoSeededRandomPool m_Rnd;
uint64_t m_LastUpdateTime; uint64_t m_LastUpdateTime;
bool m_IsUnreachable, m_AcceptsTunnels, m_IsFloodfill; bool m_IsUnreachable, m_AcceptsTunnels, m_IsFloodfill;
uint64_t m_StartupTime; // in seconds since epoch
}; };
extern RouterContext context; extern RouterContext context;

Loading…
Cancel
Save