MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / ShowLocalDestination

Function ShowLocalDestination

daemon/HTTPServer.cpp:631–688  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

629 }
630
631 void ShowLocalDestination (std::stringstream& s, const std::string& b32, uint32_t token)
632 {
633 std::string webroot; i2p::config::GetOption("http.webroot", webroot);
634 s << "<b>" << tr("Local Destination") << ":</b><br>\r\n<br>\r\n";
635 i2p::data::IdentHash ident;
636 ident.FromBase32 (b32);
637 auto dest = i2p::client::context.FindLocalDestination (ident);
638
639 if (dest)
640 {
641 ShowLeaseSetDestination (s, dest, token);
642
643 // Print table with streams information
644 s << "<table>\r\n<caption>" << tr("Streams") << "</caption>\r\n"
645 << "<thead><tr>"
646 << "<th style=\"width:25px;\">StreamID</th>"
647 << "<th style=\"width:5px;\">&nbsp;</th>" // Stream closing button column
648 << "<th class=\"streamdest\">Destination</th>"
649 << "<th>Sent</th>"
650 << "<th>Received</th>"
651 << "<th>Out</th>"
652 << "<th>In</th>"
653 << "<th>Buf</th>"
654 << "<th>RTT</th>"
655 << "<th>Window</th>"
656 << "<th>Status</th>"
657 << "</tr></thead>\r\n"
658 << "<tbody class=\"tableitem\">\r\n";
659
660 for (const auto& it: dest->GetAllStreams ())
661 {
662 auto streamDest = i2p::client::context.GetAddressBook ().ToAddress(it->GetRemoteIdentity ());
663 std::string streamDestShort = streamDest.substr(0,12) + "&hellip;.b32.i2p";
664 s << "<tr>";
665 s << "<td>" << it->GetRecvStreamID () << "</td>";
666 if (it->GetRecvStreamID ()) {
667 s << "<td><a class=\"button\" href=\"" << webroot << "?cmd=" << HTTP_COMMAND_KILLSTREAM << "&b32=" << b32 << "&streamID="
668 << it->GetRecvStreamID () << "&token=" << token << "\" title=\"" << tr("Close stream") << "\"> &#10008; </a></td>";
669 }
670 else {
671 s << "<td> !! FIXME !! </td>"; // TODO: FIXME: Undefined HTML code
672 }
673 s << "<td class=\"streamdest\" title=\"" << streamDest << "\">" << streamDestShort << "</td>";
674 s << "<td>" << it->GetNumSentBytes () << "</td>";
675 s << "<td>" << it->GetNumReceivedBytes () << "</td>";
676 s << "<td>" << it->GetSendQueueSize () << "</td>";
677 s << "<td>" << it->GetReceiveQueueSize () << "</td>";
678 s << "<td>" << it->GetSendBufferSize () << "</td>";
679 s << "<td>" << it->GetRTT () << "</td>";
680 s << "<td>" << it->GetWindowSize () << "</td>";
681 s << "<td>" << (int)it->GetStatus () << "</td>";
682 s << "</tr>\r\n";
683 }
684 s << "</tbody>\r\n</table>\r\n<br>\r\n";
685 }
686 else
687 ShowError(s, tr("Such destination is not found"));
688 }

Callers 1

HandlePageMethod · 0.85

Calls 15

GetOptionFunction · 0.85
trFunction · 0.85
ShowLeaseSetDestinationFunction · 0.85
ShowErrorFunction · 0.85
FindLocalDestinationMethod · 0.80
GetAllStreamsMethod · 0.80
ToAddressMethod · 0.80
GetRecvStreamIDMethod · 0.80
GetReceiveQueueSizeMethod · 0.80
GetSendBufferSizeMethod · 0.80
GetRTTMethod · 0.80
GetWindowSizeMethod · 0.80

Tested by

no test coverage detected