Skip to content

Commit

Permalink
show bandwidth caps for hops
Browse files Browse the repository at this point in the history
  • Loading branch information
Vort committed Feb 19, 2024
1 parent 7e3157b commit 83e8a30
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
25 changes: 21 additions & 4 deletions daemon/HTTPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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\">";
Expand Down Expand Up @@ -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 << " ";
}
);
}
Expand All @@ -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;";
}
);
}
Expand Down Expand Up @@ -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 << " ";
}
);
}
Expand All @@ -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;";
}
);
}
Expand Down
6 changes: 6 additions & 0 deletions libi2pd/RouterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,14 +514,20 @@ namespace data
case CAPS_FLAG_FLOODFILL:
m_Caps |= Caps::eFloodfill;
break;
case CAPS_FLAG_LOW_BANDWIDTH1:
case CAPS_FLAG_LOW_BANDWIDTH2:
m_BandwidthCap = *cap;
break;
case CAPS_FLAG_HIGH_BANDWIDTH1:
case CAPS_FLAG_HIGH_BANDWIDTH2:
case CAPS_FLAG_HIGH_BANDWIDTH3:
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;
Expand Down
2 changes: 2 additions & 0 deletions libi2pd/RouterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,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; };
Expand Down Expand Up @@ -329,6 +330,7 @@ namespace data
bool m_IsUpdated, m_IsUnreachable;
CompatibleTransports m_SupportedTransports, m_ReachableTransports;
uint8_t m_Caps;
char m_BandwidthCap;
int m_Version;
Congestion m_Congestion;
mutable std::shared_ptr<RouterProfile> m_Profile;
Expand Down

0 comments on commit 83e8a30

Please sign in to comment.