Merge branch 'openssl' into BandwithParameter

This commit is contained in:
🜃 Ezor Kael 2025-08-18 19:50:54 +07:00 committed by GitHub
commit b3d566c6f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 357 additions and 213 deletions

View file

@ -43,8 +43,8 @@
namespace i2p {
namespace http {
static void LoadExtCSS (std::string fileName = "style.css")
static void LoadExtCSS (std::string fileName = "style")
{
std::stringstream s;
std::string styleFile = i2p::fs::DataDirPath ("webconsole/"+fileName+".css");
@ -971,7 +971,8 @@ namespace http {
for (auto& it: sam->GetSessions ())
{
auto& name = it.second->GetLocalDestination ()->GetNickname ();
s << "<div class=\"listitem\"><a href=\"" << webroot << "?page=" << HTTP_PAGE_SAM_SESSION << "&sam_id=" << it.first << "\">";
auto sam_id = i2p::data::ByteStreamToBase64 ((const uint8_t *)it.first.data (), it.first.length ()); // base64, becuase session name might be UTF-8
s << "<div class=\"listitem\"><a href=\"" << webroot << "?page=" << HTTP_PAGE_SAM_SESSION << "&sam_id=" << sam_id << "\">";
s << name << " (" << it.first << ")</a></div>\r\n" << std::endl;
}
s << "</div>\r\n";
@ -983,13 +984,26 @@ namespace http {
void ShowSAMSession (std::stringstream& s, const std::string& id)
{
auto sam = i2p::client::context.GetSAMBridge ();
if (!sam) {
if (!sam)
{
ShowError(s, tr("SAM disabled"));
return;
}
auto session = sam->FindSession (id);
if (!session) {
if (id.empty ())
{
ShowError(s, tr("No sam_id"));
return;
}
std::vector<uint8_t> sam_id(id.length ()); // id is in base64
size_t l = i2p::data::Base64ToByteStream (id, sam_id.data (), sam_id.size ());
if (!l)
{
ShowError(s, tr("Invalid sam_id"));
return;
}
auto session = sam->FindSession ( { (const char *)sam_id.data (), l });
if (!session)
{
ShowError(s, tr("SAM session not found"));
return;
}
@ -1001,7 +1015,7 @@ namespace http {
s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "</a></div>\r\n";
s << "<br>\r\n";
s << "<b>" << tr("Streams") << ":</b><br>\r\n<div class=\"list\">\r\n";
for (const auto& it: sam->ListSockets(id))
for (const auto& it: sam->ListSockets({ (const char *)sam_id.data (), l }))
{
s << "<div class=\"listitem\">";
switch (it->GetSocketType ())