Browse Source

show tunlel creation success ratio

pull/163/head
orignal 10 years ago
parent
commit
6f9d8ed01b
  1. 1
      HTTPServer.cpp
  2. 7
      Tunnel.cpp
  3. 8
      Tunnel.h

1
HTTPServer.cpp

@ -659,6 +659,7 @@ namespace util @@ -659,6 +659,7 @@ namespace util
default: s << "Unknown";
}
s << "<br>";
s << "<b>Tunnel creation success rate:</b> " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%<br>";
s << "<b>Data path:</b> " << i2p::util::filesystem::GetDataDir().string() << "<br><br>";
s << "<b>Our external address:</b>" << "<br>" ;
for (auto& address : i2p::context.GetRouterInfo().GetAddresses())

7
Tunnel.cpp

@ -203,7 +203,8 @@ namespace tunnel @@ -203,7 +203,8 @@ namespace tunnel
Tunnels tunnels;
Tunnels::Tunnels (): m_IsRunning (false), m_Thread (nullptr)
Tunnels::Tunnels (): m_IsRunning (false), m_Thread (nullptr),
m_NumSuccesiveTunnelCreations (0), m_NumFailedTunnelCreations (0)
{
}
@ -488,6 +489,7 @@ namespace tunnel @@ -488,6 +489,7 @@ namespace tunnel
{
LogPrint ("Pending tunnel build request ", it->first, " timeout. Deleted");
it = pendingTunnels.erase (it);
m_NumFailedTunnelCreations++;
}
else
it++;
@ -495,13 +497,16 @@ namespace tunnel @@ -495,13 +497,16 @@ namespace tunnel
case eTunnelStateBuildFailed:
LogPrint ("Pending tunnel build request ", it->first, " failed. Deleted");
it = pendingTunnels.erase (it);
m_NumFailedTunnelCreations++;
break;
case eTunnelStateBuildReplyReceived:
// intermediate state, will be either established of build failed
it++;
break;
default:
// success
it = pendingTunnels.erase (it);
m_NumSuccesiveTunnelCreations++;
}
}
}

8
Tunnel.h

@ -175,6 +175,9 @@ namespace tunnel @@ -175,6 +175,9 @@ namespace tunnel
std::shared_ptr<TunnelPool> m_ExploratoryPool;
i2p::util::Queue<I2NPMessage> m_Queue;
// some stats
int m_NumSuccesiveTunnelCreations, m_NumFailedTunnelCreations;
public:
// for HTTP only
@ -182,6 +185,11 @@ namespace tunnel @@ -182,6 +185,11 @@ namespace tunnel
const decltype(m_InboundTunnels)& GetInboundTunnels () const { return m_InboundTunnels; };
const decltype(m_TransitTunnels)& GetTransitTunnels () const { return m_TransitTunnels; };
int GetQueueSize () { return m_Queue.GetSize (); };
int GetTunnelCreationSuccessRate () const // in percents
{
int totalNum = m_NumSuccesiveTunnelCreations + m_NumFailedTunnelCreations;
return totalNum ? m_NumSuccesiveTunnelCreations*100/totalNum : 0;
}
};
extern Tunnels tunnels;

Loading…
Cancel
Save