Browse Source

Make i2pcontrol password configurable.

pull/242/head
EinMByte 9 years ago
parent
commit
843abb60dd
  1. 3
      ClientContext.cpp
  2. 4
      i2pcontrol/I2PControl.cpp
  3. 4
      i2pcontrol/I2PControl.h
  4. 10
      i2pcontrol/I2PControlServer.cpp
  5. 2
      i2pcontrol/I2PControlServer.h

3
ClientContext.cpp

@ -116,7 +116,8 @@ namespace client @@ -116,7 +116,8 @@ namespace client
if(i2pcontrolPort) {
m_I2PControlService = new I2PControlService(
i2p::util::config::GetArg("-i2pcontroladdress", "127.0.0.1"),
i2pcontrolPort
i2pcontrolPort,
i2p::util::config::GetArg("-i2pcontrolpassword", I2P_CONTROL_DEFAULT_PASSWORD)
);
m_I2PControlService->Start();
LogPrint("I2PControl started");

4
i2pcontrol/I2PControl.cpp

@ -100,8 +100,8 @@ void I2PControlSession::Response::setId(const std::string& identifier) @@ -100,8 +100,8 @@ void I2PControlSession::Response::setId(const std::string& identifier)
id = identifier;
}
I2PControlSession::I2PControlSession(boost::asio::io_service& ios)
: password(I2P_CONTROL_DEFAULT_PASSWORD), tokens(), tokensMutex(),
I2PControlSession::I2PControlSession(boost::asio::io_service& ios, const std::string& pass)
: password(pass), tokens(), tokensMutex(),
service(ios), shutdownTimer(ios), expireTokensTimer(ios)
{
// Method handlers

4
i2pcontrol/I2PControl.h

@ -108,10 +108,12 @@ public: @@ -108,10 +108,12 @@ public:
/**
* Sets up the appropriate handlers.
* @param pass the password required to authenticate (i.e. obtains a token)
* @param ios the parent io_service object, must remain valid throughout
* the lifetime of this I2PControlSession.
*/
I2PControlSession(boost::asio::io_service& ios);
I2PControlSession(boost::asio::io_service& ios,
const std::string& pass = I2P_CONTROL_DEFAULT_PASSWORD);
/**
* Starts the I2PControlSession.

10
i2pcontrol/I2PControlServer.cpp

@ -6,12 +6,10 @@ @@ -6,12 +6,10 @@
#include "util/Timestamp.h"
#include "version.h"
namespace i2p
{
namespace client
{
I2PControlService::I2PControlService(const std::string& address, int port)
: m_Session(std::make_shared<I2PControlSession>(m_Service)),
namespace i2p {
namespace client {
I2PControlService::I2PControlService(const std::string& address, int port, const std::string& pass)
: m_Session(std::make_shared<I2PControlSession>(m_Service, pass)),
m_IsRunning(false), m_Thread(nullptr),
m_Acceptor(m_Service, boost::asio::ip::tcp::endpoint(
boost::asio::ip::address::from_string(address), port)

2
i2pcontrol/I2PControlServer.h

@ -21,7 +21,7 @@ typedef std::array<char, I2P_CONTROL_MAX_REQUEST_SIZE> I2PControlBuffer; @@ -21,7 +21,7 @@ typedef std::array<char, I2P_CONTROL_MAX_REQUEST_SIZE> I2PControlBuffer;
class I2PControlService {
public:
I2PControlService(const std::string& address, int port);
I2PControlService(const std::string& address, int port, const std::string& pass);
~I2PControlService ();
void Start ();

Loading…
Cancel
Save