From 0e894520565722fdfa0a91a36fbb2d8abee111d9 Mon Sep 17 00:00:00 2001 From: R4SAS Date: Wed, 22 May 2019 23:29:35 +0300 Subject: [PATCH] fix indent in HTTPServer, add RI log messages --- daemon/HTTPServer.cpp | 60 +++++++++++++++++++-------------------- libi2pd/RouterContext.cpp | 4 +-- libi2pd/RouterInfo.cpp | 3 ++ libi2pd/Transports.cpp | 2 +- 4 files changed, 36 insertions(+), 33 deletions(-) diff --git a/daemon/HTTPServer.cpp b/daemon/HTTPServer.cpp index 5442a866..5125b8a5 100644 --- a/daemon/HTTPServer.cpp +++ b/daemon/HTTPServer.cpp @@ -203,10 +203,10 @@ namespace http { s << "ERROR: " << string << "
\r\n"; } - void ShowStatus ( - std::stringstream& s, - bool includeHiddenContent, - i2p::http::OutputFormatEnum outputFormat) + void ShowStatus ( + std::stringstream& s, + bool includeHiddenContent, + i2p::http::OutputFormatEnum outputFormat) { s << "Uptime: "; ShowUptime(s, i2p::context.GetUptime ()); @@ -253,16 +253,16 @@ namespace http { ShowTraffic (s, i2p::transport::transports.GetTotalTransitTransmittedBytes ()); s << " (" << (double) i2p::transport::transports.GetTransitBandwidth () / 1024 << " KiB/s)
\r\n"; s << "Data path: " << i2p::fs::GetDataDir() << "
\r\n"; - s << "
"; - if((outputFormat==OutputFormatEnum::forWebConsole)||!includeHiddenContent) { - s << "\r\n\r\n

\r\n"; - } - if(includeHiddenContent) { - s << "Router Ident: " << i2p::context.GetRouterInfo().GetIdentHashBase64() << "
\r\n"; - s << "Router Family: " << i2p::context.GetRouterInfo().GetProperty("family") << "
\r\n"; - s << "Router Caps: " << i2p::context.GetRouterInfo().GetProperty("caps") << "
\r\n"; + s << "

"; + if((outputFormat==OutputFormatEnum::forWebConsole)||!includeHiddenContent) { + s << "\r\n\r\n

\r\n"; + } + if(includeHiddenContent) { + s << "Router Ident: " << i2p::context.GetRouterInfo ().GetIdentHashBase64 () << "
\r\n"; + s << "Router Family: " << i2p::context.GetRouterInfo ().GetProperty ("family") << "
\r\n"; + s << "Router Caps: " << i2p::context.GetRouterInfo ().GetProperty ("caps") << "
\r\n"; s << "Our external address:" << "
\r\n" ; - for (const auto& address : i2p::context.GetRouterInfo().GetAddresses()) + for (const auto& address : i2p::context.GetRouterInfo ().GetAddresses ()) { if (address->IsNTCP2 () && !address->IsPublishedNTCP2 ()) { @@ -292,12 +292,12 @@ namespace http { } s << address->host.to_string() << ":" << address->port << "
\r\n"; } - } + } s << "

\r\n
\r\n"; - if(outputFormat==OutputFormatEnum::forQtUi) { - s << "
"; - } - s << "Routers: " << i2p::data::netdb.GetNumRouters () << " "; + if(outputFormat==OutputFormatEnum::forQtUi) { + s << "
"; + } + s << "Routers: " << i2p::data::netdb.GetNumRouters () << " "; s << "Floodfills: " << i2p::data::netdb.GetNumFloodfills () << " "; s << "LeaseSets: " << i2p::data::netdb.GetNumLeaseSets () << "
\r\n"; @@ -308,17 +308,17 @@ namespace http { s << "Client Tunnels: " << std::to_string(clientTunnelCount) << " "; s << "Transit Tunnels: " << std::to_string(transitTunnelCount) << "
\r\n
\r\n"; - if(outputFormat==OutputFormatEnum::forWebConsole) { - s << "\r\n"; - s << "\r\n"; - s << "\r\n"; - s << "\r\n"; - s << "\r\n"; - s << "\r\n"; - bool i2pcontrol; i2p::config::GetOption("i2pcontrol.enabled", i2pcontrol); - s << "\r\n"; - s << "
Services
ServiceState
" << "HTTP Proxy" << "
" << "SOCKS Proxy" << "
" << "BOB" << "
" << "SAM" << "
" << "I2CP" << "
" << "I2PControl" << "
\r\n"; - } + if(outputFormat==OutputFormatEnum::forWebConsole) { + s << "\r\n"; + s << "\r\n"; + s << "\r\n"; + s << "\r\n"; + s << "\r\n"; + s << "\r\n"; + bool i2pcontrol; i2p::config::GetOption("i2pcontrol.enabled", i2pcontrol); + s << "\r\n"; + s << "
Services
ServiceState
" << "HTTP Proxy" << "
" << "SOCKS Proxy" << "
" << "BOB" << "
" << "SAM" << "
" << "I2CP" << "
" << "I2PControl" << "
\r\n"; + } } void ShowLocalDestinations (std::stringstream& s) @@ -918,7 +918,7 @@ namespace http { } else if (req.uri.find("cmd=") != std::string::npos) { HandleCommand (req, res, s); } else { - ShowStatus (s, true, i2p::http::OutputFormatEnum::forWebConsole); + ShowStatus (s, true, i2p::http::OutputFormatEnum::forWebConsole); res.add_header("Refresh", "10"); } ShowPageTail (s); diff --git a/libi2pd/RouterContext.cpp b/libi2pd/RouterContext.cpp index 14111c33..25855c15 100644 --- a/libi2pd/RouterContext.cpp +++ b/libi2pd/RouterContext.cpp @@ -621,10 +621,10 @@ namespace i2p m_RouterInfo.DeleteProperty ("coreVersion"); m_RouterInfo.DeleteProperty ("stat_uptime"); - bool ipv4; i2p::config::GetOption("ipv4", ipv4); + /*bool ipv4; i2p::config::GetOption("ipv4", ipv4); bool ipv6; i2p::config::GetOption("ipv6", ipv6); SetSupportsV4(ipv4); - SetSupportsV6(ipv6); + SetSupportsV6(ipv6);*/ } else { diff --git a/libi2pd/RouterInfo.cpp b/libi2pd/RouterInfo.cpp index 58565fa9..a178ea67 100644 --- a/libi2pd/RouterInfo.cpp +++ b/libi2pd/RouterInfo.cpp @@ -677,6 +677,7 @@ namespace data for (const auto& it: *m_Addresses) // don't insert same address twice if (*it == *addr) return; m_SupportedTransports |= addr->host.is_v6 () ? eNTCPV6 : eNTCPV4; + LogPrint (eLogInfo, "RouterInfo: added NTCP address ", addr->host.to_string(), ":", addr->port, " to our RI"); m_Addresses->push_front(std::move(addr)); // always make NTCP first } @@ -694,6 +695,7 @@ namespace data for (const auto& it: *m_Addresses) // don't insert same address twice if (*it == *addr) return; m_SupportedTransports |= addr->host.is_v6 () ? eSSUV6 : eSSUV4; + LogPrint (eLogInfo, "RouterInfo: added SSU address ", addr->host.to_string(), ":", addr->port, " to our RI"); m_Addresses->push_back(std::move(addr)); m_Caps |= eSSUTesting; @@ -713,6 +715,7 @@ namespace data if (port) addr->ntcp2->isPublished = true; memcpy (addr->ntcp2->staticKey, staticKey, 32); memcpy (addr->ntcp2->iv, iv, 16); + LogPrint (eLogInfo, "RouterInfo: added NTCP2 address ", addr->host.to_string(), ":", addr->port, " to our RI"); m_Addresses->push_back(std::move(addr)); } diff --git a/libi2pd/Transports.cpp b/libi2pd/Transports.cpp index ca7c3103..13fa8c51 100644 --- a/libi2pd/Transports.cpp +++ b/libi2pd/Transports.cpp @@ -447,7 +447,7 @@ namespace transport else LogPrint (eLogDebug, "Transports: NTCP address is not present for ", i2p::data::GetIdentHashAbbreviation (ident), ", trying SSU"); } - if (peer.numAttempts == 2)// SSU + if (peer.numAttempts == 2) // SSU { peer.numAttempts++; auto address = peer.router->GetSSUAddress (!context.SupportsV6 ());