diff --git a/daemon/HTTPServer.cpp b/daemon/HTTPServer.cpp index da431607..4d81002d 100644 --- a/daemon/HTTPServer.cpp +++ b/daemon/HTTPServer.cpp @@ -439,20 +439,61 @@ namespace http { else if (state == "established") stateText = tr("established"); else stateText = tr("unknown"); - s << "" - << stateText << ((explr) ? " (" + tr("exploratory") + ")" : "") << ""; - s << std::fixed << std::setprecision(0); - if (bytes > 1024 * 1024 * 1024) { - s << std::fixed << std::setprecision(2); - s << " " << (double) (bytes / 1024 / 1024 / 1024) << "G\r\n"; - } else if (bytes > 1024 * 1024) { - s << std::fixed << std::setprecision(1); - s << " " << (double) (bytes / 1024 / 1024) << "M\r\n"; - } else if (bytes > 1024) { - s << " " << (int) (bytes / 1024) << "K\r\n"; - } else { - s << " " << (int) (bytes) << "B\r\n"; + if (!explr) { + s << "" + << stateText << ((explr) ? " (" + tr("exploratory") + ")" : "") << ""; + s << std::fixed << std::setprecision(0); + if (bytes > 1024 * 1024 * 1024) { + s << std::fixed << std::setprecision(2); + s << " " << (double) (bytes / 1024 / 1024 / 1024) << "G\r\n"; + } else if (bytes > 1024 * 1024) { + s << std::fixed << std::setprecision(1); + s << " " << (double) (bytes / 1024 / 1024) << "M\r\n"; + } else if (bytes > 1024) { + s << " " << (int) (bytes / 1024) << "K\r\n"; + } else { + s << " " << (int) (bytes) << "B\r\n"; + } + } + } + + static void ShowExploratoryTunnelDetails (std::stringstream& s, enum i2p::tunnel::TunnelState eState, bool explr, double bytes) + { + std::string state, stateText; + switch (eState) { + case i2p::tunnel::eTunnelStateBuildReplyReceived : + case i2p::tunnel::eTunnelStatePending : state = "building"; break; + case i2p::tunnel::eTunnelStateBuildFailed : + case i2p::tunnel::eTunnelStateTestFailed : + case i2p::tunnel::eTunnelStateFailed : state = "failed"; break; + case i2p::tunnel::eTunnelStateExpiring : state = "expiring"; break; + case i2p::tunnel::eTunnelStateEstablished : state = "established"; break; + default: state = "unknown"; break; + } + + if (state == "building") stateText = tr("building"); + else if (state == "failed") stateText = tr("failed"); + else if (state == "expiring") stateText = tr("expiring"); + else if (state == "established") stateText = tr("established"); + else stateText = tr("unknown"); + + if (explr) { + s << "" + << stateText << " (" << tr("exploratory") << ")"; + s << std::fixed << std::setprecision(0); + if (bytes > 1024 * 1024 * 1024) { + s << std::fixed << std::setprecision(2); + s << " " << (double) (bytes / 1024 / 1024 / 1024) << "G\r\n"; + } else if (bytes > 1024 * 1024) { + s << std::fixed << std::setprecision(1); + s << " " << (double) (bytes / 1024 / 1024) << "M\r\n"; + } else if (bytes > 1024) { + s << " " << (int) (bytes / 1024) << "K\r\n"; + } else { + s << " " << (int) (bytes) << "B\r\n"; + } } } @@ -1052,47 +1093,102 @@ namespace http { auto ExplPool = i2p::tunnel::tunnels.GetExploratoryPool (); s << "\r\n"; - s << "
\r\n\r\n" - << "