diff --git a/HTTPServer.cpp b/HTTPServer.cpp index 3a16ff6f..bb3e2819 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -357,45 +357,47 @@ namespace util { std::stringstream s; // Html5 head start - s << "\n"; // TODO: Add support for locale. - s << ""; // TODO: Find something to parse html/template system. This is horrible. - s << ""; - s << "Purple I2P " << VERSION " Webconsole"; - s << ""; + s << "caption {font-size: 1.5em; text-align: center; color: #894C84;}"; + s << "table {width: 100%; border-collapse: collapse; text-align: center;}"; + s << "\r\n\r\n\r\n"; s << "
i2pd webconsole
"; s << "
"; - s << "
"; - s << "Main page

"; - s << "Local destinations
"; - s << "Tunnels
"; - s << "Transit tunnels
"; - s << "Transports

"; - s << "I2P tunnels
"; + s << "
\r\n"; + s << "Main page
\r\n
\r\n"; + s << "Local destinations
\r\n"; + s << "Tunnels
\r\n"; + s << "Transit tunnels
\r\n"; + s << "Transports
\r\n
\r\n"; + s << "I2P tunnels
\r\n"; if (i2p::client::context.GetSAMBridge ()) - s << "SAM sessions

"; + s << "SAM sessions
\r\n
\r\n"; if (i2p::context.AcceptsTunnels ()) - s << "Stop accepting tunnels

"; + s << "Stop accepting tunnels
\r\n
\r\n"; else - s << "Start accepting tunnels

"; - s << "Run peer test

"; + s << "Start accepting tunnels
\r\n
\r\n"; + s << "Run peer test
\r\n
\r\n"; s << "
"; if (address.length () > 1) HandleCommand (address.substr (2), s); else FillContent (s); - s << "
"; + s << "
\r\n\r\n"; SendReply (s.str ()); } @@ -403,7 +405,7 @@ namespace util { s << "Uptime: " << boost::posix_time::to_simple_string ( boost::posix_time::time_duration (boost::posix_time::seconds ( - i2p::context.GetUptime ()))) << "
"; + i2p::context.GetUptime ()))) << "
\r\n"; s << "Status: "; switch (i2p::context.GetStatus ()) { @@ -412,14 +414,14 @@ namespace util case eRouterStatusFirewalled: s << "Firewalled"; break; default: s << "Unknown"; } - s << "
"; - s << "Tunnel creation success rate: " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%
"; + s << "
\r\n"; + s << "Tunnel creation success rate: " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%
\r\n"; s << "Received: " << i2p::transport::transports.GetTotalReceivedBytes ()/1000 << "K"; - s << " (" << i2p::transport::transports.GetInBandwidth () <<" Bps)
"; + s << " (" << i2p::transport::transports.GetInBandwidth () <<" Bps)
\r\n"; s << "Sent: " << i2p::transport::transports.GetTotalSentBytes ()/1000 << "K"; - s << " (" << i2p::transport::transports.GetOutBandwidth () <<" Bps)
"; - s << "Data path: " << i2p::util::filesystem::GetDataDir().string() << "

"; - s << "Our external address:" << "
" ; + s << " (" << i2p::transport::transports.GetOutBandwidth () <<" Bps)
\r\n"; + s << "Data path: " << i2p::util::filesystem::GetDataDir().string() << "
\r\n
\r\n"; + s << "Our external address:" << "
\r\n" ; for (auto& address : i2p::context.GetRouterInfo().GetAddresses()) { switch (address.transportStyle) @@ -439,11 +441,11 @@ namespace util default: s << "Unknown  "; } - s << address.host.to_string() << ":" << address.port << "
"; + s << address.host.to_string() << ":" << address.port << "
\r\n"; } - s << "
Routers: " << i2p::data::netdb.GetNumRouters () << " "; + s << "
\r\nRouters: " << i2p::data::netdb.GetNumRouters () << " "; s << "Floodfills: " << i2p::data::netdb.GetNumFloodfills () << " "; - s << "LeaseSets: " << i2p::data::netdb.GetNumLeaseSets () << "
"; + s << "LeaseSets: " << i2p::data::netdb.GetNumLeaseSets () << "
\r\n"; } void HTTPConnection::HandleCommand (const std::string& command, std::stringstream& s) @@ -486,30 +488,31 @@ namespace util void HTTPConnection::ShowLocalDestinations (std::stringstream& s) { - s << "Local Destinations:

"; + s << "Local Destinations:
\r\n
\r\n"; for (auto& it: i2p::client::context.GetDestinations ()) { auto ident = it.second->GetIdentHash ();; s << ""; - s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "
" << std::endl; + s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "
\r\n" << std::endl; } } void HTTPConnection::ShowLocalDestination (const std::string& b32, std::stringstream& s) { - s << "Local Destination:

"; + s << "Local Destination:
\r\n
\r\n"; i2p::data::IdentHash ident; ident.FromBase32 (b32); auto dest = i2p::client::context.FindLocalDestination (ident); if (dest) { - s << "Base64:
" << dest->GetIdentity ()->ToBase64 () << "

"; - s << "LeaseSets: " << dest->GetNumRemoteLeaseSets () << "
"; + s << "Base64:
\r\n
\r\n
\r\n"; + s << "LeaseSets: " << dest->GetNumRemoteLeaseSets () << "
\r\n"; auto pool = dest->GetTunnelPool (); if (pool) { - s << "Tunnels:
"; + s << "Tunnels:
\r\n"; for (auto it: pool->GetOutboundTunnels ()) { it->Print (s); @@ -518,7 +521,7 @@ namespace util s << " " << "Failed"; else if (state == i2p::tunnel::eTunnelStateExpiring) s << " " << "Exp"; - s << "
" << std::endl; + s << "
\r\n" << std::endl; } for (auto it: pool->GetInboundTunnels ()) { @@ -528,28 +531,56 @@ namespace util s << " " << "Failed"; else if (state == i2p::tunnel::eTunnelStateExpiring) s << " " << "Exp"; - s << "
" << std::endl; + s << "
\r\n" << std::endl; } } - s << "
Streams:
"; + // s << "
\r\nStreams:
\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 << "
\r\n"<< std::endl; + // } + s << "
\r\n"; + s << ""; + s << ""; + s << ""; + s << ""; + s << ""; + s << ""; + s << ""; + s << ""; + s << ""; + s << ""; + s << ""; + 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 << "
"<< std::endl; - } + s << ""; + s << ""; + s << ""; + s << ""; + s << ""; + s << ""; + s << ""; + s << ""; + s << ""; + s << ""; + s << ""; + s << "
\r\n" << std::endl; + } } } void HTTPConnection::ShowTunnels (std::stringstream& s) { - s << "Tunnels:

"; - s << "Queue size:" << i2p::tunnel::tunnels.GetQueueSize () << "
"; + s << "Tunnels:
\r\n
\r\n"; + s << "Queue size:" << i2p::tunnel::tunnels.GetQueueSize () << "
\r\n"; for (auto it: i2p::tunnel::tunnels.GetOutboundTunnels ()) { it->Print (s); @@ -558,7 +589,7 @@ namespace util s << " " << "Failed"; else if (state == i2p::tunnel::eTunnelStateExpiring) s << " " << "Exp"; - s << " " << (int)it->GetNumSentBytes () << "
"; + s << " " << (int)it->GetNumSentBytes () << "
\r\n"; s << std::endl; } @@ -570,78 +601,78 @@ namespace util s << " " << "Failed"; else if (state == i2p::tunnel::eTunnelStateExpiring) s << " " << "Exp"; - s << " " << (int)it.second->GetNumReceivedBytes () << "
"; + s << " " << (int)it.second->GetNumReceivedBytes () << "
\r\n"; s << std::endl; } } void HTTPConnection::ShowTransitTunnels (std::stringstream& s) { - s << "Transit tunnels:

"; + s << "Transit tunnels:
\r\n
\r\n"; for (auto it: i2p::tunnel::tunnels.GetTransitTunnels ()) { if (dynamic_cast(it.second)) - s << it.second->GetTunnelID () << "-->"; + s << it.second->GetTunnelID () << " ⇒ "; else if (dynamic_cast(it.second)) - s << "-->" << it.second->GetTunnelID (); + s << " ⇒ " << it.second->GetTunnelID (); else - s << "-->" << it.second->GetTunnelID () << "-->"; - s << " " << it.second->GetNumTransmittedBytes () << "
"; + s << " ⇒ " << it.second->GetTunnelID () << " ⇒ "; + s << " " << it.second->GetNumTransmittedBytes () << "
\r\n"; } } void HTTPConnection::ShowTransports (std::stringstream& s) { - s << "Transports:

"; + s << "Transports:
\r\n
\r\n"; auto ntcpServer = i2p::transport::transports.GetNTCPServer (); if (ntcpServer) { - s << "NTCP
"; + s << "NTCP
\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 << "
" << std::endl; + s << "
\r\n" << std::endl; } } } auto ssuServer = i2p::transport::transports.GetSSUServer (); if (ssuServer) { - s << "
SSU
"; + s << "
\r\nSSU
\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 << "
" << std::endl; + s << "
\r\n" << std::endl; } - s << "
SSU6
"; + s << "
\r\nSSU6
\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 << "
" << std::endl; + s << "
\r\n" << std::endl; } } } void HTTPConnection::ShowSAMSessions (std::stringstream& s) { - s << "SAM Sessions:

"; + s << "SAM Sessions:
\r\n
\r\n"; auto sam = i2p::client::context.GetSAMBridge (); if (sam) { @@ -649,14 +680,14 @@ namespace util { s << ""; - s << it.first << "
" << std::endl; + s << it.first << "
\r\n" << std::endl; } } } void HTTPConnection::ShowSAMSession (const std::string& id, std::stringstream& s) { - s << "SAM Session:

"; + s << "SAM Session:
\r\n
\r\n"; auto sam = i2p::client::context.GetSAMBridge (); if (sam) { @@ -666,8 +697,8 @@ namespace util auto& ident = session->localDestination->GetIdentHash(); s << ""; - s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "
" << std::endl; - s << "Streams:
"; + s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "
\r\n" << std::endl; + s << "Streams:
\r\n"; for (auto it: session->sockets) { switch (it->GetSocketType ()) @@ -685,7 +716,7 @@ namespace util s << "unknown"; } s << " [" << it->GetSocket ().remote_endpoint() << "]"; - s << "
" << std::endl; + s << "
\r\n" << std::endl; } } } @@ -693,45 +724,45 @@ namespace util void HTTPConnection::ShowI2PTunnels (std::stringstream& s) { - s << "Client Tunnels:

"; + s << "Client Tunnels:
\r\n
\r\n"; for (auto& it: i2p::client::context.GetClientTunnels ()) { - s << it.second->GetName () << "<--"; + s << it.second->GetName () << " ⇐ "; auto& ident = it.second->GetLocalDestination ()->GetIdentHash(); s << ""; s << i2p::client::context.GetAddressBook ().ToAddress(ident); - s << "
"<< std::endl; + s << "
\r\n"<< std::endl; } - s << "
Server Tunnels:

"; + s << "
\r\nServer Tunnels:
\r\n
\r\n"; for (auto& it: i2p::client::context.GetServerTunnels ()) { - s << it.second->GetName () << "-->"; + s << it.second->GetName () << " ⇒ "; auto& ident = it.second->GetLocalDestination ()->GetIdentHash(); s << ""; s << i2p::client::context.GetAddressBook ().ToAddress(ident); - s << "
"<< std::endl; + s << "
\r\n"<< std::endl; } } void HTTPConnection::StopAcceptingTunnels (std::stringstream& s) { - s << "Stop Accepting Tunnels:

"; + s << "Stop Accepting Tunnels:
\r\n
\r\n"; i2p::context.SetAcceptsTunnels (false); s << "Accepting tunnels stopped" << std::endl; } void HTTPConnection::StartAcceptingTunnels (std::stringstream& s) { - s << "Start Accepting Tunnels:

"; + s << "Start Accepting Tunnels:
\r\n
\r\n"; i2p::context.SetAcceptsTunnels (true); s << "Accepting tunnels started" << std::endl; } void HTTPConnection::RunPeerTest (std::stringstream& s) { - s << "Run Peer Test:

"; + s << "Run Peer Test:
\r\n
\r\n"; i2p::transport::transports.PeerTest (); s << "Peer test is running" << std::endl; } @@ -749,7 +780,7 @@ namespace util if (!i2p::client::context.GetAddressBook ().GetIdentHash (address, destination)) { LogPrint (eLogWarning, "HTTPServer: Unknown address ", address); - SendReply ("" + itoopieImage + "
Unknown address " + address + "", 404); + SendReply ("" + itoopieImage + "
\r\nUnknown address " + address + "", 404); return; } @@ -777,7 +808,7 @@ namespace util SendToDestination (leaseSet, port, buf, len); else // still no LeaseSet - SendReply (leaseSet ? "" + itoopieImage + "
Leases expired" : "" + itoopieImage + "LeaseSet not found", 504); + SendReply (leaseSet ? "" + itoopieImage + "
\r\nLeases expired" : "" + itoopieImage + "LeaseSet not found", 504); } } @@ -811,7 +842,7 @@ namespace util else { if (ecode == boost::asio::error::timed_out) - SendReply ("" + itoopieImage + "
Not responding", 504); + SendReply ("" + itoopieImage + "
\r\nNot responding", 504); else if (ecode != boost::asio::error::operation_aborted) Terminate (); } @@ -898,3 +929,4 @@ namespace util } + diff --git a/Tunnel.cpp b/Tunnel.cpp index 7a91adca..3391fbc8 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -186,7 +186,7 @@ namespace tunnel { for (auto& it: m_Hops) { - s << "-->"; + s << " ⇒ "; s << i2p::data::GetIdentHashAbbreviation (it->ident->GetIdentHash ()); } } @@ -203,7 +203,7 @@ namespace tunnel void InboundTunnel::Print (std::stringstream& s) const { PrintHops (s); - s << "-->" << GetTunnelID () << ":me"; + s << " ⇒ " << GetTunnelID () << ":me"; } void OutboundTunnel::SendTunnelDataMsg (const uint8_t * gwHash, uint32_t gwTunnel, std::shared_ptr msg) @@ -245,7 +245,7 @@ namespace tunnel { s << GetTunnelID () << ":me"; PrintHops (s); - s << "-->"; + s << " ⇒ "; } Tunnels tunnels; @@ -787,3 +787,4 @@ namespace tunnel } } } +
Streams
StreamIDDestinationSentReceivedOutInBufRTTWindowStatus
" << it.first << "" << i2p::client::context.GetAddressBook ().ToAddress(it.second->GetRemoteIdentity ()) << "" << it.second->GetNumSentBytes () << "" << it.second->GetNumReceivedBytes () << "" << it.second->GetSendQueueSize () << "" << it.second->GetReceiveQueueSize () << "" << it.second->GetSendBufferSize () << "" << it.second->GetRTT () << "" << it.second->GetWindowSize () << "" << (int)it.second->GetStatus () << "