Browse Source

Merge pull request #2017 from Vort/show_bw_caps

show bandwidth caps for hops
pull/2094/head
orignal 5 months ago committed by GitHub
parent
commit
3a4833aa67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 25
      daemon/HTTPServer.cpp
  2. 7
      libi2pd/RouterInfo.cpp
  3. 2
      libi2pd/RouterInfo.h

25
daemon/HTTPServer.cpp

@ -417,6 +417,15 @@ namespace http { @@ -417,6 +417,15 @@ namespace http {
}
}
static void ShowHop(std::stringstream& s, const i2p::data::IdentityEx& ident)
{
auto identHash = ident.GetIdentHash();
auto router = i2p::data::netdb.FindRouter(identHash);
s << i2p::data::GetIdentHashAbbreviation(identHash);
if (router)
s << "<small style=\"color:gray\"> " << router->GetBandwidthCap() << "</small>";
}
static void ShowLeaseSetDestination (std::stringstream& s, std::shared_ptr<const i2p::client::LeaseSetDestination> dest, uint32_t token)
{
s << "<b>Base32:</b><br>\r\n<textarea readonly cols=\"80\" rows=\"1\">";
@ -482,7 +491,9 @@ namespace http { @@ -482,7 +491,9 @@ namespace http {
it->VisitTunnelHops(
[&s](std::shared_ptr<const i2p::data::IdentityEx> hopIdent)
{
s << "&#8658; " << i2p::data::GetIdentHashAbbreviation (hopIdent->GetIdentHash ()) << " ";
s << "&#8658; ";
ShowHop(s, *hopIdent);
s << " ";
}
);
}
@ -503,7 +514,9 @@ namespace http { @@ -503,7 +514,9 @@ namespace http {
it->VisitTunnelHops(
[&s](std::shared_ptr<const i2p::data::IdentityEx> hopIdent)
{
s << " " << i2p::data::GetIdentHashAbbreviation (hopIdent->GetIdentHash ()) << " &#8658;";
s << " ";
ShowHop(s, *hopIdent);
s << " &#8658;";
}
);
}
@ -699,7 +712,9 @@ namespace http { @@ -699,7 +712,9 @@ namespace http {
it->VisitTunnelHops(
[&s](std::shared_ptr<const i2p::data::IdentityEx> hopIdent)
{
s << "&#8658; " << i2p::data::GetIdentHashAbbreviation (hopIdent->GetIdentHash ()) << " ";
s << "&#8658; ";
ShowHop(s, *hopIdent);
s << " ";
}
);
}
@ -720,7 +735,9 @@ namespace http { @@ -720,7 +735,9 @@ namespace http {
it->VisitTunnelHops(
[&s](std::shared_ptr<const i2p::data::IdentityEx> hopIdent)
{
s << " " << i2p::data::GetIdentHashAbbreviation (hopIdent->GetIdentHash ()) << " &#8658;";
s << " ";
ShowHop(s, *hopIdent);
s << " &#8658;";
}
);
}

7
libi2pd/RouterInfo.cpp

@ -534,13 +534,20 @@ namespace data @@ -534,13 +534,20 @@ namespace data
case CAPS_FLAG_FLOODFILL:
m_Caps |= Caps::eFloodfill;
break;
case CAPS_FLAG_LOW_BANDWIDTH1:
case CAPS_FLAG_LOW_BANDWIDTH2:
case CAPS_FLAG_LOW_BANDWIDTH3:
m_BandwidthCap = *cap;
break;
case CAPS_FLAG_HIGH_BANDWIDTH1:
case CAPS_FLAG_HIGH_BANDWIDTH2:
m_Caps |= Caps::eHighBandwidth;
m_BandwidthCap = *cap;
break;
case CAPS_FLAG_EXTRA_BANDWIDTH1:
case CAPS_FLAG_EXTRA_BANDWIDTH2:
m_Caps |= Caps::eExtraBandwidth | Caps::eHighBandwidth;
m_BandwidthCap = *cap;
break;
case CAPS_FLAG_HIDDEN:
m_Caps |= Caps::eHidden;

2
libi2pd/RouterInfo.h

@ -271,6 +271,7 @@ namespace data @@ -271,6 +271,7 @@ namespace data
bool IsHighCongestion (bool highBandwidth) const;
uint8_t GetCaps () const { return m_Caps; };
char GetBandwidthCap() const { return m_BandwidthCap; };
void SetCaps (uint8_t caps) { m_Caps = caps; };
Congestion GetCongestion () const { return m_Congestion; };
@ -345,6 +346,7 @@ namespace data @@ -345,6 +346,7 @@ namespace data
bool m_IsUpdated, m_IsUnreachable, m_IsFloodfill;
CompatibleTransports m_SupportedTransports, m_ReachableTransports, m_PublishedTransports;
uint8_t m_Caps;
char m_BandwidthCap;
int m_Version;
Congestion m_Congestion;
mutable std::shared_ptr<RouterProfile> m_Profile;

Loading…
Cancel
Save