use shared pointer for RouterInfo's addreses list

This commit is contained in:
orignal 2022-12-04 19:21:51 -05:00
parent 6a743f66e8
commit 410d2c2fa9
6 changed files with 156 additions and 108 deletions

View file

@ -299,44 +299,49 @@ namespace http {
if ((outputFormat == OutputFormatEnum::forWebConsole) || !includeHiddenContent) {
s << "<label for=\"slide-info\">" << tr("Hidden content. Press on text to see.") << "</label>\r\n<input type=\"checkbox\" id=\"slide-info\" />\r\n<div class=\"slidecontent\">\r\n";
}
if (includeHiddenContent) {
if (includeHiddenContent)
{
s << "<b>" << tr("Router Ident") << ":</b> " << i2p::context.GetRouterInfo().GetIdentHashBase64() << "<br>\r\n";
if (!i2p::context.GetRouterInfo().GetProperty("family").empty())
s << "<b>" << tr("Router Family") << ":</b> " << i2p::context.GetRouterInfo().GetProperty("family") << "<br>\r\n";
s << "<b>" << tr("Router Caps") << ":</b> " << i2p::context.GetRouterInfo().GetProperty("caps") << "<br>\r\n";
s << "<b>" << tr("Version") << ":</b> " VERSION "<br>\r\n";
s << "<b>"<< tr("Our external address") << ":</b>" << "<br>\r\n<table class=\"extaddr\"><tbody>\r\n";
for (const auto& address : i2p::context.GetRouterInfo().GetAddresses())
{
s << "<tr>\r\n<td>";
switch (address->transportStyle)
auto addresses = i2p::context.GetRouterInfo().GetAddresses ();
if (addresses)
{
for (const auto& address : *addresses)
{
case i2p::data::RouterInfo::eTransportNTCP2:
s << "NTCP2";
break;
case i2p::data::RouterInfo::eTransportSSU2:
s << "SSU2";
break;
default:
s << tr("Unknown");
}
if (address->IsV6 ())
{
if (address->IsV4 ()) s << "v4";
s << "v6";
}
s << "</td>\r\n";
if (address->published)
s << "<td>" << address->host.to_string() << ":" << address->port << "</td>\r\n";
else
{
s << "<td>" << tr("supported");
if (address->port)
s << " :" << address->port;
s << "<tr>\r\n<td>";
switch (address->transportStyle)
{
case i2p::data::RouterInfo::eTransportNTCP2:
s << "NTCP2";
break;
case i2p::data::RouterInfo::eTransportSSU2:
s << "SSU2";
break;
default:
s << tr("Unknown");
}
if (address->IsV6 ())
{
if (address->IsV4 ()) s << "v4";
s << "v6";
}
s << "</td>\r\n";
if (address->published)
s << "<td>" << address->host.to_string() << ":" << address->port << "</td>\r\n";
else
{
s << "<td>" << tr("supported");
if (address->port)
s << " :" << address->port;
s << "</td>\r\n";
}
s << "</tr>\r\n";
}
s << "</tr>\r\n";
}
}
s << "</tbody></table>\r\n";
}
s << "</div>\r\n</div>\r\n";