Browse Source

Merge pull request #640 from atnaguzin/patch-1

add sliders for LeaseSets
pull/642/head
orignal 8 years ago committed by GitHub
parent
commit
783c2b6b03
  1. 46
      HTTPServer.cpp

46
HTTPServer.cpp

@ -345,50 +345,32 @@ namespace http {
void ShowLeasesSets(std::stringstream& s) void ShowLeasesSets(std::stringstream& s)
{ {
s << "<div id='leasesets'><b>LeaseSets:</b></div><br>"; s << "<div id='leasesets'><b>LeaseSets (click on to show info):</b></div><br>\r\n";
int counter = 1;
// for each lease set // for each lease set
i2p::data::netdb.VisitLeaseSets( i2p::data::netdb.VisitLeaseSets(
[&s](const i2p::data::IdentHash dest, std::shared_ptr<i2p::data::LeaseSet> leaseSet) [&s, &counter](const i2p::data::IdentHash dest, std::shared_ptr<i2p::data::LeaseSet> leaseSet)
{ {
// create copy of lease set so we extract leases // create copy of lease set so we extract leases
i2p::data::LeaseSet ls(leaseSet->GetBuffer(), leaseSet->GetBufferLen()); i2p::data::LeaseSet ls(leaseSet->GetBuffer(), leaseSet->GetBufferLen());
// begin lease set entry
s << "<div class='leaseset"; s << "<div class='leaseset";
if (ls.IsExpired()) if (ls.IsExpired())
s << " expired"; // additional css class for expired s << " expired"; // additional css class for expired
s << "'>"; s << "'>\r\n";
// invalid ?
if (!ls.IsValid()) if (!ls.IsValid())
s << "<div class='invalid'>!! Invalid !! </div>"; s << "<div class='invalid'>!! Invalid !! </div>\r\n";
// ident s << "<div class='slide'><label for='slide" << counter << "'>" << dest.ToBase32() << "</label>\r\n";
s << "<div class='ident'>" << dest.ToBase32() << "</div>"; s << "<input type='checkbox' id='slide" << (counter++) << "'/>\r\n<p class='content'>\r\n";
// LeaseSet time s << "<b>Expires:</b> " << ls.GetExpirationTime() << "<br>\r\n";
s << "<div class='expires'>expires: " << ls.GetExpirationTime() << "</div>";
// get non expired leases
auto leases = ls.GetNonExpiredLeases(); auto leases = ls.GetNonExpiredLeases();
// show non expired leases s << "<b>Non Expired Leases: " << leases.size() << "</b><br>\r\n";
s << "<div class='leasecount'>Non Expired Leases: " << leases.size() << "</div>";
// for each lease
s << "<div class='leases'>";
for ( auto & l : leases ) for ( auto & l : leases )
{ {
// begin lease s << "<b>Gateway:</b> " << l->tunnelGateway.ToBase64() << "<br>\r\n";
s << "<div class='lease'>"; s << "<b>TunnelID:</b> " << l->tunnelID << "<br>\r\n";
// gateway s << "<b>EndDate:</b> " << l->endDate << "<br>\r\n";
s << "<div class='gateway'>Gateway: " << l->tunnelGateway.ToBase64() << "</div>"; }
// tunnel id s << "</p>\r\n</div>\r\n</div>\r\n";
s << "<div class='tunnelID'>TunnelID: " << l->tunnelID << "</div>";
// end date
s << "<div class='endDate'>EndDate: " << l->endDate << "</div>";
// end lease
s << "</div>";
}
// end for each lease
s << "</div>";
// end lease set entry
s << "</div>";
// linebreak
s << "<br>";
} }
); );
// end for each lease set // end for each lease set

Loading…
Cancel
Save