|
|
|
@ -357,45 +357,47 @@ namespace util
@@ -357,45 +357,47 @@ namespace util
|
|
|
|
|
{ |
|
|
|
|
std::stringstream s; |
|
|
|
|
// Html5 head start
|
|
|
|
|
s << "<!DOCTYPE html>\n<html lang=\"en\">"; // TODO: Add support for locale.
|
|
|
|
|
s << "<head><meta charset=\"utf-8\">"; // TODO: Find something to parse html/template system. This is horrible.
|
|
|
|
|
s << "<link rel='shortcut icon' href='" + itoopieFavicon + "'>"; |
|
|
|
|
s << "<title>Purple I2P " << VERSION " Webconsole</title>"; |
|
|
|
|
s << "<style>"; |
|
|
|
|
s << "<!DOCTYPE html>\r\n<html lang=\"en\">"; // TODO: Add support for locale.
|
|
|
|
|
s << "<head>\r\n<meta charset=\"utf-8\">\r\n"; // TODO: Find something to parse html/template system. This is horrible.
|
|
|
|
|
s << "<link rel='shortcut icon' href='" + itoopieFavicon + "'>\r\n"; |
|
|
|
|
s << "<title>Purple I2P " << VERSION " Webconsole</title>\r\n"; |
|
|
|
|
s << "<style>\r\n"; |
|
|
|
|
s << "body {font: 100%/1.5em sans-serif; margin: 0; padding: 1.5em; background: #FAFAFA; color: #103456;}"; |
|
|
|
|
s << "a {text-decoration: none; color: #894C84;}"; |
|
|
|
|
s << "a:hover {color: #FAFAFA; background: #894C84;}"; |
|
|
|
|
s << ".header {font-size: 2.5em; text-align: center; margin: 1.5em 0; color: #894C84;}"; |
|
|
|
|
s << ".wrapper {margin: 0 auto; padding: 1em; max-width: 48em;}"; |
|
|
|
|
s << ".wrapper {margin: 0 auto; padding: 1em; max-width: 60em;}"; |
|
|
|
|
s << ".left {float: left; position: absolute;}"; |
|
|
|
|
s << ".right {font-size: 1em; margin-left: 13em; float: left; max-width: 34em; overflow: auto;}"; |
|
|
|
|
s << ".right {font-size: 1em; margin-left: 13em; float: left; max-width: 46em; overflow: auto;}"; |
|
|
|
|
s << ".established_tunnel {color: #56b734;}"; |
|
|
|
|
s << ".expiring_tunnel {color: #d3ae3f;}"; |
|
|
|
|
s << ".failed_tunnel {color: #d33f3f;}"; |
|
|
|
|
s << ".another_tunnel {color: #434343;}"; |
|
|
|
|
s << "</style></head><body>"; |
|
|
|
|
s << "caption {font-size: 1.5em; text-align: center; color: #894C84;}"; |
|
|
|
|
s << "table {width: 100%; border-collapse: collapse; text-align: center;}"; |
|
|
|
|
s << "</style>\r\n</head>\r\n<body>\r\n"; |
|
|
|
|
s << "<div class=header><b>i2pd </b>webconsole</div>"; |
|
|
|
|
s << "<div class=wrapper>"; |
|
|
|
|
s << "<div class=left>"; |
|
|
|
|
s << "<a href=/>Main page</a><br><br>"; |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_LOCAL_DESTINATIONS << ">Local destinations</a><br>"; |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_TUNNELS << ">Tunnels</a><br>"; |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_TRANSIT_TUNNELS << ">Transit tunnels</a><br>"; |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_TRANSPORTS << ">Transports</a><br><br>"; |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_I2P_TUNNELS << ">I2P tunnels</a><br>"; |
|
|
|
|
s << "<div class=left>\r\n"; |
|
|
|
|
s << "<a href=/>Main page</a><br>\r\n<br>\r\n"; |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_LOCAL_DESTINATIONS << ">Local destinations</a><br>\r\n"; |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_TUNNELS << ">Tunnels</a><br>\r\n"; |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_TRANSIT_TUNNELS << ">Transit tunnels</a><br>\r\n"; |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_TRANSPORTS << ">Transports</a><br>\r\n<br>\r\n"; |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_I2P_TUNNELS << ">I2P tunnels</a><br>\r\n"; |
|
|
|
|
if (i2p::client::context.GetSAMBridge ()) |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_SAM_SESSIONS << ">SAM sessions</a><br><br>"; |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_SAM_SESSIONS << ">SAM sessions</a><br>\r\n<br>\r\n"; |
|
|
|
|
if (i2p::context.AcceptsTunnels ()) |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_STOP_ACCEPTING_TUNNELS << ">Stop accepting tunnels</a><br><br>"; |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_STOP_ACCEPTING_TUNNELS << ">Stop accepting tunnels</a><br>\r\n<br>\r\n"; |
|
|
|
|
else |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_START_ACCEPTING_TUNNELS << ">Start accepting tunnels</a><br><br>"; |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_RUN_PEER_TEST << ">Run peer test</a><br><br>"; |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_START_ACCEPTING_TUNNELS << ">Start accepting tunnels</a><br>\r\n<br>\r\n"; |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_RUN_PEER_TEST << ">Run peer test</a><br>\r\n<br>\r\n"; |
|
|
|
|
s << "</div><div class=right>"; |
|
|
|
|
if (address.length () > 1) |
|
|
|
|
HandleCommand (address.substr (2), s); |
|
|
|
|
else |
|
|
|
|
FillContent (s); |
|
|
|
|
s << "</div></div></body></html>"; |
|
|
|
|
s << "</div></div>\r\n</body>\r\n</html>"; |
|
|
|
|
SendReply (s.str ()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -403,7 +405,7 @@ namespace util
@@ -403,7 +405,7 @@ namespace util
|
|
|
|
|
{ |
|
|
|
|
s << "<b>Uptime:</b> " << boost::posix_time::to_simple_string ( |
|
|
|
|
boost::posix_time::time_duration (boost::posix_time::seconds ( |
|
|
|
|
i2p::context.GetUptime ()))) << "<br>"; |
|
|
|
|
i2p::context.GetUptime ()))) << "<br>\r\n"; |
|
|
|
|
s << "<b>Status:</b> "; |
|
|
|
|
switch (i2p::context.GetStatus ()) |
|
|
|
|
{ |
|
|
|
@ -412,14 +414,14 @@ namespace util
@@ -412,14 +414,14 @@ namespace util
|
|
|
|
|
case eRouterStatusFirewalled: s << "Firewalled"; break; |
|
|
|
|
default: s << "Unknown"; |
|
|
|
|
} |
|
|
|
|
s << "<br>"; |
|
|
|
|
s << "<b>Tunnel creation success rate:</b> " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%<br>"; |
|
|
|
|
s << "<br>\r\n"; |
|
|
|
|
s << "<b>Tunnel creation success rate:</b> " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%<br>\r\n"; |
|
|
|
|
s << "<b>Received:</b> " << i2p::transport::transports.GetTotalReceivedBytes ()/1000 << "K"; |
|
|
|
|
s << " (" << i2p::transport::transports.GetInBandwidth () <<" Bps)<br>"; |
|
|
|
|
s << " (" << i2p::transport::transports.GetInBandwidth () <<" Bps)<br>\r\n"; |
|
|
|
|
s << "<b>Sent:</b> " << i2p::transport::transports.GetTotalSentBytes ()/1000 << "K"; |
|
|
|
|
s << " (" << i2p::transport::transports.GetOutBandwidth () <<" Bps)<br>"; |
|
|
|
|
s << "<b>Data path:</b> " << i2p::util::filesystem::GetDataDir().string() << "<br><br>"; |
|
|
|
|
s << "<b>Our external address:</b>" << "<br>" ; |
|
|
|
|
s << " (" << i2p::transport::transports.GetOutBandwidth () <<" Bps)<br>\r\n"; |
|
|
|
|
s << "<b>Data path:</b> " << i2p::util::filesystem::GetDataDir().string() << "<br>\r\n<br>\r\n"; |
|
|
|
|
s << "<b>Our external address:</b>" << "<br>\r\n" ; |
|
|
|
|
for (auto& address : i2p::context.GetRouterInfo().GetAddresses()) |
|
|
|
|
{ |
|
|
|
|
switch (address.transportStyle) |
|
|
|
@ -439,11 +441,11 @@ namespace util
@@ -439,11 +441,11 @@ namespace util
|
|
|
|
|
default: |
|
|
|
|
s << "Unknown "; |
|
|
|
|
} |
|
|
|
|
s << address.host.to_string() << ":" << address.port << "<br>"; |
|
|
|
|
s << address.host.to_string() << ":" << address.port << "<br>\r\n"; |
|
|
|
|
} |
|
|
|
|
s << "<br><b>Routers:</b> " << i2p::data::netdb.GetNumRouters () << " "; |
|
|
|
|
s << "<br>\r\n<b>Routers:</b> " << i2p::data::netdb.GetNumRouters () << " "; |
|
|
|
|
s << "<b>Floodfills:</b> " << i2p::data::netdb.GetNumFloodfills () << " "; |
|
|
|
|
s << "<b>LeaseSets:</b> " << i2p::data::netdb.GetNumLeaseSets () << "<br>"; |
|
|
|
|
s << "<b>LeaseSets:</b> " << i2p::data::netdb.GetNumLeaseSets () << "<br>\r\n"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void HTTPConnection::HandleCommand (const std::string& command, std::stringstream& s) |
|
|
|
@ -486,30 +488,31 @@ namespace util
@@ -486,30 +488,31 @@ namespace util
|
|
|
|
|
|
|
|
|
|
void HTTPConnection::ShowLocalDestinations (std::stringstream& s) |
|
|
|
|
{ |
|
|
|
|
s << "<b>Local Destinations:</b><br><br>"; |
|
|
|
|
s << "<b>Local Destinations:</b><br>\r\n<br>\r\n"; |
|
|
|
|
for (auto& it: i2p::client::context.GetDestinations ()) |
|
|
|
|
{ |
|
|
|
|
auto ident = it.second->GetIdentHash ();; |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_LOCAL_DESTINATION; |
|
|
|
|
s << "&" << HTTP_PARAM_BASE32_ADDRESS << "=" << ident.ToBase32 () << ">"; |
|
|
|
|
s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "</a><br>" << std::endl; |
|
|
|
|
s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "</a><br>\r\n" << std::endl; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void HTTPConnection::ShowLocalDestination (const std::string& b32, std::stringstream& s) |
|
|
|
|
{ |
|
|
|
|
s << "<b>Local Destination:</b><br><br>"; |
|
|
|
|
s << "<b>Local Destination:</b><br>\r\n<br>\r\n"; |
|
|
|
|
i2p::data::IdentHash ident; |
|
|
|
|
ident.FromBase32 (b32); |
|
|
|
|
auto dest = i2p::client::context.FindLocalDestination (ident); |
|
|
|
|
if (dest) |
|
|
|
|
{ |
|
|
|
|
s << "<b>Base64:</b><br>" << dest->GetIdentity ()->ToBase64 () << "<br><br>"; |
|
|
|
|
s << "<b>LeaseSets:</b> <i>" << dest->GetNumRemoteLeaseSets () << "</i><br>"; |
|
|
|
|
s << "<b>Base64:</b><br>\r\n<textarea readonly=\"readonly\" cols=\"64\" rows=\"1\" wrap=\"off\">"; |
|
|
|
|
s << dest->GetIdentity ()->ToBase64 () << "</textarea><br>\r\n<br>\r\n"; |
|
|
|
|
s << "<b>LeaseSets:</b> <i>" << dest->GetNumRemoteLeaseSets () << "</i><br>\r\n"; |
|
|
|
|
auto pool = dest->GetTunnelPool (); |
|
|
|
|
if (pool) |
|
|
|
|
{ |
|
|
|
|
s << "<b>Tunnels:</b><br>"; |
|
|
|
|
s << "<b>Tunnels:</b><br>\r\n"; |
|
|
|
|
for (auto it: pool->GetOutboundTunnels ()) |
|
|
|
|
{ |
|
|
|
|
it->Print (s); |
|
|
|
@ -518,7 +521,7 @@ namespace util
@@ -518,7 +521,7 @@ namespace util
|
|
|
|
|
s << " " << "Failed"; |
|
|
|
|
else if (state == i2p::tunnel::eTunnelStateExpiring) |
|
|
|
|
s << " " << "Exp"; |
|
|
|
|
s << "<br>" << std::endl; |
|
|
|
|
s << "<br>\r\n" << std::endl; |
|
|
|
|
} |
|
|
|
|
for (auto it: pool->GetInboundTunnels ()) |
|
|
|
|
{ |
|
|
|
@ -528,28 +531,56 @@ namespace util
@@ -528,28 +531,56 @@ namespace util
|
|
|
|
|
s << " " << "Failed"; |
|
|
|
|
else if (state == i2p::tunnel::eTunnelStateExpiring) |
|
|
|
|
s << " " << "Exp"; |
|
|
|
|
s << "<br>" << std::endl; |
|
|
|
|
s << "<br>\r\n" << std::endl; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
s << "<br><b>Streams:</b><br>"; |
|
|
|
|
// s << "<br>\r\n<b>Streams:</b><br>\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 () << "]";
|
|
|
|
|
// s << "[buf:" << it.second->GetSendBufferSize () << "]";
|
|
|
|
|
// s << "[RTT:" << it.second->GetRTT () << "]";
|
|
|
|
|
// s << "[Window:" << it.second->GetWindowSize () << "]";
|
|
|
|
|
// s << "[Status:" << (int)it.second->GetStatus () << "]";
|
|
|
|
|
// s << "<br>\r\n"<< std::endl;
|
|
|
|
|
// }
|
|
|
|
|
s << "<br>\r\n<table><caption>Streams</caption><tr>"; |
|
|
|
|
s << "<th>StreamID</th>"; |
|
|
|
|
s << "<th>Destination</th>"; |
|
|
|
|
s << "<th>Sent</th>"; |
|
|
|
|
s << "<th>Received</th>"; |
|
|
|
|
s << "<th>Out</th>"; |
|
|
|
|
s << "<th>In</th>"; |
|
|
|
|
s << "<th>Buf</th>"; |
|
|
|
|
s << "<th>RTT</th>"; |
|
|
|
|
s << "<th>Window</th>"; |
|
|
|
|
s << "<th>Status</th>"; |
|
|
|
|
s << "</tr>"; |
|
|
|
|
|
|
|
|
|
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 () << "]"; |
|
|
|
|
s << "[buf:" << it.second->GetSendBufferSize () << "]"; |
|
|
|
|
s << "[RTT:" << it.second->GetRTT () << "]"; |
|
|
|
|
s << "[Window:" << it.second->GetWindowSize () << "]"; |
|
|
|
|
s << "[Status:" << (int)it.second->GetStatus () << "]"; |
|
|
|
|
s << "<br>"<< std::endl; |
|
|
|
|
} |
|
|
|
|
s << "<tr>"; |
|
|
|
|
s << "<td>" << it.first << "</td>"; |
|
|
|
|
s << "<td>" << i2p::client::context.GetAddressBook ().ToAddress(it.second->GetRemoteIdentity ()) << "</td>"; |
|
|
|
|
s << "<td>" << it.second->GetNumSentBytes () << "</td>"; |
|
|
|
|
s << "<td>" << it.second->GetNumReceivedBytes () << "</td>"; |
|
|
|
|
s << "<td>" << it.second->GetSendQueueSize () << "</td>"; |
|
|
|
|
s << "<td>" << it.second->GetReceiveQueueSize () << "</td>"; |
|
|
|
|
s << "<td>" << it.second->GetSendBufferSize () << "</td>"; |
|
|
|
|
s << "<td>" << it.second->GetRTT () << "</td>"; |
|
|
|
|
s << "<td>" << it.second->GetWindowSize () << "</td>"; |
|
|
|
|
s << "<td>" << (int)it.second->GetStatus () << "</td>"; |
|
|
|
|
s << "</tr><br>\r\n" << std::endl; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void HTTPConnection::ShowTunnels (std::stringstream& s) |
|
|
|
|
{ |
|
|
|
|
s << "<b>Tunnels:</b><br><br>"; |
|
|
|
|
s << "<b>Queue size:</b>" << i2p::tunnel::tunnels.GetQueueSize () << "<br>"; |
|
|
|
|
s << "<b>Tunnels:</b><br>\r\n<br>\r\n"; |
|
|
|
|
s << "<b>Queue size:</b> " << i2p::tunnel::tunnels.GetQueueSize () << "<br>\r\n"; |
|
|
|
|
for (auto it: i2p::tunnel::tunnels.GetOutboundTunnels ()) |
|
|
|
|
{ |
|
|
|
|
it->Print (s); |
|
|
|
@ -558,7 +589,7 @@ namespace util
@@ -558,7 +589,7 @@ namespace util
|
|
|
|
|
s << "<span class=failed_tunnel> " << "Failed</span>"; |
|
|
|
|
else if (state == i2p::tunnel::eTunnelStateExpiring) |
|
|
|
|
s << "<span class=expiring_tunnel> " << "Exp</span>"; |
|
|
|
|
s << " " << (int)it->GetNumSentBytes () << "<br>"; |
|
|
|
|
s << " " << (int)it->GetNumSentBytes () << "<br>\r\n"; |
|
|
|
|
s << std::endl; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -570,78 +601,78 @@ namespace util
@@ -570,78 +601,78 @@ namespace util
|
|
|
|
|
s << "<span class=failed_tunnel> " << "Failed</span>"; |
|
|
|
|
else if (state == i2p::tunnel::eTunnelStateExpiring) |
|
|
|
|
s << "<span class=expiring_tunnel> " << "Exp</span>"; |
|
|
|
|
s << " " << (int)it.second->GetNumReceivedBytes () << "<br>"; |
|
|
|
|
s << " " << (int)it.second->GetNumReceivedBytes () << "<br>\r\n"; |
|
|
|
|
s << std::endl; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void HTTPConnection::ShowTransitTunnels (std::stringstream& s) |
|
|
|
|
{ |
|
|
|
|
s << "<b>Transit tunnels:</b><br><br>"; |
|
|
|
|
s << "<b>Transit tunnels:</b><br>\r\n<br>\r\n"; |
|
|
|
|
for (auto it: i2p::tunnel::tunnels.GetTransitTunnels ()) |
|
|
|
|
{ |
|
|
|
|
if (dynamic_cast<i2p::tunnel::TransitTunnelGateway *>(it.second)) |
|
|
|
|
s << it.second->GetTunnelID () << "-->"; |
|
|
|
|
s << it.second->GetTunnelID () << " ⇒ "; |
|
|
|
|
else if (dynamic_cast<i2p::tunnel::TransitTunnelEndpoint *>(it.second)) |
|
|
|
|
s << "-->" << it.second->GetTunnelID (); |
|
|
|
|
s << " ⇒ " << it.second->GetTunnelID (); |
|
|
|
|
else |
|
|
|
|
s << "-->" << it.second->GetTunnelID () << "-->"; |
|
|
|
|
s << " " << it.second->GetNumTransmittedBytes () << "<br>"; |
|
|
|
|
s << " ⇒ " << it.second->GetTunnelID () << " ⇒ "; |
|
|
|
|
s << " " << it.second->GetNumTransmittedBytes () << "<br>\r\n"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void HTTPConnection::ShowTransports (std::stringstream& s) |
|
|
|
|
{ |
|
|
|
|
s << "<b>Transports:</b><br><br>"; |
|
|
|
|
s << "<b>Transports:</b><br>\r\n<br>\r\n"; |
|
|
|
|
auto ntcpServer = i2p::transport::transports.GetNTCPServer (); |
|
|
|
|
if (ntcpServer) |
|
|
|
|
{ |
|
|
|
|
s << "<b>NTCP</b><br>"; |
|
|
|
|
s << "<b>NTCP</b><br>\r\n"; |
|
|
|
|
for (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 << "<br>" << std::endl; |
|
|
|
|
s << "<br>\r\n" << std::endl; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
auto ssuServer = i2p::transport::transports.GetSSUServer (); |
|
|
|
|
if (ssuServer) |
|
|
|
|
{ |
|
|
|
|
s << "<br><b>SSU</b><br>"; |
|
|
|
|
s << "<br>\r\n<b>SSU</b><br>\r\n"; |
|
|
|
|
for (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 () << "]"; |
|
|
|
|
s << "<br>" << std::endl; |
|
|
|
|
s << "<br>\r\n" << std::endl; |
|
|
|
|
} |
|
|
|
|
s << "<br><b>SSU6</b><br>"; |
|
|
|
|
s << "<br>\r\n<b>SSU6</b><br>\r\n"; |
|
|
|
|
for (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 << "<br>" << std::endl; |
|
|
|
|
s << "<br>\r\n" << std::endl; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void HTTPConnection::ShowSAMSessions (std::stringstream& s) |
|
|
|
|
{ |
|
|
|
|
s << "<b>SAM Sessions:</b><br><br>"; |
|
|
|
|
s << "<b>SAM Sessions:</b><br>\r\n<br>\r\n"; |
|
|
|
|
auto sam = i2p::client::context.GetSAMBridge (); |
|
|
|
|
if (sam) |
|
|
|
|
{ |
|
|
|
@ -649,14 +680,14 @@ namespace util
@@ -649,14 +680,14 @@ namespace util
|
|
|
|
|
{ |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_SAM_SESSION; |
|
|
|
|
s << "&" << HTTP_PARAM_SAM_SESSION_ID << "=" << it.first << ">"; |
|
|
|
|
s << it.first << "</a><br>" << std::endl; |
|
|
|
|
s << it.first << "</a><br>\r\n" << std::endl; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void HTTPConnection::ShowSAMSession (const std::string& id, std::stringstream& s) |
|
|
|
|
{ |
|
|
|
|
s << "<b>SAM Session:</b><br><br>"; |
|
|
|
|
s << "<b>SAM Session:</b><br>\r\n<br>\r\n"; |
|
|
|
|
auto sam = i2p::client::context.GetSAMBridge (); |
|
|
|
|
if (sam) |
|
|
|
|
{ |
|
|
|
@ -666,8 +697,8 @@ namespace util
@@ -666,8 +697,8 @@ namespace util
|
|
|
|
|
auto& ident = session->localDestination->GetIdentHash(); |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_LOCAL_DESTINATION; |
|
|
|
|
s << "&" << HTTP_PARAM_BASE32_ADDRESS << "=" << ident.ToBase32 () << ">"; |
|
|
|
|
s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "</a><br>" << std::endl; |
|
|
|
|
s << "<b>Streams:</b><br>"; |
|
|
|
|
s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "</a><br>\r\n" << std::endl; |
|
|
|
|
s << "<b>Streams:</b><br>\r\n"; |
|
|
|
|
for (auto it: session->sockets) |
|
|
|
|
{ |
|
|
|
|
switch (it->GetSocketType ()) |
|
|
|
@ -685,7 +716,7 @@ namespace util
@@ -685,7 +716,7 @@ namespace util
|
|
|
|
|
s << "unknown"; |
|
|
|
|
} |
|
|
|
|
s << " [" << it->GetSocket ().remote_endpoint() << "]"; |
|
|
|
|
s << "<br>" << std::endl; |
|
|
|
|
s << "<br>\r\n" << std::endl; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -693,45 +724,46 @@ namespace util
@@ -693,45 +724,46 @@ namespace util
|
|
|
|
|
|
|
|
|
|
void HTTPConnection::ShowI2PTunnels (std::stringstream& s) |
|
|
|
|
{ |
|
|
|
|
s << "<b>Client Tunnels:</b><br><br>"; |
|
|
|
|
s << "<b>Client Tunnels:</b><br>\r\n<br>\r\n"; |
|
|
|
|
for (auto& it: i2p::client::context.GetClientTunnels ()) |
|
|
|
|
{ |
|
|
|
|
s << it.second->GetName () << "<--"; |
|
|
|
|
s << it.second->GetName () << " ⇐ "; |
|
|
|
|
auto& ident = it.second->GetLocalDestination ()->GetIdentHash(); |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_LOCAL_DESTINATION; |
|
|
|
|
s << "&" << HTTP_PARAM_BASE32_ADDRESS << "=" << ident.ToBase32 () << ">"; |
|
|
|
|
s << i2p::client::context.GetAddressBook ().ToAddress(ident); |
|
|
|
|
s << "</a><br>"<< std::endl; |
|
|
|
|
s << "</a><br>\r\n"<< std::endl; |
|
|
|
|
} |
|
|
|
|
s << "<br><b>Server Tunnels:</b><br><br>"; |
|
|
|
|
s << "<br>\r\n<b>Server Tunnels:</b><br>\r\n<br>\r\n"; |
|
|
|
|
for (auto& it: i2p::client::context.GetServerTunnels ()) |
|
|
|
|
{ |
|
|
|
|
s << it.second->GetName () << "-->"; |
|
|
|
|
s << it.second->GetName () << " ⇒ "; |
|
|
|
|
auto& ident = it.second->GetLocalDestination ()->GetIdentHash(); |
|
|
|
|
s << "<a href=/?" << HTTP_COMMAND_LOCAL_DESTINATION; |
|
|
|
|
s << "&" << HTTP_PARAM_BASE32_ADDRESS << "=" << ident.ToBase32 () << ">"; |
|
|
|
|
s << i2p::client::context.GetAddressBook ().ToAddress(ident); |
|
|
|
|
s << "</a><br>"<< std::endl; |
|
|
|
|
s << ":" << it.second->GetLocalPort (); |
|
|
|
|
s << "</a><br>\r\n"<< std::endl; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void HTTPConnection::StopAcceptingTunnels (std::stringstream& s) |
|
|
|
|
{ |
|
|
|
|
s << "<b>Stop Accepting Tunnels:</b><br><br>"; |
|
|
|
|
s << "<b>Stop Accepting Tunnels:</b><br>\r\n<br>\r\n"; |
|
|
|
|
i2p::context.SetAcceptsTunnels (false); |
|
|
|
|
s << "Accepting tunnels stopped" << std::endl; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void HTTPConnection::StartAcceptingTunnels (std::stringstream& s) |
|
|
|
|
{ |
|
|
|
|
s << "<b>Start Accepting Tunnels:</b><br><br>"; |
|
|
|
|
s << "<b>Start Accepting Tunnels:</b><br>\r\n<br>\r\n"; |
|
|
|
|
i2p::context.SetAcceptsTunnels (true); |
|
|
|
|
s << "Accepting tunnels started" << std::endl; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void HTTPConnection::RunPeerTest (std::stringstream& s) |
|
|
|
|
{ |
|
|
|
|
s << "<b>Run Peer Test:</b><br><br>"; |
|
|
|
|
s << "<b>Run Peer Test:</b><br>\r\n<br>\r\n"; |
|
|
|
|
i2p::transport::transports.PeerTest (); |
|
|
|
|
s << "Peer test is running" << std::endl; |
|
|
|
|
} |
|
|
|
@ -739,7 +771,7 @@ namespace util
@@ -739,7 +771,7 @@ namespace util
|
|
|
|
|
void HTTPConnection::HandleDestinationRequest (const std::string& address, const std::string& uri) |
|
|
|
|
{ |
|
|
|
|
std::string request = "GET " + uri + " HTTP/1.1\r\nHost:" + address + "\r\n\r\n"; |
|
|
|
|
LogPrint(eLogDebug, "HTTPServer: client request: ", request); |
|
|
|
|
LogPrint(eLogInfo, "HTTPServer: client request: ", request); |
|
|
|
|
SendToAddress (address, 80, request.c_str (), request.size ()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -749,7 +781,7 @@ namespace util
@@ -749,7 +781,7 @@ namespace util
|
|
|
|
|
if (!i2p::client::context.GetAddressBook ().GetIdentHash (address, destination)) |
|
|
|
|
{ |
|
|
|
|
LogPrint (eLogWarning, "HTTPServer: Unknown address ", address); |
|
|
|
|
SendReply ("<html>" + itoopieImage + "<br>Unknown address " + address + "</html>", 404); |
|
|
|
|
SendReply ("<html>" + itoopieImage + "<br>\r\nUnknown address " + address + "</html>", 404); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -777,7 +809,7 @@ namespace util
@@ -777,7 +809,7 @@ namespace util
|
|
|
|
|
SendToDestination (leaseSet, port, buf, len); |
|
|
|
|
else |
|
|
|
|
// still no LeaseSet
|
|
|
|
|
SendReply (leaseSet ? "<html>" + itoopieImage + "<br>Leases expired</html>" : "<html>" + itoopieImage + "LeaseSet not found</html>", 504); |
|
|
|
|
SendReply (leaseSet ? "<html>" + itoopieImage + "<br>\r\nLeases expired</html>" : "<html>" + itoopieImage + "LeaseSet not found</html>", 504); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -811,7 +843,7 @@ namespace util
@@ -811,7 +843,7 @@ namespace util
|
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (ecode == boost::asio::error::timed_out) |
|
|
|
|
SendReply ("<html>" + itoopieImage + "<br>Not responding</html>", 504); |
|
|
|
|
SendReply ("<html>" + itoopieImage + "<br>\r\nNot responding</html>", 504); |
|
|
|
|
else if (ecode != boost::asio::error::operation_aborted) |
|
|
|
|
Terminate (); |
|
|
|
|
} |
|
|
|
@ -898,3 +930,4 @@ namespace util
@@ -898,3 +930,4 @@ namespace util
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|