mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-08-26 10:10:24 +01:00
Handle links with UTF8 SAM session name
Some checks are pending
Build Debian packages / bookworm (push) Waiting to run
Build Debian packages / bullseye (push) Waiting to run
Build Debian packages / trixie (push) Waiting to run
Build on FreeBSD / with UPnP (push) Waiting to run
Build on OSX / With USE_UPNP=no (push) Waiting to run
Build on OSX / With USE_UPNP=yes (push) Waiting to run
Build on Windows / clang-x86_64 (push) Waiting to run
Build on Windows / i686 (push) Waiting to run
Build on Windows / ucrt-x86_64 (push) Waiting to run
Build on Windows / x86_64 (push) Waiting to run
Build on Windows / CMake clang-x86_64 (push) Waiting to run
Build on Windows / CMake i686 (push) Waiting to run
Build on Windows / CMake ucrt-x86_64 (push) Waiting to run
Build on Windows / CMake x86_64 (push) Waiting to run
Build on Windows / XP (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=no (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=yes (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=OFF (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=ON (push) Waiting to run
Build containers / Building container for linux/arm64 (push) Waiting to run
Build containers / Building container for linux/amd64 (push) Waiting to run
Build containers / Building container for linux/arm/v7 (push) Waiting to run
Build containers / Building container for linux/386 (push) Waiting to run
Build containers / Pushing merged manifest (push) Blocked by required conditions
Some checks are pending
Build Debian packages / bookworm (push) Waiting to run
Build Debian packages / bullseye (push) Waiting to run
Build Debian packages / trixie (push) Waiting to run
Build on FreeBSD / with UPnP (push) Waiting to run
Build on OSX / With USE_UPNP=no (push) Waiting to run
Build on OSX / With USE_UPNP=yes (push) Waiting to run
Build on Windows / clang-x86_64 (push) Waiting to run
Build on Windows / i686 (push) Waiting to run
Build on Windows / ucrt-x86_64 (push) Waiting to run
Build on Windows / x86_64 (push) Waiting to run
Build on Windows / CMake clang-x86_64 (push) Waiting to run
Build on Windows / CMake i686 (push) Waiting to run
Build on Windows / CMake ucrt-x86_64 (push) Waiting to run
Build on Windows / CMake x86_64 (push) Waiting to run
Build on Windows / XP (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=no (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=yes (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=OFF (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=ON (push) Waiting to run
Build containers / Building container for linux/arm64 (push) Waiting to run
Build containers / Building container for linux/amd64 (push) Waiting to run
Build containers / Building container for linux/arm/v7 (push) Waiting to run
Build containers / Building container for linux/386 (push) Waiting to run
Build containers / Pushing merged manifest (push) Blocked by required conditions
This commit is contained in:
parent
aeca4c3fc7
commit
28996583e4
1 changed files with 20 additions and 6 deletions
|
@ -947,7 +947,8 @@ namespace http {
|
||||||
for (auto& it: sam->GetSessions ())
|
for (auto& it: sam->GetSessions ())
|
||||||
{
|
{
|
||||||
auto& name = it.second->GetLocalDestination ()->GetNickname ();
|
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 << name << " (" << it.first << ")</a></div>\r\n" << std::endl;
|
||||||
}
|
}
|
||||||
s << "</div>\r\n";
|
s << "</div>\r\n";
|
||||||
|
@ -959,13 +960,26 @@ namespace http {
|
||||||
void ShowSAMSession (std::stringstream& s, const std::string& id)
|
void ShowSAMSession (std::stringstream& s, const std::string& id)
|
||||||
{
|
{
|
||||||
auto sam = i2p::client::context.GetSAMBridge ();
|
auto sam = i2p::client::context.GetSAMBridge ();
|
||||||
if (!sam) {
|
if (!sam)
|
||||||
|
{
|
||||||
ShowError(s, tr("SAM disabled"));
|
ShowError(s, tr("SAM disabled"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (id.empty ())
|
||||||
auto session = sam->FindSession (id);
|
{
|
||||||
if (!session) {
|
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"));
|
ShowError(s, tr("SAM session not found"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -977,7 +991,7 @@ namespace http {
|
||||||
s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "</a></div>\r\n";
|
s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "</a></div>\r\n";
|
||||||
s << "<br>\r\n";
|
s << "<br>\r\n";
|
||||||
s << "<b>" << tr("Streams") << ":</b><br>\r\n<div class=\"list\">\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\">";
|
s << "<div class=\"listitem\">";
|
||||||
switch (it->GetSocketType ())
|
switch (it->GetSocketType ())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue