|
|
@ -357,45 +357,47 @@ namespace util |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::stringstream s; |
|
|
|
std::stringstream s; |
|
|
|
// Html5 head start
|
|
|
|
// Html5 head start
|
|
|
|
s << "<!DOCTYPE html>\n<html lang=\"en\">"; // TODO: Add support for locale.
|
|
|
|
s << "<!DOCTYPE html>\r\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 << "<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 + "'>"; |
|
|
|
s << "<link rel='shortcut icon' href='" + itoopieFavicon + "'>\r\n"; |
|
|
|
s << "<title>Purple I2P " << VERSION " Webconsole</title>"; |
|
|
|
s << "<title>Purple I2P " << VERSION " Webconsole</title>\r\n"; |
|
|
|
s << "<style>"; |
|
|
|
s << "<style>\r\n"; |
|
|
|
s << "body {font: 100%/1.5em sans-serif; margin: 0; padding: 1.5em; background: #FAFAFA; color: #103456;}"; |
|
|
|
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 {text-decoration: none; color: #894C84;}"; |
|
|
|
s << "a:hover {color: #FAFAFA; background: #894C84;}"; |
|
|
|
s << "a:hover {color: #FAFAFA; background: #894C84;}"; |
|
|
|
s << ".header {font-size: 2.5em; text-align: center; margin: 1.5em 0; color: #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 << ".left {float: left; position: absolute;}"; |
|
|
|
s << ".right {font-size: 1em; margin-left: 13em; float: left; max-width: 34em; word-break: break-all;}"; |
|
|
|
s << ".right {font-size: 1em; margin-left: 13em; float: left; max-width: 46em; overflow: auto;}"; |
|
|
|
s << ".established_tunnel {color: #56b734;}"; |
|
|
|
s << ".established_tunnel {color: #56b734;}"; |
|
|
|
s << ".expiring_tunnel {color: #d3ae3f;}"; |
|
|
|
s << ".expiring_tunnel {color: #d3ae3f;}"; |
|
|
|
s << ".failed_tunnel {color: #d33f3f;}"; |
|
|
|
s << ".failed_tunnel {color: #d33f3f;}"; |
|
|
|
s << ".another_tunnel {color: #434343;}"; |
|
|
|
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=header><b>i2pd </b>webconsole</div>"; |
|
|
|
s << "<div class=wrapper>"; |
|
|
|
s << "<div class=wrapper>"; |
|
|
|
s << "<div class=left>"; |
|
|
|
s << "<div class=left>\r\n"; |
|
|
|
s << "<a href=/>Main page</a><br><br>"; |
|
|
|
s << "<a href=/>Main page</a><br>\r\n<br>\r\n"; |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_LOCAL_DESTINATIONS << ">Local destinations</a><br>"; |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_LOCAL_DESTINATIONS << ">Local destinations</a><br>\r\n"; |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_TUNNELS << ">Tunnels</a><br>"; |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_TUNNELS << ">Tunnels</a><br>\r\n"; |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_TRANSIT_TUNNELS << ">Transit tunnels</a><br>"; |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_TRANSIT_TUNNELS << ">Transit tunnels</a><br>\r\n"; |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_TRANSPORTS << ">Transports</a><br><br>"; |
|
|
|
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>"; |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_I2P_TUNNELS << ">I2P tunnels</a><br>\r\n"; |
|
|
|
if (i2p::client::context.GetSAMBridge ()) |
|
|
|
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 ()) |
|
|
|
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 |
|
|
|
else |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_START_ACCEPTING_TUNNELS << ">Start accepting tunnels</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><br>"; |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_RUN_PEER_TEST << ">Run peer test</a><br>\r\n<br>\r\n"; |
|
|
|
s << "</div><div class=right>"; |
|
|
|
s << "</div><div class=right>"; |
|
|
|
if (address.length () > 1) |
|
|
|
if (address.length () > 1) |
|
|
|
HandleCommand (address.substr (2), s); |
|
|
|
HandleCommand (address.substr (2), s); |
|
|
|
else |
|
|
|
else |
|
|
|
FillContent (s); |
|
|
|
FillContent (s); |
|
|
|
s << "</div></div></body></html>"; |
|
|
|
s << "</div></div>\r\n</body>\r\n</html>"; |
|
|
|
SendReply (s.str ()); |
|
|
|
SendReply (s.str ()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -403,7 +405,7 @@ namespace util |
|
|
|
{ |
|
|
|
{ |
|
|
|
s << "<b>Uptime:</b> " << boost::posix_time::to_simple_string ( |
|
|
|
s << "<b>Uptime:</b> " << boost::posix_time::to_simple_string ( |
|
|
|
boost::posix_time::time_duration (boost::posix_time::seconds ( |
|
|
|
boost::posix_time::time_duration (boost::posix_time::seconds ( |
|
|
|
i2p::context.GetUptime ()))) << "<br>"; |
|
|
|
i2p::context.GetUptime ()))) << "<br>\r\n"; |
|
|
|
s << "<b>Status:</b> "; |
|
|
|
s << "<b>Status:</b> "; |
|
|
|
switch (i2p::context.GetStatus ()) |
|
|
|
switch (i2p::context.GetStatus ()) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -412,14 +414,14 @@ namespace util |
|
|
|
case eRouterStatusFirewalled: s << "Firewalled"; break; |
|
|
|
case eRouterStatusFirewalled: s << "Firewalled"; break; |
|
|
|
default: s << "Unknown"; |
|
|
|
default: s << "Unknown"; |
|
|
|
} |
|
|
|
} |
|
|
|
s << "<br>"; |
|
|
|
s << "<br>\r\n"; |
|
|
|
s << "<b>Tunnel creation success rate:</b> " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%<br>"; |
|
|
|
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 << "<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 << "<b>Sent:</b> " << i2p::transport::transports.GetTotalSentBytes ()/1000 << "K"; |
|
|
|
s << " (" << i2p::transport::transports.GetOutBandwidth () <<" Bps)<br>"; |
|
|
|
s << " (" << i2p::transport::transports.GetOutBandwidth () <<" Bps)<br>\r\n"; |
|
|
|
s << "<b>Data path:</b> " << i2p::util::filesystem::GetDataDir().string() << "<br><br>"; |
|
|
|
s << "<b>Data path:</b> " << i2p::util::filesystem::GetDataDir().string() << "<br>\r\n<br>\r\n"; |
|
|
|
s << "<b>Our external address:</b>" << "<br>" ; |
|
|
|
s << "<b>Our external address:</b>" << "<br>\r\n" ; |
|
|
|
for (auto& address : i2p::context.GetRouterInfo().GetAddresses()) |
|
|
|
for (auto& address : i2p::context.GetRouterInfo().GetAddresses()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
switch (address.transportStyle) |
|
|
|
switch (address.transportStyle) |
|
|
@ -439,11 +441,11 @@ namespace util |
|
|
|
default: |
|
|
|
default: |
|
|
|
s << "Unknown "; |
|
|
|
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>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) |
|
|
|
void HTTPConnection::HandleCommand (const std::string& command, std::stringstream& s) |
|
|
@ -486,30 +488,31 @@ namespace util |
|
|
|
|
|
|
|
|
|
|
|
void HTTPConnection::ShowLocalDestinations (std::stringstream& s) |
|
|
|
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 ()) |
|
|
|
for (auto& it: i2p::client::context.GetDestinations ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto ident = it.second->GetIdentHash ();; |
|
|
|
auto ident = it.second->GetIdentHash ();; |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_LOCAL_DESTINATION; |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_LOCAL_DESTINATION; |
|
|
|
s << "&" << HTTP_PARAM_BASE32_ADDRESS << "=" << ident.ToBase32 () << ">"; |
|
|
|
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) |
|
|
|
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; |
|
|
|
i2p::data::IdentHash ident; |
|
|
|
ident.FromBase32 (b32); |
|
|
|
ident.FromBase32 (b32); |
|
|
|
auto dest = i2p::client::context.FindLocalDestination (ident); |
|
|
|
auto dest = i2p::client::context.FindLocalDestination (ident); |
|
|
|
if (dest) |
|
|
|
if (dest) |
|
|
|
{ |
|
|
|
{ |
|
|
|
s << "<b>Base64:</b><br>" << dest->GetIdentity ()->ToBase64 () << "<br><br>"; |
|
|
|
s << "<b>Base64:</b><br>\r\n<textarea readonly=\"readonly\" cols=\"64\" rows=\"1\" wrap=\"off\">"; |
|
|
|
s << "<b>LeaseSets:</b> <i>" << dest->GetNumRemoteLeaseSets () << "</i><br>"; |
|
|
|
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 (); |
|
|
|
auto pool = dest->GetTunnelPool (); |
|
|
|
if (pool) |
|
|
|
if (pool) |
|
|
|
{ |
|
|
|
{ |
|
|
|
s << "<b>Tunnels:</b><br>"; |
|
|
|
s << "<b>Tunnels:</b><br>\r\n"; |
|
|
|
for (auto it: pool->GetOutboundTunnels ()) |
|
|
|
for (auto it: pool->GetOutboundTunnels ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
it->Print (s); |
|
|
|
it->Print (s); |
|
|
@ -518,7 +521,7 @@ namespace util |
|
|
|
s << " " << "Failed"; |
|
|
|
s << " " << "Failed"; |
|
|
|
else if (state == i2p::tunnel::eTunnelStateExpiring) |
|
|
|
else if (state == i2p::tunnel::eTunnelStateExpiring) |
|
|
|
s << " " << "Exp"; |
|
|
|
s << " " << "Exp"; |
|
|
|
s << "<br>" << std::endl; |
|
|
|
s << "<br>\r\n" << std::endl; |
|
|
|
} |
|
|
|
} |
|
|
|
for (auto it: pool->GetInboundTunnels ()) |
|
|
|
for (auto it: pool->GetInboundTunnels ()) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -528,28 +531,56 @@ namespace util |
|
|
|
s << " " << "Failed"; |
|
|
|
s << " " << "Failed"; |
|
|
|
else if (state == i2p::tunnel::eTunnelStateExpiring) |
|
|
|
else if (state == i2p::tunnel::eTunnelStateExpiring) |
|
|
|
s << " " << "Exp"; |
|
|
|
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 ()) |
|
|
|
for (auto it: dest->GetStreamingDestination ()->GetStreams ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
s << it.first << "->" << i2p::client::context.GetAddressBook ().ToAddress(it.second->GetRemoteIdentity ()) << " "; |
|
|
|
s << "<tr>"; |
|
|
|
s << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]"; |
|
|
|
s << "<td>" << it.first << "</td>"; |
|
|
|
s << " [out:" << it.second->GetSendQueueSize () << "][in:" << it.second->GetReceiveQueueSize () << "]"; |
|
|
|
s << "<td>" << i2p::client::context.GetAddressBook ().ToAddress(it.second->GetRemoteIdentity ()) << "</td>"; |
|
|
|
s << "[buf:" << it.second->GetSendBufferSize () << "]"; |
|
|
|
s << "<td>" << it.second->GetNumSentBytes () << "</td>"; |
|
|
|
s << "[RTT:" << it.second->GetRTT () << "]"; |
|
|
|
s << "<td>" << it.second->GetNumReceivedBytes () << "</td>"; |
|
|
|
s << "[Window:" << it.second->GetWindowSize () << "]"; |
|
|
|
s << "<td>" << it.second->GetSendQueueSize () << "</td>"; |
|
|
|
s << "[Status:" << (int)it.second->GetStatus () << "]"; |
|
|
|
s << "<td>" << it.second->GetReceiveQueueSize () << "</td>"; |
|
|
|
s << "<br>"<< std::endl; |
|
|
|
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) |
|
|
|
void HTTPConnection::ShowTunnels (std::stringstream& s) |
|
|
|
{ |
|
|
|
{ |
|
|
|
s << "<b>Tunnels:</b><br><br>"; |
|
|
|
s << "<b>Tunnels:</b><br>\r\n<br>\r\n"; |
|
|
|
s << "<b>Queue size:</b>" << i2p::tunnel::tunnels.GetQueueSize () << "<br>"; |
|
|
|
s << "<b>Queue size:</b>" << i2p::tunnel::tunnels.GetQueueSize () << "<br>\r\n"; |
|
|
|
for (auto it: i2p::tunnel::tunnels.GetOutboundTunnels ()) |
|
|
|
for (auto it: i2p::tunnel::tunnels.GetOutboundTunnels ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
it->Print (s); |
|
|
|
it->Print (s); |
|
|
@ -558,7 +589,7 @@ namespace util |
|
|
|
s << "<span class=failed_tunnel> " << "Failed</span>"; |
|
|
|
s << "<span class=failed_tunnel> " << "Failed</span>"; |
|
|
|
else if (state == i2p::tunnel::eTunnelStateExpiring) |
|
|
|
else if (state == i2p::tunnel::eTunnelStateExpiring) |
|
|
|
s << "<span class=expiring_tunnel> " << "Exp</span>"; |
|
|
|
s << "<span class=expiring_tunnel> " << "Exp</span>"; |
|
|
|
s << " " << (int)it->GetNumSentBytes () << "<br>"; |
|
|
|
s << " " << (int)it->GetNumSentBytes () << "<br>\r\n"; |
|
|
|
s << std::endl; |
|
|
|
s << std::endl; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -570,78 +601,78 @@ namespace util |
|
|
|
s << "<span class=failed_tunnel> " << "Failed</span>"; |
|
|
|
s << "<span class=failed_tunnel> " << "Failed</span>"; |
|
|
|
else if (state == i2p::tunnel::eTunnelStateExpiring) |
|
|
|
else if (state == i2p::tunnel::eTunnelStateExpiring) |
|
|
|
s << "<span class=expiring_tunnel> " << "Exp</span>"; |
|
|
|
s << "<span class=expiring_tunnel> " << "Exp</span>"; |
|
|
|
s << " " << (int)it.second->GetNumReceivedBytes () << "<br>"; |
|
|
|
s << " " << (int)it.second->GetNumReceivedBytes () << "<br>\r\n"; |
|
|
|
s << std::endl; |
|
|
|
s << std::endl; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void HTTPConnection::ShowTransitTunnels (std::stringstream& s) |
|
|
|
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 ()) |
|
|
|
for (auto it: i2p::tunnel::tunnels.GetTransitTunnels ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (dynamic_cast<i2p::tunnel::TransitTunnelGateway *>(it.second)) |
|
|
|
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)) |
|
|
|
else if (dynamic_cast<i2p::tunnel::TransitTunnelEndpoint *>(it.second)) |
|
|
|
s << "-->" << it.second->GetTunnelID (); |
|
|
|
s << " ⇒ " << it.second->GetTunnelID (); |
|
|
|
else |
|
|
|
else |
|
|
|
s << "-->" << it.second->GetTunnelID () << "-->"; |
|
|
|
s << " ⇒ " << it.second->GetTunnelID () << " ⇒ "; |
|
|
|
s << " " << it.second->GetNumTransmittedBytes () << "<br>"; |
|
|
|
s << " " << it.second->GetNumTransmittedBytes () << "<br>\r\n"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void HTTPConnection::ShowTransports (std::stringstream& s) |
|
|
|
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 (); |
|
|
|
auto ntcpServer = i2p::transport::transports.GetNTCPServer (); |
|
|
|
if (ntcpServer) |
|
|
|
if (ntcpServer) |
|
|
|
{ |
|
|
|
{ |
|
|
|
s << "<b>NTCP</b><br>"; |
|
|
|
s << "<b>NTCP</b><br>\r\n"; |
|
|
|
for (auto it: ntcpServer->GetNTCPSessions ()) |
|
|
|
for (auto it: ntcpServer->GetNTCPSessions ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (it.second && it.second->IsEstablished ()) |
|
|
|
if (it.second && it.second->IsEstablished ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// incoming connection doesn't have remote RI
|
|
|
|
// 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 ()) << ": " |
|
|
|
s << i2p::data::GetIdentHashAbbreviation (it.second->GetRemoteIdentity ()->GetIdentHash ()) << ": " |
|
|
|
<< it.second->GetSocket ().remote_endpoint().address ().to_string (); |
|
|
|
<< 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 << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]"; |
|
|
|
s << "<br>" << std::endl; |
|
|
|
s << "<br>\r\n" << std::endl; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
auto ssuServer = i2p::transport::transports.GetSSUServer (); |
|
|
|
auto ssuServer = i2p::transport::transports.GetSSUServer (); |
|
|
|
if (ssuServer) |
|
|
|
if (ssuServer) |
|
|
|
{ |
|
|
|
{ |
|
|
|
s << "<br><b>SSU</b><br>"; |
|
|
|
s << "<br>\r\n<b>SSU</b><br>\r\n"; |
|
|
|
for (auto it: ssuServer->GetSessions ()) |
|
|
|
for (auto it: ssuServer->GetSessions ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto endpoint = it.second->GetRemoteEndpoint (); |
|
|
|
auto endpoint = it.second->GetRemoteEndpoint (); |
|
|
|
if (it.second->IsOutgoing ()) s << "-->"; |
|
|
|
if (it.second->IsOutgoing ()) s << " ⇒ "; |
|
|
|
s << endpoint.address ().to_string () << ":" << endpoint.port (); |
|
|
|
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 << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]"; |
|
|
|
if (it.second->GetRelayTag ()) |
|
|
|
if (it.second->GetRelayTag ()) |
|
|
|
s << " [itag:" << 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 ()) |
|
|
|
for (auto it: ssuServer->GetSessionsV6 ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto endpoint = it.second->GetRemoteEndpoint (); |
|
|
|
auto endpoint = it.second->GetRemoteEndpoint (); |
|
|
|
if (it.second->IsOutgoing ()) s << "-->"; |
|
|
|
if (it.second->IsOutgoing ()) s << " ⇒ "; |
|
|
|
s << endpoint.address ().to_string () << ":" << endpoint.port (); |
|
|
|
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 << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]"; |
|
|
|
s << "<br>" << std::endl; |
|
|
|
s << "<br>\r\n" << std::endl; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void HTTPConnection::ShowSAMSessions (std::stringstream& s) |
|
|
|
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 (); |
|
|
|
auto sam = i2p::client::context.GetSAMBridge (); |
|
|
|
if (sam) |
|
|
|
if (sam) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -649,14 +680,14 @@ namespace util |
|
|
|
{ |
|
|
|
{ |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_SAM_SESSION; |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_SAM_SESSION; |
|
|
|
s << "&" << HTTP_PARAM_SAM_SESSION_ID << "=" << it.first << ">"; |
|
|
|
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) |
|
|
|
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 (); |
|
|
|
auto sam = i2p::client::context.GetSAMBridge (); |
|
|
|
if (sam) |
|
|
|
if (sam) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -666,8 +697,8 @@ namespace util |
|
|
|
auto& ident = session->localDestination->GetIdentHash(); |
|
|
|
auto& ident = session->localDestination->GetIdentHash(); |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_LOCAL_DESTINATION; |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_LOCAL_DESTINATION; |
|
|
|
s << "&" << HTTP_PARAM_BASE32_ADDRESS << "=" << ident.ToBase32 () << ">"; |
|
|
|
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; |
|
|
|
s << "<b>Streams:</b><br>"; |
|
|
|
s << "<b>Streams:</b><br>\r\n"; |
|
|
|
for (auto it: session->sockets) |
|
|
|
for (auto it: session->sockets) |
|
|
|
{ |
|
|
|
{ |
|
|
|
switch (it->GetSocketType ()) |
|
|
|
switch (it->GetSocketType ()) |
|
|
@ -685,7 +716,7 @@ namespace util |
|
|
|
s << "unknown"; |
|
|
|
s << "unknown"; |
|
|
|
} |
|
|
|
} |
|
|
|
s << " [" << it->GetSocket ().remote_endpoint() << "]"; |
|
|
|
s << " [" << it->GetSocket ().remote_endpoint() << "]"; |
|
|
|
s << "<br>" << std::endl; |
|
|
|
s << "<br>\r\n" << std::endl; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -693,45 +724,45 @@ namespace util |
|
|
|
|
|
|
|
|
|
|
|
void HTTPConnection::ShowI2PTunnels (std::stringstream& s) |
|
|
|
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 ()) |
|
|
|
for (auto& it: i2p::client::context.GetClientTunnels ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
s << it.second->GetName () << "<--"; |
|
|
|
s << it.second->GetName () << " ⇐ "; |
|
|
|
auto& ident = it.second->GetLocalDestination ()->GetIdentHash(); |
|
|
|
auto& ident = it.second->GetLocalDestination ()->GetIdentHash(); |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_LOCAL_DESTINATION; |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_LOCAL_DESTINATION; |
|
|
|
s << "&" << HTTP_PARAM_BASE32_ADDRESS << "=" << ident.ToBase32 () << ">"; |
|
|
|
s << "&" << HTTP_PARAM_BASE32_ADDRESS << "=" << ident.ToBase32 () << ">"; |
|
|
|
s << i2p::client::context.GetAddressBook ().ToAddress(ident); |
|
|
|
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 ()) |
|
|
|
for (auto& it: i2p::client::context.GetServerTunnels ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
s << it.second->GetName () << "-->"; |
|
|
|
s << it.second->GetName () << " ⇒ "; |
|
|
|
auto& ident = it.second->GetLocalDestination ()->GetIdentHash(); |
|
|
|
auto& ident = it.second->GetLocalDestination ()->GetIdentHash(); |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_LOCAL_DESTINATION; |
|
|
|
s << "<a href=/?" << HTTP_COMMAND_LOCAL_DESTINATION; |
|
|
|
s << "&" << HTTP_PARAM_BASE32_ADDRESS << "=" << ident.ToBase32 () << ">"; |
|
|
|
s << "&" << HTTP_PARAM_BASE32_ADDRESS << "=" << ident.ToBase32 () << ">"; |
|
|
|
s << i2p::client::context.GetAddressBook ().ToAddress(ident); |
|
|
|
s << i2p::client::context.GetAddressBook ().ToAddress(ident); |
|
|
|
s << "</a><br>"<< std::endl; |
|
|
|
s << "</a><br>\r\n"<< std::endl; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void HTTPConnection::StopAcceptingTunnels (std::stringstream& s) |
|
|
|
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); |
|
|
|
i2p::context.SetAcceptsTunnels (false); |
|
|
|
s << "Accepting tunnels stopped" << std::endl; |
|
|
|
s << "Accepting tunnels stopped" << std::endl; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void HTTPConnection::StartAcceptingTunnels (std::stringstream& s) |
|
|
|
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); |
|
|
|
i2p::context.SetAcceptsTunnels (true); |
|
|
|
s << "Accepting tunnels started" << std::endl; |
|
|
|
s << "Accepting tunnels started" << std::endl; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void HTTPConnection::RunPeerTest (std::stringstream& s) |
|
|
|
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 (); |
|
|
|
i2p::transport::transports.PeerTest (); |
|
|
|
s << "Peer test is running" << std::endl; |
|
|
|
s << "Peer test is running" << std::endl; |
|
|
|
} |
|
|
|
} |
|
|
@ -749,7 +780,7 @@ namespace util |
|
|
|
if (!i2p::client::context.GetAddressBook ().GetIdentHash (address, destination)) |
|
|
|
if (!i2p::client::context.GetAddressBook ().GetIdentHash (address, destination)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogWarning, "HTTPServer: Unknown address ", address); |
|
|
|
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; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -777,7 +808,7 @@ namespace util |
|
|
|
SendToDestination (leaseSet, port, buf, len); |
|
|
|
SendToDestination (leaseSet, port, buf, len); |
|
|
|
else |
|
|
|
else |
|
|
|
// still no LeaseSet
|
|
|
|
// 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 +842,7 @@ namespace util |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (ecode == boost::asio::error::timed_out) |
|
|
|
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) |
|
|
|
else if (ecode != boost::asio::error::operation_aborted) |
|
|
|
Terminate (); |
|
|
|
Terminate (); |
|
|
|
} |
|
|
|
} |
|
|
@ -898,3 +929,4 @@ namespace util |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|