diff --git a/HTTPServer.cpp b/HTTPServer.cpp
index e5093bba..7dc8d910 100644
--- a/HTTPServer.cpp
+++ b/HTTPServer.cpp
@@ -573,15 +573,16 @@ namespace http {
void ShowSAMSessions (std::stringstream& s)
{
- s << "SAM Sessions:
\r\n
\r\n";
auto sam = i2p::client::context.GetSAMBridge ();
- if (sam)
- {
- for (auto& it: sam->GetSessions ())
- {
- s << "";
- s << it.first << "
\r\n" << std::endl;
- }
+ if (!sam) {
+ ShowError(s, "SAM disabled");
+ return;
+ }
+ s << "SAM Sessions:
\r\n
\r\n";
+ for (auto& it: sam->GetSessions ())
+ {
+ s << "";
+ s << it.first << "
\r\n" << std::endl;
}
}
@@ -589,35 +590,31 @@ namespace http {
{
s << "SAM Session:
\r\n
\r\n";
auto sam = i2p::client::context.GetSAMBridge ();
- if (sam)
+ if (!sam) {
+ ShowError(s, "SAM disabled");
+ return;
+ }
+ auto session = sam->FindSession (id);
+ if (!session) {
+ ShowError(s, "SAM session not found");
+ return;
+ }
+ auto& ident = session->localDestination->GetIdentHash();
+ s << "";
+ s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "
\r\n";
+ s << "
\r\n";
+ s << "Streams:
\r\n";
+ for (auto it: session->ListSockets())
{
- auto session = sam->FindSession (id);
- if (session)
+ switch (it->GetSocketType ())
{
- auto& ident = session->localDestination->GetIdentHash();
- s << "";
- s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "
\r\n" << std::endl;
- s << "Streams:
\r\n";
- for (auto it: session->ListSockets())
- {
- switch (it->GetSocketType ())
- {
- case i2p::client::eSAMSocketTypeSession:
- s << "session";
- break;
- case i2p::client::eSAMSocketTypeStream:
- s << "stream";
- break;
- case i2p::client::eSAMSocketTypeAcceptor:
- s << "acceptor";
- break;
- default:
- s << "unknown";
- }
- s << " [" << it->GetSocket ().remote_endpoint() << "]";
- s << "
\r\n" << std::endl;
- }
+ case i2p::client::eSAMSocketTypeSession : s << "session"; break;
+ case i2p::client::eSAMSocketTypeStream : s << "stream"; break;
+ case i2p::client::eSAMSocketTypeAcceptor : s << "acceptor"; break;
+ default: s << "unknown"; break;
}
+ s << " [" << it->GetSocket ().remote_endpoint() << "]";
+ s << "
\r\n";
}
}