Browse Source

show local destinations

pull/102/head
orignal 10 years ago
parent
commit
b13c9d924f
  1. 22
      HTTPServer.cpp
  2. 1
      HTTPServer.h
  3. 5
      Streaming.cpp
  4. 10
      Streaming.h

22
HTTPServer.cpp

@ -8,6 +8,7 @@ @@ -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 @@ -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 @@ -628,8 +630,9 @@ namespace util
s << "<b>Floodfills:</b> <i>" << i2p::data::netdb.GetNumFloodfills () << "</i> ";
s << "<b>LeaseSets:</b> <i>" << i2p::data::netdb.GetNumLeaseSets () << "</i><br>";
s << "<br><b><a href=/?" << HTTP_COMMAND_TUNNELS << ">Tunnels</a></b><br>";
s << "<br><b><a href=/?" << HTTP_COMMAND_TRANSIT_TUNNELS << ">Transit tunnels</a></b><br>";
s << "<br><b><a href=/?" << HTTP_COMMAND_LOCAL_DESTINATIONS << ">Local destinations</a></b>";
s << "<br><b><a href=/?" << HTTP_COMMAND_TUNNELS << ">Tunnels</a></b>";
s << "<br><b><a href=/?" << HTTP_COMMAND_TRANSIT_TUNNELS << ">Transit tunnels</a></b>";
s << "<br><b><a href=/?" << HTTP_COMMAND_TRANSPORTS << ">Transports</a></b><br>";
s << "<p><a href=\"zmw2cyw2vj7f6obx3msmdvdepdhnw2ctc4okza2zjxlukkdfckhq.b32.i2p\">Flibusta</a></p>";
@ -643,7 +646,8 @@ namespace util @@ -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 @@ -662,6 +666,7 @@ namespace util
s << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]";
s << "<br>";
}
s << std::endl;
}
auto ssuServer = i2p::transports.GetSSUServer ();
if (ssuServer)
@ -677,6 +682,7 @@ namespace util @@ -677,6 +682,7 @@ namespace util
if (!outgoing) s << "-->";
s << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]";
s << "<br>";
s << std::endl;
}
}
}
@ -694,6 +700,7 @@ namespace util @@ -694,6 +700,7 @@ namespace util
else if (state == i2p::tunnel::eTunnelStateExpiring)
s << " " << "Exp";
s << " " << (int)it->GetNumSentBytes () << "<br>";
s << std::endl;
}
for (auto it: i2p::tunnel::tunnels.GetInboundTunnels ())
@ -707,6 +714,7 @@ namespace util @@ -707,6 +714,7 @@ namespace util
else if (state == i2p::tunnel::eTunnelStateExpiring)
s << " " << "Exp";
s << " " << (int)it.second->GetNumReceivedBytes () << "<br>";
s << std::endl;
}
}
@ -723,6 +731,14 @@ namespace util @@ -723,6 +731,14 @@ namespace util
s << " " << it.second->GetNumTransmittedBytes () << "<br>";
}
}
void HTTPConnection::ShowLocalDestinations (std::stringstream& s)
{
for (auto& it: i2p::stream::GetLocalDestinations ().GetDestinations ())
{
s << it.first.ToBase32 () << ".b32.i2p<br>" << std::endl;
}
}
void HTTPConnection::HandleDestinationRequest (const std::string& address, const std::string& uri)
{

1
HTTPServer.h

@ -62,6 +62,7 @@ namespace util @@ -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 ();

5
Streaming.cpp

@ -842,6 +842,11 @@ namespace stream @@ -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);

10
Streaming.h

@ -218,6 +218,10 @@ namespace stream @@ -218,6 +218,10 @@ namespace stream
std::map<i2p::data::IdentHash, StreamingDestination *> 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 @@ -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);

Loading…
Cancel
Save