From 4c323a666a2b45b91f9b36cd7020e5e64f2fe2cc Mon Sep 17 00:00:00 2001 From: orignal Date: Sun, 27 Mar 2022 19:29:50 -0400 Subject: [PATCH] show SSU2 transports in web console --- daemon/HTTPServer.cpp | 11 +++++++++-- libi2pd/SSU2.h | 5 +++++ libi2pd/Transports.h | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/daemon/HTTPServer.cpp b/daemon/HTTPServer.cpp index 4b6fad8d..924a3b6e 100644 --- a/daemon/HTTPServer.cpp +++ b/daemon/HTTPServer.cpp @@ -732,7 +732,7 @@ namespace http { } template - static void ShowNTCPTransports (std::stringstream& s, const Sessions& sessions, const std::string name) + static void ShowTransportSessions (std::stringstream& s, const Sessions& sessions, const std::string name) { std::stringstream tmp_s, tmp_s6; uint16_t cnt = 0, cnt6 = 0; for (const auto& it: sessions ) @@ -782,7 +782,7 @@ namespace http { { auto sessions = ntcp2Server->GetNTCP2Sessions (); if (!sessions.empty ()) - ShowNTCPTransports (s, sessions, "NTCP2"); + ShowTransportSessions (s, sessions, "NTCP2"); } auto ssuServer = i2p::transport::transports.GetSSUServer (); if (ssuServer) @@ -824,6 +824,13 @@ namespace http { s << "\r\n\r\n"; } } + auto ssu2Server = i2p::transport::transports.GetSSU2Server (); + if (ssu2Server) + { + auto sessions = ssu2Server->GetSSU2Sessions (); + if (!sessions.empty ()) + ShowTransportSessions (s, sessions, "SSU2"); + } } void ShowSAMSessions (std::stringstream& s) diff --git a/libi2pd/SSU2.h b/libi2pd/SSU2.h index 2ebabf3c..df5f8be9 100644 --- a/libi2pd/SSU2.h +++ b/libi2pd/SSU2.h @@ -210,6 +210,11 @@ namespace transport std::map > m_IncomingTokens, m_OutgoingTokens; // remote endpoint -> (token, expires in seconds) i2p::util::MemoryPoolMt m_PacketsPool; boost::asio::deadline_timer m_TerminationTimer; + + public: + + // for HTTP/I2PControl + const decltype(m_Sessions)& GetSSU2Sessions () const { return m_Sessions; }; }; } } diff --git a/libi2pd/Transports.h b/libi2pd/Transports.h index 988b323d..80d1855e 100644 --- a/libi2pd/Transports.h +++ b/libi2pd/Transports.h @@ -187,6 +187,7 @@ namespace transport // for HTTP only const SSUServer * GetSSUServer () const { return m_SSUServer; }; const NTCP2Server * GetNTCP2Server () const { return m_NTCP2Server; }; + const SSU2Server * GetSSU2Server () const { return m_SSU2Server; }; const decltype(m_Peers)& GetPeers () const { return m_Peers; }; };