diff --git a/HTTPServer.cpp b/HTTPServer.cpp index 3ced372b..15478116 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -8,6 +8,7 @@ #include "NetDb.h" #include "HTTPServer.h" #include "I2PEndian.h" +#include "Streaming.h" // For image and info #include "version.h" @@ -460,6 +461,7 @@ namespace util const char HTTP_COMMAND_TUNNELS[] = "tunnels"; const char HTTP_COMMAND_TRANSIT_TUNNELS[] = "transit_tunnels"; const char HTTP_COMMAND_TRANSPORTS[] = "transports"; + const char HTTP_COMMAND_LOCAL_DESTINATIONS[] = "local_destinations"; namespace misc_strings { @@ -628,8 +630,9 @@ namespace util s << "Floodfills: " << i2p::data::netdb.GetNumFloodfills () << " "; s << "LeaseSets: " << i2p::data::netdb.GetNumLeaseSets () << "
"; - s << "
Tunnels
"; - s << "
Transit tunnels
"; + s << "
Local destinations"; + s << "
Tunnels"; + s << "
Transit tunnels"; s << "
Transports
"; s << "

Flibusta

"; @@ -643,7 +646,8 @@ namespace util ShowTunnels (s); else if (command == HTTP_COMMAND_TRANSIT_TUNNELS) ShowTransitTunnels (s); - + else if (command == HTTP_COMMAND_LOCAL_DESTINATIONS) + ShowLocalDestinations (s); } void HTTPConnection::ShowTransports (std::stringstream& s) @@ -662,6 +666,7 @@ namespace util s << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]"; s << "
"; } + s << std::endl; } auto ssuServer = i2p::transports.GetSSUServer (); if (ssuServer) @@ -677,6 +682,7 @@ namespace util if (!outgoing) s << "-->"; s << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]"; s << "
"; + s << std::endl; } } } @@ -694,6 +700,7 @@ namespace util else if (state == i2p::tunnel::eTunnelStateExpiring) s << " " << "Exp"; s << " " << (int)it->GetNumSentBytes () << "
"; + s << std::endl; } for (auto it: i2p::tunnel::tunnels.GetInboundTunnels ()) @@ -707,6 +714,7 @@ namespace util else if (state == i2p::tunnel::eTunnelStateExpiring) s << " " << "Exp"; s << " " << (int)it.second->GetNumReceivedBytes () << "
"; + s << std::endl; } } @@ -723,6 +731,14 @@ namespace util s << " " << it.second->GetNumTransmittedBytes () << "
"; } } + + void HTTPConnection::ShowLocalDestinations (std::stringstream& s) + { + for (auto& it: i2p::stream::GetLocalDestinations ().GetDestinations ()) + { + s << it.first.ToBase32 () << ".b32.i2p
" << std::endl; + } + } void HTTPConnection::HandleDestinationRequest (const std::string& address, const std::string& uri) { diff --git a/HTTPServer.h b/HTTPServer.h index 28414062..6ea86839 100644 --- a/HTTPServer.h +++ b/HTTPServer.h @@ -62,6 +62,7 @@ namespace util void ShowTransports (std::stringstream& s); void ShowTunnels (std::stringstream& s); void ShowTransitTunnels (std::stringstream& s); + void ShowLocalDestinations (std::stringstream& s); void FillContent (std::stringstream& s); std::string ExtractAddress (); diff --git a/Streaming.cpp b/Streaming.cpp index 4477cd6e..5bc26bd8 100644 --- a/Streaming.cpp +++ b/Streaming.cpp @@ -842,6 +842,11 @@ namespace stream return destinations.LoadLocalDestination (filename); } + const StreamingDestinations& GetLocalDestinations () + { + return destinations; + } + void HandleDataMessage (i2p::data::IdentHash destination, const uint8_t * buf, size_t len) { uint32_t length = be32toh (*(uint32_t *)buf); diff --git a/Streaming.h b/Streaming.h index e3ae83e4..e68f0254 100644 --- a/Streaming.h +++ b/Streaming.h @@ -218,6 +218,10 @@ namespace stream std::map m_Destinations; StreamingDestination * m_SharedLocalDestination; + + public: + // for HTTP + const decltype(m_Destinations)& GetDestinations () const { return m_Destinations; }; }; Stream * CreateStream (const i2p::data::LeaseSet& remote); @@ -229,8 +233,10 @@ namespace stream void DeleteLocalDestination (StreamingDestination * destination); StreamingDestination * GetLocalDestination (const i2p::data::PrivateKeys& keys, bool isPublic = true); StreamingDestination * FindLocalDestination (const i2p::data::IdentHash& destination); - StreamingDestination * LoadLocalDestination (const std::string& filename); - + StreamingDestination * LoadLocalDestination (const std::string& filename); + // for HTTP + const StreamingDestinations& GetLocalDestinations (); + // assuming data is I2CP message void HandleDataMessage (i2p::data::IdentHash destination, const uint8_t * buf, size_t len); I2NPMessage * CreateDataMessage (Stream * s, const uint8_t * payload, size_t len);