| 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;\"> </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) + "….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") << "\"> ✘ </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 | } |
no test coverage detected