From eb96ead80e871320885dd916847b0ca97f9399da Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 2 Mar 2016 09:41:37 -0500 Subject: [PATCH 1/3] add tunnel counts to front page of web ui --- HTTPServer.cpp | 7 +++++++ Tunnel.cpp | 17 ++++++++++++++++- Tunnel.h | 5 +++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/HTTPServer.cpp b/HTTPServer.cpp index 85dbec42..e218117a 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -447,6 +447,13 @@ namespace util s << "
\r\nRouters: " << i2p::data::netdb.GetNumRouters () << " "; s << "Floodfills: " << i2p::data::netdb.GetNumFloodfills () << " "; s << "LeaseSets: " << i2p::data::netdb.GetNumLeaseSets () << "
\r\n"; + + size_t clientTunnelCount = i2p::tunnel::tunnels.CountOutboundTunnels(); + clientTunnelCount += i2p::tunnel::tunnels.CountInboundTunnels(); + size_t transitTunnelCount = i2p::tunnel::tunnels.CountTransitTunnels(); + + s << "Client Tunnels " << std::to_string(clientTunnelCount) << " "; + s << "Transit Tunnels: " << std::to_string(transitTunnelCount) << "
\r\n"; } void HTTPConnection::HandleCommand (const std::string& command, std::stringstream& s) diff --git a/Tunnel.cpp b/Tunnel.cpp index f7102327..ee3b7119 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -793,7 +793,22 @@ namespace tunnel if (t > timeout) timeout = t; } return timeout; - } + } + + size_t Tunnels::CountTransitTunnels() { + // TODO: locking + return m_TransitTunnels.size(); + } + + size_t Tunnels::CountInboundTunnels() { + // TODO: locking + return m_InboundTunnels.size(); + } + + size_t Tunnels::CountOutboundTunnels() { + // TODO: locking + return m_OutboundTunnels.size(); + } } } diff --git a/Tunnel.h b/Tunnel.h index 138a48fc..f3bcc127 100644 --- a/Tunnel.h +++ b/Tunnel.h @@ -201,6 +201,11 @@ namespace tunnel const decltype(m_OutboundTunnels)& GetOutboundTunnels () const { return m_OutboundTunnels; }; const decltype(m_InboundTunnels)& GetInboundTunnels () const { return m_InboundTunnels; }; const decltype(m_TransitTunnels)& GetTransitTunnels () const { return m_TransitTunnels; }; + + size_t CountTransitTunnels(); + size_t CountInboundTunnels(); + size_t CountOutboundTunnels(); + int GetQueueSize () { return m_Queue.GetSize (); }; int GetTunnelCreationSuccessRate () const // in percents { From 9378668e52d1e02e304a02db29b96cb49428d912 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 2 Mar 2016 09:58:17 -0500 Subject: [PATCH 2/3] add colin --- HTTPServer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HTTPServer.cpp b/HTTPServer.cpp index e218117a..39109dba 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -452,7 +452,7 @@ namespace util clientTunnelCount += i2p::tunnel::tunnels.CountInboundTunnels(); size_t transitTunnelCount = i2p::tunnel::tunnels.CountTransitTunnels(); - s << "Client Tunnels " << std::to_string(clientTunnelCount) << " "; + s << "Client Tunnels: " << std::to_string(clientTunnelCount) << " "; s << "Transit Tunnels: " << std::to_string(transitTunnelCount) << "
\r\n"; } From 1dc6cec1aa72ac85eeeaaee8189ff68126d17193 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 2 Mar 2016 10:05:26 -0500 Subject: [PATCH 3/3] add client/transit tunnel count in webui --- HTTPServer.cpp | 12 ++++++------ Tunnel.cpp | 28 ++++++++++++++-------------- Tunnel.h | 8 ++++---- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/HTTPServer.cpp b/HTTPServer.cpp index 39109dba..128b3ad6 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -448,12 +448,12 @@ namespace util s << "Floodfills: " << i2p::data::netdb.GetNumFloodfills () << " "; s << "LeaseSets: " << i2p::data::netdb.GetNumLeaseSets () << "
\r\n"; - size_t clientTunnelCount = i2p::tunnel::tunnels.CountOutboundTunnels(); - clientTunnelCount += i2p::tunnel::tunnels.CountInboundTunnels(); - size_t transitTunnelCount = i2p::tunnel::tunnels.CountTransitTunnels(); - - s << "Client Tunnels: " << std::to_string(clientTunnelCount) << " "; - s << "Transit Tunnels: " << std::to_string(transitTunnelCount) << "
\r\n"; + size_t clientTunnelCount = i2p::tunnel::tunnels.CountOutboundTunnels(); + clientTunnelCount += i2p::tunnel::tunnels.CountInboundTunnels(); + size_t transitTunnelCount = i2p::tunnel::tunnels.CountTransitTunnels(); + + s << "Client Tunnels: " << std::to_string(clientTunnelCount) << " "; + s << "Transit Tunnels: " << std::to_string(transitTunnelCount) << "
\r\n"; } void HTTPConnection::HandleCommand (const std::string& command, std::stringstream& s) diff --git a/Tunnel.cpp b/Tunnel.cpp index ee3b7119..f235d321 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -795,20 +795,20 @@ namespace tunnel return timeout; } - size_t Tunnels::CountTransitTunnels() { - // TODO: locking - return m_TransitTunnels.size(); - } - - size_t Tunnels::CountInboundTunnels() { - // TODO: locking - return m_InboundTunnels.size(); - } - - size_t Tunnels::CountOutboundTunnels() { - // TODO: locking - return m_OutboundTunnels.size(); - } + size_t Tunnels::CountTransitTunnels() { + // TODO: locking + return m_TransitTunnels.size(); + } + + size_t Tunnels::CountInboundTunnels() { + // TODO: locking + return m_InboundTunnels.size(); + } + + size_t Tunnels::CountOutboundTunnels() { + // TODO: locking + return m_OutboundTunnels.size(); + } } } diff --git a/Tunnel.h b/Tunnel.h index f3bcc127..ea68f1c3 100644 --- a/Tunnel.h +++ b/Tunnel.h @@ -202,10 +202,10 @@ namespace tunnel const decltype(m_InboundTunnels)& GetInboundTunnels () const { return m_InboundTunnels; }; const decltype(m_TransitTunnels)& GetTransitTunnels () const { return m_TransitTunnels; }; - size_t CountTransitTunnels(); - size_t CountInboundTunnels(); - size_t CountOutboundTunnels(); - + size_t CountTransitTunnels(); + size_t CountInboundTunnels(); + size_t CountOutboundTunnels(); + int GetQueueSize () { return m_Queue.GetSize (); }; int GetTunnelCreationSuccessRate () const // in percents {