From c86a1f63a21d5c1aff4c76f9768b64d92bdb7f4b Mon Sep 17 00:00:00 2001 From: weko Date: Mon, 8 May 2023 20:28:19 +0000 Subject: [PATCH] understandable construction for client tunnels --- daemon/HTTPServer.cpp | 12 ++++++++---- libi2pd_client/HTTPProxy.h | 2 ++ libi2pd_client/I2PService.h | 3 +++ libi2pd_client/I2PTunnel.h | 2 ++ libi2pd_client/SOCKS.h | 2 ++ libi2pd_client/UDPTunnel.h | 2 ++ 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/daemon/HTTPServer.cpp b/daemon/HTTPServer.cpp index 2a11a1dc..1357111e 100644 --- a/daemon/HTTPServer.cpp +++ b/daemon/HTTPServer.cpp @@ -978,9 +978,11 @@ namespace http { auto& ident = it.second->GetLocalDestination ()->GetIdentHash(); s << "
"; s << it.second->GetName () << " "; + s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "; "; s << it.first.address() << ":" << it.first.port(); s << " ⇒ "; - s << i2p::client::context.GetAddressBook ().ToAddress(ident); + if (it.second->GetRemoteDestination() != "") // no remote destination for proxy + s << it.second->GetRemoteDestination() << ":" << it.second->GetRemoteDestinationPort(); s << "
\r\n"<< std::endl; } auto httpProxy = i2p::client::context.GetHttpProxy (); @@ -989,9 +991,9 @@ namespace http { auto& ident = httpProxy->GetLocalDestination ()->GetIdentHash(); s << "
"; s << "HTTP " << tr("Proxy") << " "; + s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "; "; s << httpProxy->GetLocalEndpoint().address() << ":" << httpProxy->GetLocalEndpoint().port(); s << " ⇒ "; - s << i2p::client::context.GetAddressBook ().ToAddress(ident); s << "
\r\n"<< std::endl; } auto socksProxy = i2p::client::context.GetSocksProxy (); @@ -1000,9 +1002,9 @@ namespace http { auto& ident = socksProxy->GetLocalDestination ()->GetIdentHash(); s << "
"; s << "SOCKS " << tr("Proxy") << " "; + s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "; "; s << httpProxy->GetLocalEndpoint().address() << ":" << httpProxy->GetLocalEndpoint().port(); s << " ⇒ "; - s << i2p::client::context.GetAddressBook ().ToAddress(ident); s << "
\r\n"<< std::endl; } s << "\r\n"; @@ -1033,9 +1035,11 @@ namespace http { auto& ident = it.second->GetLocalDestination ()->GetIdentHash(); s << "
"; s << it.second->GetName () << " "; + s << i2p::client::context.GetAddressBook ().ToAddress(ident) << "; "; s << it.first.address() << ":" << it.first.port(); s << " ⇒ "; - s << i2p::client::context.GetAddressBook ().ToAddress(ident); + if (it.second->GetRemoteDestination() != "") // no remote destination for proxy + s << it.second->GetRemoteDestination() << ":" << it.second->GetRemoteDestinationPort(); s << "
\r\n"<< std::endl; } s << "\r\n"; diff --git a/libi2pd_client/HTTPProxy.h b/libi2pd_client/HTTPProxy.h index 69ed4cef..def99609 100644 --- a/libi2pd_client/HTTPProxy.h +++ b/libi2pd_client/HTTPProxy.h @@ -28,6 +28,8 @@ namespace proxy { // Implements TCPIPAcceptor std::shared_ptr CreateHandler(std::shared_ptr socket); const char* GetName() { return m_Name.c_str (); } + const std::string GetRemoteDestination() { return ""; } + int GetRemoteDestinationPort() { return 0; } private: diff --git a/libi2pd_client/I2PService.h b/libi2pd_client/I2PService.h index e14f85c1..9a750ba3 100644 --- a/libi2pd_client/I2PService.h +++ b/libi2pd_client/I2PService.h @@ -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: diff --git a/libi2pd_client/I2PTunnel.h b/libi2pd_client/I2PTunnel.h index 4c7b2002..e8f52dcb 100644 --- a/libi2pd_client/I2PTunnel.h +++ b/libi2pd_client/I2PTunnel.h @@ -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: diff --git a/libi2pd_client/SOCKS.h b/libi2pd_client/SOCKS.h index f41cfd72..c855229e 100644 --- a/libi2pd_client/SOCKS.h +++ b/libi2pd_client/SOCKS.h @@ -34,6 +34,8 @@ namespace proxy // Implements TCPIPAcceptor std::shared_ptr CreateHandler(std::shared_ptr socket); const char* GetName() { return m_Name.c_str (); } + const std::string GetRemoteDestination() { return ""; } + int GetRemoteDestinationPort() { return 0; } private: diff --git a/libi2pd_client/UDPTunnel.h b/libi2pd_client/UDPTunnel.h index 814884ec..d5c04936 100644 --- a/libi2pd_client/UDPTunnel.h +++ b/libi2pd_client/UDPTunnel.h @@ -135,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 > GetSessions (); bool IsLocalDestination (const i2p::data::IdentHash & destination) const { return destination == m_LocalDest->GetIdentHash(); }