From cf1719427e3c3105297c17081f00cd776da52785 Mon Sep 17 00:00:00 2001 From: dr|z3d Date: Sat, 14 Aug 2021 20:41:33 +0000 Subject: [PATCH] Console: move 'sensitive' info to control page; refinements; hide header buttons for now --- daemon/HTTPServer.cpp | 106 ++++++++++++++++++++++-------------------- webconsole/style.css | 26 +++++++++-- 2 files changed, 78 insertions(+), 54 deletions(-) diff --git a/daemon/HTTPServer.cpp b/daemon/HTTPServer.cpp index 4bfb2763..5601930f 100644 --- a/daemon/HTTPServer.cpp +++ b/daemon/HTTPServer.cpp @@ -374,7 +374,8 @@ namespace http { time_t t = divTime.quot; struct tm *tm = localtime(&t); char date[128]; - snprintf(date, sizeof(date), "%02d/%02d/%d %02d:%02d:%02d.%03lld", tm->tm_mday, tm->tm_mon + 1, tm->tm_year + 1900, tm->tm_hour, tm->tm_min, tm->tm_sec, divTime.rem); + snprintf(date, sizeof(date), "%02d/%02d/%d %02d:%02d:%02d.%03lld", + tm->tm_mday, tm->tm_mon + 1, tm->tm_year + 1900, tm->tm_hour, tm->tm_min, tm->tm_sec, divTime.rem); return date; } @@ -580,7 +581,6 @@ namespace http { void ShowStatus (std::stringstream& s, bool includeHiddenContent, i2p::http::OutputFormatEnum outputFormat) { - s << "" << tr("Version") << "" VERSION "\r\n"; s << "" << tr("Uptime") << ""; ShowUptime(s, i2p::context.GetUptime ()); s << "\r\n"; @@ -664,50 +664,6 @@ namespace http { } s << "" << tr("Build Success") << ""; s << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%\r\n"; -// TODO: Move to separate routerinfo page -/* - s << "" << tr("Router Caps") << "" << i2p::context.GetRouterInfo().GetProperty("caps") << "\r\n"; - s << "" << tr("Data path") << "" << i2p::fs::GetUTF8DataDir() << "\r\n"; - s << "" << tr("Router Ident") << "\r\n"; - auto family = i2p::context.GetFamily (); - if (family.length () > 0) - s << ""<< tr("Family") << "" << family << "
\r\n"; - if (!i2p::context.GetRouterInfo().GetProperty("family").empty()) - s << "" << tr("Router Family") << "\r\n"; - for (const auto& address : i2p::context.GetRouterInfo().GetAddresses()) - { - s << "\r\n"; - if (address->IsNTCP2 () && !address->IsPublishedNTCP2 ()) - { - s << "NTCP2"; - if (address->host.is_v6 ()) s << "v6"; - s << "" << tr("supported") << "\r\n\r\n"; - continue; - } - switch (address->transportStyle) - { - case i2p::data::RouterInfo::eTransportNTCP: - { - s << "NTCP"; - if (address->IsPublishedNTCP2 ()) s << "2"; - if (address->host.is_v6 ()) s << "v6"; - s << "\r\n"; - break; - } - case i2p::data::RouterInfo::eTransportSSU: - { - s << "SSU"; - if (address->host.is_v6 ()) - s << "v6"; - s << "\r\n"; - break; - } - default: - s << "" << tr("Unknown") << "\r\n"; - } - s << "\r\n\r\n"; - } -*/ s << "" << tr("Routers") << "" << i2p::data::netdb.GetNumRouters () << "\r\n"; s << "" << tr("Floodfills") << "" << i2p::data::netdb.GetNumFloodfills () << "\r\n"; s << "" << tr("LeaseSets") << "" << i2p::data::netdb.GetNumLeaseSets () << "\r\n"; @@ -731,7 +687,7 @@ namespace http { bool i2cp = i2p::client::context.GetI2CPServer () ? true : false; bool i2pcontrol; i2p::config::GetOption("i2pcontrol.enabled", i2pcontrol); if (httpproxy || socksproxy || bob || sam || i2cp || i2pcontrol) { - s << "" << tr("Active Router Services") << "\r\n"; + s << "" << tr("Router Services") << ""; s << ""; if (httpproxy) s << " HTTP " << tr("Proxy") << " "; @@ -1141,8 +1097,54 @@ namespace http { static void ShowCommands (std::stringstream& s, uint32_t token) { - std::string webroot; i2p::config::GetOption("http.webroot", webroot); + s << "" << tr("Router Configuration") << ""; + s << "" << tr("Version") << "" VERSION "\r\n"; + s << "" << tr("Router Ident") << "\r\n"; + s << "" << tr("Router Caps") << "" << i2p::context.GetRouterInfo().GetProperty("caps") << "\r\n"; + if (!i2p::context.GetRouterInfo().GetProperty("family").empty()) + s << "" << tr("Router Family") << "\r\n"; + auto family = i2p::context.GetFamily (); + if (family.length () > 0) + s << ""<< tr("Family") << "" << family << "
\r\n"; + for (const auto& address : i2p::context.GetRouterInfo().GetAddresses()) + { + s << "\r\n"; + if (address->IsNTCP2 () && !address->IsPublishedNTCP2 ()) + { + s << "NTCP2"; + if (address->host.is_v6 ()) s << "v6"; + s << "" << tr("supported") << "\r\n\r\n"; + continue; + } + switch (address->transportStyle) + { + case i2p::data::RouterInfo::eTransportNTCP: + { + s << "NTCP"; + if (address->IsPublishedNTCP2 ()) s << "2"; + if (address->host.is_v6 ()) s << "v6"; + s << "\r\n"; + break; + } + case i2p::data::RouterInfo::eTransportSSU: + { + s << "SSU"; + if (address->host.is_v6 ()) + s << "v6"; + s << "\r\n"; + break; + } + default: + s << "" << tr("Unknown") << "\r\n"; + } + s << "\r\n\r\n"; + } + s << "" << tr("Data path") << "" << i2p::fs::GetUTF8DataDir() << "\r\n"; + + std::string webroot; i2p::config::GetOption("http.webroot", webroot); s << "" << tr("Router Commands") << "" << "\r\n"; s << " " << tr("Force shutdown") << "\r\n"; - } -/* only one option? displayed in the header +/* TODO graceful shutdown button in header with .notify dialog if transit tunnels + active to offer option to shutdown immediately + only one option? displayed in the header +*/ } else { s << " " << tr("Shutdown") << "\r\n"; } -*/ + std::string styleFile = i2p::fs::DataDirPath ("webconsole/style.css"); if (i2p::fs::Exists(styleFile)) { s << "