Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add target address and port to webconsole for every client tunnel (issue #1877) #1928

Open
wants to merge 2 commits into
base: openssl
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 26 additions & 10 deletions daemon/HTTPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,26 +977,34 @@ namespace http {
{
auto& ident = it.second->GetLocalDestination ()->GetIdentHash();
s << "<div class=\"listitem\"><a href=\"" << webroot << "?page=" << HTTP_PAGE_LOCAL_DESTINATION << "&b32=" << ident.ToBase32 () << "\">";
s << it.second->GetName () << "</a> &#8656; ";
s << i2p::client::context.GetAddressBook ().ToAddress(ident);
s << it.second->GetName () << "</a> ";
s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "; ";
s << it.first.address() << ":" << it.first.port();
s << " &#8658; ";
if (it.second->GetRemoteDestination() != "") // no remote destination for proxy
s << it.second->GetRemoteDestination() << ":" << it.second->GetRemoteDestinationPort();
s << "</div>\r\n"<< std::endl;
}
auto httpProxy = i2p::client::context.GetHttpProxy ();
if (httpProxy)
{
auto& ident = httpProxy->GetLocalDestination ()->GetIdentHash();
s << "<div class=\"listitem\"><a href=\"" << webroot << "?page=" << HTTP_PAGE_LOCAL_DESTINATION << "&b32=" << ident.ToBase32 () << "\">";
s << "HTTP " << tr("Proxy") << "</a> &#8656; ";
s << i2p::client::context.GetAddressBook ().ToAddress(ident);
s << "HTTP " << tr("Proxy") << "</a> ";
s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "; ";
s << httpProxy->GetLocalEndpoint().address() << ":" << httpProxy->GetLocalEndpoint().port();
s << " &#8658; ";
s << "</div>\r\n"<< std::endl;
}
auto socksProxy = i2p::client::context.GetSocksProxy ();
if (socksProxy)
{
auto& ident = socksProxy->GetLocalDestination ()->GetIdentHash();
s << "<div class=\"listitem\"><a href=\"" << webroot << "?page=" << HTTP_PAGE_LOCAL_DESTINATION << "&b32=" << ident.ToBase32 () << "\">";
s << "SOCKS " << tr("Proxy") << "</a> &#8656; ";
s << i2p::client::context.GetAddressBook ().ToAddress(ident);
s << "SOCKS " << tr("Proxy") << "</a> ";
s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "; ";
s << httpProxy->GetLocalEndpoint().address() << ":" << httpProxy->GetLocalEndpoint().port();
s << " &#8658; ";
s << "</div>\r\n"<< std::endl;
}
s << "</div>\r\n";
Expand All @@ -1008,7 +1016,9 @@ namespace http {
{
auto& ident = it.second->GetLocalDestination ()->GetIdentHash();
s << "<div class=\"listitem\"><a href=\"" << webroot << "?page=" << HTTP_PAGE_LOCAL_DESTINATION << "&b32=" << ident.ToBase32 () << "\">";
s << it.second->GetName () << "</a> &#8658; ";
s << it.second->GetName () << "</a> ";
s << it.second->GetEndpoint().address() << ":" << it.second->GetEndpoint().port();
s << " &#8656; ";
s << i2p::client::context.GetAddressBook ().ToAddress(ident);
s << ":" << it.second->GetLocalPort ();
s << "</a></div>\r\n"<< std::endl;
Expand All @@ -1024,8 +1034,12 @@ namespace http {
{
auto& ident = it.second->GetLocalDestination ()->GetIdentHash();
s << "<div class=\"listitem\"><a href=\"" << webroot << "?page=" << HTTP_PAGE_LOCAL_DESTINATION << "&b32=" << ident.ToBase32 () << "\">";
s << it.second->GetName () << "</a> &#8656; ";
s << i2p::client::context.GetAddressBook ().ToAddress(ident);
s << it.second->GetName () << "</a> ";
s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "; ";
s << it.first.address() << ":" << it.first.port();
s << " &#8658; ";
if (it.second->GetRemoteDestination() != "") // no remote destination for proxy
s << it.second->GetRemoteDestination() << ":" << it.second->GetRemoteDestinationPort();
s << "</div>\r\n"<< std::endl;
}
s << "</div>\r\n";
Expand All @@ -1038,7 +1052,9 @@ namespace http {
{
auto& ident = it.second->GetLocalDestination ()->GetIdentHash();
s << "<div class=\"listitem\"><a href=\"" << webroot << "?page=" << HTTP_PAGE_LOCAL_DESTINATION << "&b32=" << ident.ToBase32 () << "\">";
s << it.second->GetName () << "</a> &#8656; ";
s << it.second->GetName () << "</a> ";
s << it.second->GetEndpoint().address() << ":" << it.second->GetEndpoint().port();
s << " &#8656; ";
s << i2p::client::context.GetAddressBook ().ToAddress(ident);
s << "</div>\r\n"<< std::endl;
}
Expand Down
2 changes: 2 additions & 0 deletions libi2pd_client/HTTPProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ namespace proxy {
// Implements TCPIPAcceptor
std::shared_ptr<i2p::client::I2PServiceHandler> CreateHandler(std::shared_ptr<boost::asio::ip::tcp::socket> socket);
const char* GetName() { return m_Name.c_str (); }
const std::string GetRemoteDestination() { return ""; }
int GetRemoteDestinationPort() { return 0; }

private:

Expand Down
3 changes: 3 additions & 0 deletions libi2pd_client/I2PService.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ namespace client
virtual void Stop () = 0;

virtual const char* GetName() { return "Generic I2P Service"; }
virtual const std::string GetRemoteDestination() { return ""; }
virtual int GetRemoteDestinationPort() { return -1; }


private:

Expand Down
2 changes: 2 additions & 0 deletions libi2pd_client/I2PTunnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ namespace client
void Stop ();

const char* GetName() { return m_Name.c_str (); }
const std::string GetRemoteDestination() { return m_Destination; }
int GetRemoteDestinationPort() { return m_DestinationPort; }
void SetKeepAliveInterval (uint32_t keepAliveInterval);

private:
Expand Down
2 changes: 2 additions & 0 deletions libi2pd_client/SOCKS.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ namespace proxy
// Implements TCPIPAcceptor
std::shared_ptr<i2p::client::I2PServiceHandler> CreateHandler(std::shared_ptr<boost::asio::ip::tcp::socket> socket);
const char* GetName() { return m_Name.c_str (); }
const std::string GetRemoteDestination() { return ""; }
int GetRemoteDestinationPort() { return 0; }

private:

Expand Down
3 changes: 3 additions & 0 deletions libi2pd_client/UDPTunnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ namespace client
const char * GetName () const { return m_Name.c_str(); }
std::vector<std::shared_ptr<DatagramSessionInfo> > GetSessions ();
std::shared_ptr<ClientDestination> GetLocalDestination () const { return m_LocalDest; }
const boost::asio::ip::udp::endpoint& GetEndpoint () const { return m_RemoteEndpoint; }

void SetUniqueLocal (bool isUniqueLocal = true) { m_IsUniqueLocal = isUniqueLocal; }

Expand Down Expand Up @@ -134,6 +135,8 @@ namespace client
void Start ();
void Stop ();
const char * GetName () const { return m_Name.c_str(); }
const std::string GetRemoteDestination() { return m_RemoteDest; }
uint16_t GetRemoteDestinationPort() { return RemotePort; }
std::vector<std::shared_ptr<DatagramSessionInfo> > GetSessions ();

bool IsLocalDestination (const i2p::data::IdentHash & destination) const { return destination == m_LocalDest->GetIdentHash(); }
Expand Down