From c46a82420db80989b7190d69d1894ad20e6489c4 Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 23 Feb 2015 14:41:56 -0500 Subject: [PATCH] show uptime --- HTTPServer.cpp | 6 +++++- RouterContext.cpp | 8 +++++++- RouterContext.h | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/HTTPServer.cpp b/HTTPServer.cpp index c83894aa..fc2fc060 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "base64.h" #include "Log.h" #include "Tunnel.h" @@ -646,8 +647,11 @@ namespace util void HTTPConnection::FillContent (std::stringstream& s) { s << "

Welcome to the Webconsole!



"; + s << "Uptime: " << s << "Data path: " << i2p::util::filesystem::GetDataDir().string() << "
" << "
"; - s << "Our external address:" << "
"; + s << "Our external address:" << boost::posix_time::to_simple_string ( + boost::posix_time::time_duration (boost::posix_time::seconds ( + i2p::context.GetUptime ()))) << "

"; for (auto& address : i2p::context.GetRouterInfo().GetAddresses()) { switch (address.transportStyle) diff --git a/RouterContext.cpp b/RouterContext.cpp index 36cb06bf..d7e20aac 100644 --- a/RouterContext.cpp +++ b/RouterContext.cpp @@ -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 void RouterContext::HandleI2NPMessage (const uint8_t * buf, size_t len, std::shared_ptr from) { i2p::HandleI2NPMessage (CreateI2NPMessage (buf, GetI2NPMessageLength (buf), from)); + } + + uint32_t RouterContext::GetUptime () const + { + return i2p::util::GetSecondsSinceEpoch () - m_StartupTime; } } diff --git a/RouterContext.h b/RouterContext.h index e483646c..0073d538 100644 --- a/RouterContext.h +++ b/RouterContext.h @@ -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 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;