diff --git a/HTTPServer.cpp b/HTTPServer.cpp
index 8ca35100..f10289ef 100644
--- a/HTTPServer.cpp
+++ b/HTTPServer.cpp
@@ -68,7 +68,7 @@ namespace http {
const char HTTP_PAGE_TUNNELS[] = "tunnels";
const char HTTP_PAGE_TRANSIT_TUNNELS[] = "transit_tunnels";
- const char HTTP_PAGE_TRANSPORTS[] = "transports";
+ const char HTTP_PAGE_TRANSPORTS[] = "transports";
const char HTTP_PAGE_LOCAL_DESTINATIONS[] = "local_destinations";
const char HTTP_PAGE_LOCAL_DESTINATION[] = "local_destination";
const char HTTP_PAGE_SAM_SESSIONS[] = "sam_sessions";
@@ -82,7 +82,7 @@ namespace http {
const char HTTP_COMMAND_SHUTDOWN_CANCEL[] = "shutdown_cancel";
const char HTTP_COMMAND_SHUTDOWN_NOW[] = "terminate";
const char HTTP_COMMAND_RUN_PEER_TEST[] = "run_peer_test";
- const char HTTP_COMMAND_RELOAD_CONFIG[] = "reload_config";
+ const char HTTP_COMMAND_RELOAD_CONFIG[] = "reload_config";
const char HTTP_PARAM_SAM_SESSION_ID[] = "id";
const char HTTP_PARAM_ADDRESS[] = "address";
@@ -144,12 +144,14 @@ namespace http {
" Main page
\r\n
\r\n"
" Router commands
\r\n"
" Local destinations
\r\n"
- " Lease Sets
\r\n"
+ " LeaseSets
\r\n"
" Tunnels
\r\n"
" Transit tunnels
\r\n"
" Transports
\r\n"
- " I2P tunnels
\r\n"
- " SAM sessions
\r\n"
+ " I2P tunnels
\r\n";
+ if (i2p::client::context.GetSAMBridge ())
+ s << " SAM sessions
\r\n";
+ s <<
"\r\n"
"
";
}
@@ -239,9 +241,9 @@ namespace http {
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";
+
+ s << "
Client Tunnels: " << std::to_string(clientTunnelCount) << " ";
+ s << "
Transit Tunnels: " << std::to_string(transitTunnelCount) << "
\r\n";
}
void ShowLocalDestinations (std::stringstream& s)
@@ -280,18 +282,18 @@ namespace http {
it->Print(s);
ShowTunnelDetails(s, it->GetState (), it->GetNumSentBytes ());
}
- }
+ }
s << "
\r\n";
s << "
TagsIncoming: " << dest->GetNumIncomingTags () << "
Outgoing:
" << std::endl;
for (const auto& it: dest->GetSessions ())
{
s << i2p::client::context.GetAddressBook ().ToAddress(it.first) << " ";
s << it.second->GetNumOutgoingTags () << "
" << std::endl;
- }
+ }
s << "
" << std::endl;
// s << "
\r\n
Streams:\r\n";
// for (auto it: dest->GetStreamingDestination ()->GetStreams ())
- // {
+ // {
// s << it.first << "->" << i2p::client::context.GetAddressBook ().ToAddress(it.second->GetRemoteIdentity ()) << " ";
// s << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]";
// s << " [out:" << it.second->GetSendQueueSize () << "][in:" << it.second->GetReceiveQueueSize () << "]";
@@ -300,7 +302,7 @@ namespace http {
// s << "[Window:" << it.second->GetWindowSize () << "]";
// s << "[Status:" << (int)it.second->GetStatus () << "]";
// s << "
\r\n"<< std::endl;
- // }
+ // }
s << "
\r\n
Streams";
s << "StreamID | ";
s << "Destination | ";
@@ -315,7 +317,7 @@ namespace http {
s << "
";
for (const auto& it: dest->GetAllStreams ())
- {
+ {
s << "";
s << "" << it->GetSendStreamID () << " | ";
s << "" << i2p::client::context.GetAddressBook ().ToAddress(it->GetRemoteIdentity ()) << " | ";
@@ -329,12 +331,12 @@ namespace http {
s << "" << (int)it->GetStatus () << " | ";
s << "
\r\n" << std::endl;
}
- }
+ }
}
void ShowLeasesSets(std::stringstream& s)
{
- s << "LeaseSets
";
+ s << "LeaseSets:
";
// for each lease set
i2p::data::netdb.VisitLeaseSets(
[&s](const i2p::data::IdentHash dest, std::shared_ptr leaseSet)
@@ -382,7 +384,7 @@ namespace http {
);
// end for each lease set
}
-
+
void ShowTunnels (std::stringstream& s)
{
s << "Queue size: " << i2p::tunnel::tunnels.GetQueueSize () << "
\r\n";
@@ -399,7 +401,7 @@ namespace http {
ShowTunnelDetails(s, it->GetState (), it->GetNumSentBytes ());
}
s << "
\r\n";
- }
+ }
void ShowCommands (std::stringstream& s)
{
@@ -409,7 +411,7 @@ namespace http {
//s << " Reload config
\r\n";
if (i2p::context.AcceptsTunnels ())
s << " Decline transit tunnels
\r\n";
- else
+ else
s << " Accept transit tunnels
\r\n";
#if (!defined(WIN32) && !defined(QT_GUI_LIB) && !defined(ANDROID))
if (Daemon.gracefullShutdownInterval)
@@ -435,11 +437,11 @@ namespace http {
for (const auto& it: i2p::tunnel::tunnels.GetTransitTunnels ())
{
if (std::dynamic_pointer_cast(it))
- s << it->GetTunnelID () << " ⇒ ";
+ s << it->GetTunnelID () << " ⇒ ";
else if (std::dynamic_pointer_cast(it))
- s << " ⇒ " << it->GetTunnelID ();
+ s << " ⇒ " << it->GetTunnelID ();
else
- s << " ⇒ " << it->GetTunnelID () << " ⇒ ";
+ s << " ⇒ " << it->GetTunnelID () << " ⇒ ";
s << " " << it->GetNumTransmittedBytes () << "
\r\n";
}
}
@@ -449,22 +451,22 @@ namespace http {
s << "Transports:
\r\n
\r\n";
auto ntcpServer = i2p::transport::transports.GetNTCPServer ();
if (ntcpServer)
- {
+ {
s << "NTCP
\r\n";
for (const auto& it: ntcpServer->GetNTCPSessions ())
{
if (it.second && it.second->IsEstablished ())
{
// incoming connection doesn't have remote RI
- if (it.second->IsOutgoing ()) s << " ⇒ ";
+ if (it.second->IsOutgoing ()) s << " ⇒ ";
s << i2p::data::GetIdentHashAbbreviation (it.second->GetRemoteIdentity ()->GetIdentHash ()) << ": "
<< it.second->GetSocket ().remote_endpoint().address ().to_string ();
- if (!it.second->IsOutgoing ()) s << " ⇒ ";
+ if (!it.second->IsOutgoing ()) s << " ⇒ ";
s << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]";
s << "
\r\n" << std::endl;
}
}
- }
+ }
auto ssuServer = i2p::transport::transports.GetSSUServer ();
if (ssuServer)
{
@@ -472,9 +474,9 @@ namespace http {
for (const auto& it: ssuServer->GetSessions ())
{
auto endpoint = it.second->GetRemoteEndpoint ();
- if (it.second->IsOutgoing ()) s << " ⇒ ";
+ if (it.second->IsOutgoing ()) s << " ⇒ ";
s << endpoint.address ().to_string () << ":" << endpoint.port ();
- if (!it.second->IsOutgoing ()) s << " ⇒ ";
+ if (!it.second->IsOutgoing ()) s << " ⇒ ";
s << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]";
if (it.second->GetRelayTag ())
s << " [itag:" << it.second->GetRelayTag () << "]";
@@ -484,15 +486,15 @@ namespace http {
for (const auto& it: ssuServer->GetSessionsV6 ())
{
auto endpoint = it.second->GetRemoteEndpoint ();
- if (it.second->IsOutgoing ()) s << " ⇒ ";
+ if (it.second->IsOutgoing ()) s << " ⇒ ";
s << endpoint.address ().to_string () << ":" << endpoint.port ();
- if (!it.second->IsOutgoing ()) s << " ⇒ ";
+ if (!it.second->IsOutgoing ()) s << " ⇒ ";
s << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]";
s << "
\r\n" << std::endl;
}
}
}
-
+
void ShowSAMSessions (std::stringstream& s)
{
auto sam = i2p::client::context.GetSAMBridge ();
@@ -505,8 +507,8 @@ namespace http {
{
s << "";
s << it.first << "
\r\n" << std::endl;
- }
- }
+ }
+ }
void ShowSAMSession (std::stringstream& s, const std::string& id)
{
@@ -537,8 +539,8 @@ namespace http {
}
s << " [" << it->GetSocket ().remote_endpoint() << "]";
s << "
\r\n";
- }
- }
+ }
+ }
void ShowI2PTunnels (std::stringstream& s)
{
@@ -547,21 +549,21 @@ namespace http {
{
auto& ident = it.second->GetLocalDestination ()->GetIdentHash();
s << "";
- s << it.second->GetName () << " ⇐ ";
+ s << it.second->GetName () << " ⇐ ";
s << i2p::client::context.GetAddressBook ().ToAddress(ident);
s << "
\r\n"<< std::endl;
- }
+ }
s << "
\r\nServer Tunnels:
\r\n
\r\n";
for (auto& it: i2p::client::context.GetServerTunnels ())
{
auto& ident = it.second->GetLocalDestination ()->GetIdentHash();
s << "";
- s << it.second->GetName () << " ⇒ ";
+ s << it.second->GetName () << " ⇒ ";
s << i2p::client::context.GetAddressBook ().ToAddress(ident);
s << ":" << it.second->GetLocalPort ();
s << "
\r\n"<< std::endl;
- }
- }
+ }
+ }
HTTPConnection::HTTPConnection (std::shared_ptr socket):
m_Socket (socket), m_Timer (socket->get_io_service ()), m_BufferLen (0)
@@ -734,7 +736,7 @@ namespace http {
Daemon.gracefullShutdownInterval = 10*60;
#endif
#ifdef WIN32_APP
- i2p::win32::GracefulShutdown ();
+ i2p::win32::GracefulShutdown ();
#endif
} else if (cmd == HTTP_COMMAND_SHUTDOWN_CANCEL) {
i2p::context.SetAcceptsTunnels (true);
@@ -752,7 +754,7 @@ namespace http {
s << "Back to commands list
\r\n";
s << "You will be redirected in 5 seconds";
res.add_header("Refresh", "5; url=/?page=commands");
- }
+ }
void HTTPConnection::SendReply (HTTPRes& reply, std::string& content)
{