Browse Source

get family string from local RouterInfo

pull/487/head
orignal 9 years ago
parent
commit
5e2dc14dd5
  1. 1
      Daemon.cpp
  2. 4
      HTTPServer.cpp
  3. 12
      RouterContext.cpp
  4. 4
      RouterContext.h
  5. 8
      RouterInfo.cpp
  6. 1
      RouterInfo.h

1
Daemon.cpp

@ -189,7 +189,6 @@ namespace i2p
std::string family; i2p::config::GetOption("family", family); std::string family; i2p::config::GetOption("family", family);
i2p::context.SetFamily (family); i2p::context.SetFamily (family);
i2p::context.SetFamilyString (family);
if (family.length () > 0) if (family.length () > 0)
LogPrint(eLogInfo, "Daemon: family set to ", family); LogPrint(eLogInfo, "Daemon: family set to ", family);

4
HTTPServer.cpp

@ -417,7 +417,9 @@ namespace util
default: s << "Unknown"; default: s << "Unknown";
} }
s << "<br>\r\n"; s << "<br>\r\n";
s << "<b>Family:</b> " << i2p::context.GetFamilyString() << "<br>\r\n"; auto family = i2p::context.GetFamily ();
if (family.length () > 0)
s << "<b>Family:</b> " << family << "<br>\r\n";
s << "<b>Tunnel creation success rate:</b> " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%<br>\r\n"; s << "<b>Tunnel creation success rate:</b> " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%<br>\r\n";
s << "<b>Received:</b> "; s << "<b>Received:</b> ";
s << std::fixed << std::setprecision(2); s << std::fixed << std::setprecision(2);

12
RouterContext.cpp

@ -149,17 +149,9 @@ namespace i2p
UpdateRouterInfo (); UpdateRouterInfo ();
} }
void RouterContext::SetFamilyString (const std::string& family) std::string RouterContext::GetFamily () const
{ {
if (family.length() > 0) return m_RouterInfo.GetProperty (i2p::data::ROUTER_INFO_PROPERTY_FAMILY);
m_FamilyString = family;
else
m_FamilyString = "&lt;undefined&gt;";
}
std::string RouterContext::GetFamilyString () const
{
return m_FamilyString;
} }
void RouterContext::SetFamily (const std::string& family) void RouterContext::SetFamily (const std::string& family)

4
RouterContext.h

@ -59,8 +59,7 @@ namespace i2p
bool IsFloodfill () const { return m_IsFloodfill; }; bool IsFloodfill () const { return m_IsFloodfill; };
void SetFloodfill (bool floodfill); void SetFloodfill (bool floodfill);
void SetFamily (const std::string& family); void SetFamily (const std::string& family);
void SetFamilyString (const std::string& family); std::string GetFamily () const;
std::string GetFamilyString () const;
void SetBandwidth (int limit); /* in kilobytes */ void SetBandwidth (int limit); /* in kilobytes */
void SetBandwidth (char L); /* by letter */ void SetBandwidth (char L); /* by letter */
bool AcceptsTunnels () const { return m_AcceptsTunnels; }; bool AcceptsTunnels () const { return m_AcceptsTunnels; };
@ -102,7 +101,6 @@ namespace i2p
i2p::data::PrivateKeys m_Keys; i2p::data::PrivateKeys m_Keys;
uint64_t m_LastUpdateTime; uint64_t m_LastUpdateTime;
bool m_AcceptsTunnels, m_IsFloodfill; bool m_AcceptsTunnels, m_IsFloodfill;
std::string m_FamilyString;
uint64_t m_StartupTime; // in seconds since epoch uint64_t m_StartupTime; // in seconds since epoch
uint32_t m_BandwidthLimit; // allowed bandwidth uint32_t m_BandwidthLimit; // allowed bandwidth
RouterStatus m_Status; RouterStatus m_Status;

8
RouterInfo.cpp

@ -636,6 +636,14 @@ namespace data
m_Properties.erase (key); m_Properties.erase (key);
} }
std::string RouterInfo::GetProperty (const std::string& key) const
{
auto it = m_Properties.find (key);
if (it != m_Properties.end ())
return it->second;
return "";
}
bool RouterInfo::IsNTCP (bool v4only) const bool RouterInfo::IsNTCP (bool v4only) const
{ {
if (v4only) if (v4only)

1
RouterInfo.h

@ -128,6 +128,7 @@ namespace data
bool RemoveIntroducer (const boost::asio::ip::udp::endpoint& e); bool RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
void SetProperty (const std::string& key, const std::string& value); // called from RouterContext only void SetProperty (const std::string& key, const std::string& value); // called from RouterContext only
void DeleteProperty (const std::string& key); // called from RouterContext only void DeleteProperty (const std::string& key); // called from RouterContext only
std::string GetProperty (const std::string& key) const; // called from RouterContext only
void ClearProperties () { m_Properties.clear (); }; void ClearProperties () { m_Properties.clear (); };
bool IsFloodfill () const { return m_Caps & Caps::eFloodfill; }; bool IsFloodfill () const { return m_Caps & Caps::eFloodfill; };
bool IsReachable () const { return m_Caps & Caps::eReachable; }; bool IsReachable () const { return m_Caps & Caps::eReachable; };

Loading…
Cancel
Save