Browse Source

show streams per local destination

pull/102/head
orignal 10 years ago
parent
commit
6d6c81bf8b
  1. 19
      Destination.cpp
  2. 5
      Destination.h
  3. 4
      HTTPServer.cpp
  4. 2
      TunnelPool.cpp

19
Destination.cpp

@ -70,15 +70,7 @@ namespace stream
StreamingDestination::~StreamingDestination () StreamingDestination::~StreamingDestination ()
{ {
{
std::unique_lock<std::mutex> l(m_StreamsMutex);
for (auto it: m_Streams)
delete it.second;
m_Streams.clear ();
}
Stop (); Stop ();
if (m_Pool)
i2p::tunnel::tunnels.DeleteTunnelPool (m_Pool);
delete m_LeaseSet; delete m_LeaseSet;
} }
@ -95,6 +87,17 @@ namespace stream
void StreamingDestination::Stop () void StreamingDestination::Stop ()
{ {
{
std::unique_lock<std::mutex> l(m_StreamsMutex);
for (auto it: m_Streams)
delete it.second;
m_Streams.clear ();
}
if (m_Pool)
{
i2p::tunnel::tunnels.DeleteTunnelPool (m_Pool);
m_Pool = nullptr;
}
m_IsRunning = false; m_IsRunning = false;
m_Service.stop (); m_Service.stop ();
if (m_Thread) if (m_Thread)

5
Destination.h

@ -77,6 +77,11 @@ namespace stream
bool m_IsPublic; bool m_IsPublic;
std::function<void (Stream *)> m_Acceptor; std::function<void (Stream *)> m_Acceptor;
public:
// for HTTP only
const decltype(m_Streams)& GetStreams () const { return m_Streams; };
}; };
class StreamingDestinations class StreamingDestinations

4
HTTPServer.cpp

@ -798,6 +798,7 @@ namespace util
auto pool = dest->GetTunnelPool (); auto pool = dest->GetTunnelPool ();
if (pool) if (pool)
{ {
s << "<b>Tunnels:</b><br>";
for (auto it: pool->GetOutboundTunnels ()) for (auto it: pool->GetOutboundTunnels ())
{ {
it->GetTunnelConfig ()->Print (s); it->GetTunnelConfig ()->Print (s);
@ -809,6 +810,9 @@ namespace util
s << "<br>" << std::endl; s << "<br>" << std::endl;
} }
} }
s << "<br><b>Streams:</b><br>";
for (auto it: dest->GetStreams ())
s << it.first << "->" << it.second->GetRemoteIdentity ().GetIdentHash ().ToBase32 () << ".b32.i2p<br>" << std::endl;
} }
} }

2
TunnelPool.cpp

@ -37,6 +37,7 @@ namespace tunnel
void TunnelPool::TunnelCreated (InboundTunnel * createdTunnel) void TunnelPool::TunnelCreated (InboundTunnel * createdTunnel)
{ {
if (m_IsDeleted) return;
{ {
std::unique_lock<std::mutex> l(m_InboundTunnelsMutex); std::unique_lock<std::mutex> l(m_InboundTunnelsMutex);
m_InboundTunnels.insert (createdTunnel); m_InboundTunnels.insert (createdTunnel);
@ -60,6 +61,7 @@ namespace tunnel
void TunnelPool::TunnelCreated (OutboundTunnel * createdTunnel) void TunnelPool::TunnelCreated (OutboundTunnel * createdTunnel)
{ {
if (m_IsDeleted) return;
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex); std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
m_OutboundTunnels.insert (createdTunnel); m_OutboundTunnels.insert (createdTunnel);
} }

Loading…
Cancel
Save