From a7da2423cec968222690e6356a5feb4fb060b82d Mon Sep 17 00:00:00 2001 From: EinMByte Date: Mon, 27 Jul 2015 12:13:05 +0200 Subject: [PATCH] Do not bind HTTPServer to the "any" address (#235). --- Daemon.cpp | 5 ++++- HTTPServer.cpp | 4 ++-- HTTPServer.h | 2 +- README.md | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Daemon.cpp b/Daemon.cpp index 599c192a..7ba7ccb3 100644 --- a/Daemon.cpp +++ b/Daemon.cpp @@ -106,7 +106,10 @@ namespace i2p StartLog (""); // write to stdout } - d.httpServer = new i2p::util::HTTPServer(i2p::util::config::GetArg("-httpport", 7070)); + d.httpServer = new i2p::util::HTTPServer( + i2p::util::config::GetArg("-httpaddress", "127.0.0.1"), + i2p::util::config::GetArg("-httpport", 7070) + ); d.httpServer->Start(); LogPrint("HTTP Server started"); i2p::data::netdb.Start(); diff --git a/HTTPServer.cpp b/HTTPServer.cpp index cb1cafd6..3d656730 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -1042,9 +1042,9 @@ namespace util std::bind (&HTTPConnection::HandleWriteReply, shared_from_this (), std::placeholders::_1)); } - HTTPServer::HTTPServer (int port): + HTTPServer::HTTPServer (const std::string& address, int port): m_Thread (nullptr), m_Work (m_Service), - m_Acceptor (m_Service, boost::asio::ip::tcp::endpoint (boost::asio::ip::tcp::v4 (), port)), + m_Acceptor (m_Service, boost::asio::ip::tcp::endpoint (boost::asio::ip::address::from_string(address), port)), m_NewSocket (nullptr) { diff --git a/HTTPServer.h b/HTTPServer.h index a32f8e7a..8ed03282 100644 --- a/HTTPServer.h +++ b/HTTPServer.h @@ -107,7 +107,7 @@ namespace util { public: - HTTPServer (int port); + HTTPServer (const std::string& address, int port); virtual ~HTTPServer (); void Start (); diff --git a/README.md b/README.md index e512eda2..c021a46a 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,7 @@ Cmdline options * --host= - The external IP (deprecated). * --port= - The port to listen on * --httpport= - The http port to listen on +* --httpaddress= - The ip address for the HTTP server, 127.0.0.1 by default * --log= - Enable or disable logging to file. 1 for yes, 0 for no. * --daemon= - Enable or disable daemon mode. 1 for yes, 0 for no. * --service= - 1 if uses system folders (/var/run/i2pd.pid, /var/log/i2pd.log, /var/lib/i2pd).