From d8918edb515eb111b6df2bfe5775717490b0fd43 Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 14 Aug 2014 10:20:22 -0400 Subject: [PATCH] IRC tunnel support --- Daemon.cpp | 24 ++++++++++++++++++++++-- README.md | 3 +++ SOCKS.h | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Daemon.cpp b/Daemon.cpp index 2cc8b9e7..234f9d00 100644 --- a/Daemon.cpp +++ b/Daemon.cpp @@ -16,6 +16,7 @@ #include "HTTPServer.h" #include "HTTPProxy.h" #include "SOCKS.h" +#include "I2PTunnel.h" namespace i2p { @@ -24,16 +25,19 @@ namespace i2p class Daemon_Singleton::Daemon_Singleton_Private { public: - Daemon_Singleton_Private() : httpServer(nullptr), httpProxy(nullptr), socksProxy(nullptr) { }; + Daemon_Singleton_Private() : httpServer(nullptr), httpProxy(nullptr), + socksProxy(nullptr), ircTunnel(nullptr) { }; ~Daemon_Singleton_Private() { delete httpServer; delete httpProxy; delete socksProxy; + delete ircTunnel; }; i2p::util::HTTPServer *httpServer; i2p::proxy::HTTPProxy *httpProxy; i2p::proxy::SOCKSProxy *socksProxy; + i2p::stream::I2PClientTunnel * ircTunnel; }; Daemon_Singleton::Daemon_Singleton() : running(1), d(*new Daemon_Singleton_Private()) {}; @@ -105,6 +109,14 @@ namespace i2p d.socksProxy = new i2p::proxy::SOCKSProxy(i2p::util::config::GetArg("-socksproxyport", 4447)); d.socksProxy->Start(); LogPrint("SOCKS Proxy Started"); + std::string ircDestination = i2p::util::config::GetArg("-ircdest", ""); + if (ircDestination.length () > 0) // ircdest is presented + { + d.ircTunnel = new i2p::stream::I2PClientTunnel (d.socksProxy->GetService (), ircDestination, + i2p::util::config::GetArg("-ircport", 6668)); + d.ircTunnel->Start (); + LogPrint("IRC tunnel started"); + } return true; } @@ -128,8 +140,16 @@ namespace i2p LogPrint("NetDB stoped"); d.httpServer->Stop(); LogPrint("HTTP Server stoped"); + if (d.ircTunnel) + { + d.ircTunnel->Stop (); + delete d.ircTunnel; + d.ircTunnel = nullptr; + LogPrint("IRC tunnel stoped"); + } StopLog (); - delete d.socksProxy; d.socksProxy = nullptr; + + delete d.socksProxy; d.socksProxy = nullptr; delete d.httpProxy; d.httpProxy = nullptr; delete d.httpServer; d.httpServer = nullptr; diff --git a/README.md b/README.md index 22f32266..65bc91e4 100644 --- a/README.md +++ b/README.md @@ -50,5 +50,8 @@ Options * --log= - Enable or disable logging to file. 1 for yes, 0 for no. * --daemon= - Eanble or disable daemon mode. 1 for yes, 0 for no. * --httpproxyport= - The port to listen on (HTTP Proxy) +* --socksproxyport= - The port to listen on (SOCKS Proxy) +* --ircport= - The local port of IRC tunnel to listen on. 6668 by default +* --ircdest= - I2P destination address of IRC server. For example irc.postman.i2p diff --git a/SOCKS.h b/SOCKS.h index af9e4788..79f8b4ca 100644 --- a/SOCKS.h +++ b/SOCKS.h @@ -73,6 +73,7 @@ namespace proxy void Start(); void Stop(); + boost::asio::io_service& GetService () { return m_ios; }; private: