mirror of https://github.com/PurpleI2P/i2pd.git
I2P: End-to-End encrypted and anonymous Internet
https://i2pd.website/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
3.3 KiB
87 lines
3.3 KiB
10 years ago
|
#ifndef CLIENT_CONTEXT_H__
|
||
|
#define CLIENT_CONTEXT_H__
|
||
|
|
||
10 years ago
|
#include <map>
|
||
10 years ago
|
#include <mutex>
|
||
10 years ago
|
#include <memory>
|
||
10 years ago
|
#include "Destination.h"
|
||
10 years ago
|
#include "HTTPProxy.h"
|
||
|
#include "SOCKS.h"
|
||
|
#include "I2PTunnel.h"
|
||
|
#include "SAM.h"
|
||
10 years ago
|
#include "BOB.h"
|
||
10 years ago
|
#include "AddressBook.h"
|
||
9 years ago
|
#include "i2pcontrol/I2PControlServer.h"
|
||
10 years ago
|
|
||
|
namespace i2p
|
||
|
{
|
||
|
namespace client
|
||
|
{
|
||
10 years ago
|
const char I2P_TUNNELS_SECTION_TYPE[] = "type";
|
||
|
const char I2P_TUNNELS_SECTION_TYPE_CLIENT[] = "client";
|
||
|
const char I2P_TUNNELS_SECTION_TYPE_SERVER[] = "server";
|
||
|
const char I2P_TUNNELS_SECTION_TYPE_HTTP[] = "http";
|
||
|
const char I2P_CLIENT_TUNNEL_PORT[] = "port";
|
||
9 years ago
|
const char I2P_CLIENT_TUNNEL_ADDRESS[] = "address";
|
||
10 years ago
|
const char I2P_CLIENT_TUNNEL_DESTINATION[] = "destination";
|
||
|
const char I2P_CLIENT_TUNNEL_KEYS[] = "keys";
|
||
|
const char I2P_CLIENT_TUNNEL_DESTINATION_PORT[] = "destinationport";
|
||
|
const char I2P_SERVER_TUNNEL_HOST[] = "host";
|
||
|
const char I2P_SERVER_TUNNEL_PORT[] = "port";
|
||
|
const char I2P_SERVER_TUNNEL_KEYS[] = "keys";
|
||
|
const char I2P_SERVER_TUNNEL_INPORT[] = "inport";
|
||
|
const char I2P_SERVER_TUNNEL_ACCESS_LIST[] = "accesslist";
|
||
10 years ago
|
|
||
10 years ago
|
class ClientContext
|
||
|
{
|
||
|
public:
|
||
10 years ago
|
|
||
10 years ago
|
ClientContext ();
|
||
|
~ClientContext ();
|
||
10 years ago
|
|
||
10 years ago
|
void Start ();
|
||
|
void Stop ();
|
||
10 years ago
|
|
||
10 years ago
|
std::shared_ptr<ClientDestination> GetSharedLocalDestination () const { return m_SharedLocalDestination; };
|
||
|
std::shared_ptr<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
|
||
|
std::shared_ptr<ClientDestination> CreateNewLocalDestination (const i2p::data::PrivateKeys& keys, bool isPublic = true,
|
||
|
const std::map<std::string, std::string> * params = nullptr);
|
||
|
void DeleteLocalDestination (std::shared_ptr<ClientDestination> destination);
|
||
|
std::shared_ptr<ClientDestination> FindLocalDestination (const i2p::data::IdentHash& destination) const;
|
||
|
std::shared_ptr<ClientDestination> LoadLocalDestination (const std::string& filename, bool isPublic);
|
||
10 years ago
|
|
||
10 years ago
|
AddressBook& GetAddressBook () { return m_AddressBook; };
|
||
|
const SAMBridge * GetSAMBridge () const { return m_SamBridge; };
|
||
|
|
||
|
private:
|
||
10 years ago
|
|
||
10 years ago
|
void ReadTunnels ();
|
||
|
|
||
|
private:
|
||
10 years ago
|
|
||
10 years ago
|
std::mutex m_DestinationsMutex;
|
||
|
std::map<i2p::data::IdentHash, std::shared_ptr<ClientDestination> > m_Destinations;
|
||
|
std::shared_ptr<ClientDestination> m_SharedLocalDestination;
|
||
10 years ago
|
|
||
10 years ago
|
AddressBook m_AddressBook;
|
||
10 years ago
|
|
||
10 years ago
|
i2p::proxy::HTTPProxy * m_HttpProxy;
|
||
|
i2p::proxy::SOCKSProxy * m_SocksProxy;
|
||
|
std::map<int, std::unique_ptr<I2PClientTunnel> > m_ClientTunnels; // port->tunnel
|
||
|
std::map<i2p::data::IdentHash, std::unique_ptr<I2PServerTunnel> > m_ServerTunnels; // destination->tunnel
|
||
|
SAMBridge * m_SamBridge;
|
||
|
BOBCommandChannel * m_BOBCommandChannel;
|
||
|
I2PControlService * m_I2PControlService;
|
||
10 years ago
|
|
||
10 years ago
|
public:
|
||
|
// for HTTP
|
||
|
const decltype(m_Destinations)& GetDestinations () const { return m_Destinations; };
|
||
|
};
|
||
|
|
||
|
extern ClientContext context;
|
||
|
}
|
||
|
}
|
||
10 years ago
|
|
||
|
#endif
|