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.
57 lines
1.6 KiB
57 lines
1.6 KiB
9 years ago
|
#ifndef I2P_CONTROL_SERVER_H__
|
||
|
#define I2P_CONTROL_SERVER_H__
|
||
|
|
||
|
#include "I2PControl.h"
|
||
|
#include <inttypes.h>
|
||
|
#include <thread>
|
||
|
#include <memory>
|
||
|
#include <array>
|
||
|
#include <string>
|
||
|
#include <sstream>
|
||
|
#include <boost/asio.hpp>
|
||
|
|
||
|
namespace i2p {
|
||
|
namespace client {
|
||
|
|
||
|
const size_t I2P_CONTROL_MAX_REQUEST_SIZE = 1024;
|
||
|
typedef std::array<char, I2P_CONTROL_MAX_REQUEST_SIZE> I2PControlBuffer;
|
||
|
|
||
|
class I2PControlService {
|
||
|
public:
|
||
|
|
||
9 years ago
|
I2PControlService(const std::string& address, int port, const std::string& pass);
|
||
9 years ago
|
~I2PControlService();
|
||
9 years ago
|
|
||
9 years ago
|
void Start();
|
||
|
void Stop();
|
||
9 years ago
|
|
||
|
private:
|
||
|
|
||
9 years ago
|
void Run();
|
||
|
void Accept();
|
||
9 years ago
|
void HandleAccept(const boost::system::error_code& ecode, std::shared_ptr<boost::asio::ip::tcp::socket> socket);
|
||
9 years ago
|
void ReadRequest(std::shared_ptr<boost::asio::ip::tcp::socket> socket);
|
||
|
void HandleRequestReceived(const boost::system::error_code& ecode, size_t bytes_transferred,
|
||
9 years ago
|
std::shared_ptr<boost::asio::ip::tcp::socket> socket, std::shared_ptr<I2PControlBuffer> buf);
|
||
9 years ago
|
void SendResponse(std::shared_ptr<boost::asio::ip::tcp::socket> socket,
|
||
9 years ago
|
std::shared_ptr<I2PControlBuffer> buf, const std::string& response, bool isHtml);
|
||
9 years ago
|
void HandleResponseSent(const boost::system::error_code& ecode, std::size_t bytes_transferred,
|
||
9 years ago
|
std::shared_ptr<boost::asio::ip::tcp::socket> socket, std::shared_ptr<I2PControlBuffer> buf);
|
||
|
|
||
|
private:
|
||
|
|
||
|
bool m_IsRunning;
|
||
|
std::thread * m_Thread;
|
||
|
|
||
|
boost::asio::io_service m_Service;
|
||
|
boost::asio::ip::tcp::acceptor m_Acceptor;
|
||
|
|
||
9 years ago
|
std::shared_ptr<I2PControlSession> m_Session;
|
||
9 years ago
|
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endif
|
||
|
|