2014-10-16 00:52:17 +00:00
|
|
|
#ifndef CLIENT_CONTEXT_H__
|
|
|
|
#define CLIENT_CONTEXT_H__
|
|
|
|
|
2015-02-13 15:18:42 +00:00
|
|
|
#include <map>
|
2014-10-16 00:52:17 +00:00
|
|
|
#include <mutex>
|
2015-02-12 21:11:56 +00:00
|
|
|
#include <memory>
|
2014-10-16 00:52:17 +00:00
|
|
|
#include "Destination.h"
|
2014-10-16 01:39:39 +00:00
|
|
|
#include "HTTPProxy.h"
|
|
|
|
#include "SOCKS.h"
|
|
|
|
#include "I2PTunnel.h"
|
|
|
|
#include "SAM.h"
|
2014-12-02 15:34:02 +00:00
|
|
|
#include "BOB.h"
|
2014-10-24 19:22:36 +00:00
|
|
|
#include "AddressBook.h"
|
2015-01-08 18:28:51 +00:00
|
|
|
#include "I2PControl.h"
|
2014-10-16 00:52:17 +00:00
|
|
|
|
|
|
|
namespace i2p
|
|
|
|
{
|
|
|
|
namespace client
|
|
|
|
{
|
2015-02-12 21:11:56 +00:00
|
|
|
const char I2P_CLIENT_TUNNEL_NAME[] = "client.name";
|
|
|
|
const char I2P_CLIENT_TUNNEL_PORT[] = "client.port";
|
|
|
|
const char I2P_CLIENT_TUNNEL_DESTINATION[] = "client.destination";
|
|
|
|
const char I2P_CLIENT_TUNNEL_KEYS[] = "client.keys";
|
2015-02-13 20:56:57 +00:00
|
|
|
const char I2P_SERVER_TUNNEL_NAME[] = "server.name";
|
|
|
|
const char I2P_SERVER_TUNNEL_HOST[] = "server.host";
|
|
|
|
const char I2P_SERVER_TUNNEL_PORT[] = "server.port";
|
|
|
|
const char I2P_SERVER_TUNNEL_KEYS[] = "server.keys";
|
2015-02-12 21:11:56 +00:00
|
|
|
const char TUNNELS_CONFIG_FILENAME[] = "tunnels.cfg";
|
|
|
|
|
2014-10-16 00:52:17 +00:00
|
|
|
class ClientContext
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2014-10-16 01:39:39 +00:00
|
|
|
ClientContext ();
|
|
|
|
~ClientContext ();
|
2014-10-16 00:52:17 +00:00
|
|
|
|
|
|
|
void Start ();
|
|
|
|
void Stop ();
|
|
|
|
|
2014-10-22 15:46:54 +00:00
|
|
|
ClientDestination * GetSharedLocalDestination () const { return m_SharedLocalDestination; };
|
2014-11-30 15:51:22 +00:00
|
|
|
ClientDestination * CreateNewLocalDestination (bool isPublic = false, i2p::data::SigningKeyType sigType = i2p::data::SIGNING_KEY_TYPE_DSA_SHA1,
|
|
|
|
const std::map<std::string, std::string> * params = nullptr); // transient
|
|
|
|
ClientDestination * CreateNewLocalDestination (const i2p::data::PrivateKeys& keys, bool isPublic = true,
|
|
|
|
const std::map<std::string, std::string> * params = nullptr);
|
2014-10-22 15:46:54 +00:00
|
|
|
void DeleteLocalDestination (ClientDestination * destination);
|
|
|
|
ClientDestination * FindLocalDestination (const i2p::data::IdentHash& destination) const;
|
|
|
|
ClientDestination * LoadLocalDestination (const std::string& filename, bool isPublic);
|
2014-10-16 00:52:17 +00:00
|
|
|
|
2014-10-24 19:22:36 +00:00
|
|
|
AddressBook& GetAddressBook () { return m_AddressBook; };
|
2015-02-12 21:11:56 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void ReadTunnels ();
|
|
|
|
|
2014-10-16 00:52:17 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
std::mutex m_DestinationsMutex;
|
2014-10-22 15:46:54 +00:00
|
|
|
std::map<i2p::data::IdentHash, ClientDestination *> m_Destinations;
|
|
|
|
ClientDestination * m_SharedLocalDestination;
|
2014-10-16 00:52:17 +00:00
|
|
|
|
2014-10-24 19:22:36 +00:00
|
|
|
AddressBook m_AddressBook;
|
|
|
|
|
2014-10-16 01:39:39 +00:00
|
|
|
i2p::proxy::HTTPProxy * m_HttpProxy;
|
|
|
|
i2p::proxy::SOCKSProxy * m_SocksProxy;
|
2015-02-13 15:18:42 +00:00
|
|
|
std::map<int, std::unique_ptr<I2PClientTunnel> > m_ClientTunnels; // port->tunnel
|
2015-02-13 20:56:57 +00:00
|
|
|
std::map<i2p::data::IdentHash, std::unique_ptr<I2PServerTunnel> > m_ServerTunnels; // destination->tunnel
|
2014-10-16 14:28:44 +00:00
|
|
|
SAMBridge * m_SamBridge;
|
2014-12-02 15:34:02 +00:00
|
|
|
BOBCommandChannel * m_BOBCommandChannel;
|
2015-01-08 18:28:51 +00:00
|
|
|
I2PControlService * m_I2PControlService;
|
2014-10-16 01:39:39 +00:00
|
|
|
|
2014-10-16 00:52:17 +00:00
|
|
|
public:
|
|
|
|
// for HTTP
|
|
|
|
const decltype(m_Destinations)& GetDestinations () const { return m_Destinations; };
|
|
|
|
};
|
|
|
|
|
|
|
|
extern ClientContext context;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|