| 923 | |
| 924 | template<typename Sessions> |
| 925 | static void ShowTransportSessions (std::stringstream& s, const Sessions& sessions, const std::string name) |
| 926 | { |
| 927 | auto comp = [](typename Sessions::mapped_type a, typename Sessions::mapped_type b) |
| 928 | { return a->GetRemoteEndpoint() < b->GetRemoteEndpoint(); }; |
| 929 | std::set<typename Sessions::mapped_type, decltype(comp)> sortedSessions(comp); |
| 930 | for (const auto& it : sessions) |
| 931 | { |
| 932 | auto ret = sortedSessions.insert(it.second); |
| 933 | if (!ret.second) |
| 934 | LogPrint(eLogError, "HTTPServer: Duplicate remote endpoint detected: ", (*ret.first)->GetRemoteEndpoint()); |
| 935 | } |
| 936 | std::stringstream tmp_s, tmp_s6; uint16_t cnt = 0, cnt6 = 0; |
| 937 | for (const auto& it: sortedSessions) |
| 938 | { |
| 939 | auto endpoint = it->GetRemoteEndpoint (); |
| 940 | if (it && it->IsEstablished () && endpoint.address ().is_v4 ()) |
| 941 | { |
| 942 | tmp_s << "<div class=\"listitem\">\r\n"; |
| 943 | if (it->IsOutgoing ()) tmp_s << " ⇒ "; |
| 944 | else tmp_s << " "; |
| 945 | tmp_s << i2p::data::GetIdentHashAbbreviation (it->GetRemoteIdentity ()->GetIdentHash ()) << ": " |
| 946 | << endpoint.address ().to_string () << ":" << endpoint.port (); |
| 947 | if (!it->IsOutgoing ()) tmp_s << " ⇒ "; |
| 948 | else tmp_s << " "; |
| 949 | tmp_s << " [" << it->GetNumSentBytes () << ":" << it->GetNumReceivedBytes () << "]"; |
| 950 | if (it->GetRelayTag ()) |
| 951 | tmp_s << " [itag:" << it->GetRelayTag () << "]"; |
| 952 | if (it->GetSendQueueSize () > 0) |
| 953 | tmp_s << " [queue:" << it->GetSendQueueSize () << "]"; |
| 954 | if (it->IsSlow ()) tmp_s << " [slow]"; |
| 955 | if (it->GetVersion () > 2) tmp_s << " [pq=" << (int)it->GetVersion () << "]"; |
| 956 | tmp_s << "</div>\r\n" << std::endl; |
| 957 | cnt++; |
| 958 | } |
| 959 | if (it && it->IsEstablished () && endpoint.address ().is_v6 ()) |
| 960 | { |
| 961 | tmp_s6 << "<div class=\"listitem\">\r\n"; |
| 962 | if (it->IsOutgoing ()) tmp_s6 << " ⇒ "; |
| 963 | else tmp_s6 << " "; |
| 964 | tmp_s6 << i2p::data::GetIdentHashAbbreviation (it->GetRemoteIdentity ()->GetIdentHash ()) << ": " |
| 965 | << "[" << endpoint.address ().to_string () << "]:" << endpoint.port (); |
| 966 | if (!it->IsOutgoing ()) tmp_s6 << " ⇒ "; |
| 967 | else tmp_s6 << " "; |
| 968 | tmp_s6 << " [" << it->GetNumSentBytes () << ":" << it->GetNumReceivedBytes () << "]"; |
| 969 | if (it->GetRelayTag ()) |
| 970 | tmp_s6 << " [itag:" << it->GetRelayTag () << "]"; |
| 971 | if (it->GetSendQueueSize () > 0) |
| 972 | tmp_s6 << " [queue:" << it->GetSendQueueSize () << "]"; |
| 973 | if (it->IsSlow ()) tmp_s6 << " [slow]"; |
| 974 | if (it->GetVersion () > 2) tmp_s6 << " [pq=" << (int)it->GetVersion () << "]"; |
| 975 | tmp_s6 << "</div>\r\n" << std::endl; |
| 976 | cnt6++; |
| 977 | } |
| 978 | } |
| 979 | if (!tmp_s.str ().empty ()) |
| 980 | { |
| 981 | s << "<div class='slide'><label for='slide_" << boost::algorithm::to_lower_copy(name) << "'><b>" << name |
| 982 | << "</b> ( " << cnt << " )</label>\r\n" |
no test coverage detected