mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-13 01:20:22 +03:00
42 lines
930 B
C++
42 lines
930 B
C++
#ifndef HTTP_PROXY_H__
|
|
#define HTTP_PROXY_H__
|
|
|
|
#include <memory>
|
|
#include <set>
|
|
#include <boost/asio.hpp>
|
|
#include <mutex>
|
|
#include "I2PService.h"
|
|
|
|
namespace i2p
|
|
{
|
|
namespace proxy
|
|
{
|
|
class HTTPProxyHandler;
|
|
class HTTPProxyServer: public i2p::client::I2PService
|
|
{
|
|
private:
|
|
std::set<std::shared_ptr<HTTPProxyHandler> > m_Handlers;
|
|
boost::asio::ip::tcp::acceptor m_Acceptor;
|
|
boost::asio::deadline_timer m_Timer;
|
|
std::mutex m_HandlersMutex;
|
|
|
|
private:
|
|
|
|
void Accept();
|
|
void HandleAccept(const boost::system::error_code& ecode, boost::asio::ip::tcp::socket * socket);
|
|
|
|
public:
|
|
HTTPProxyServer(int port) : I2PService(i2p::data::SIGNING_KEY_TYPE_DSA_SHA1),
|
|
m_Acceptor (GetService (), boost::asio::ip::tcp::endpoint (boost::asio::ip::tcp::v4(), port)),
|
|
m_Timer (GetService ()) {};
|
|
~HTTPProxyServer() { Stop(); }
|
|
|
|
void Start ();
|
|
void Stop ();
|
|
};
|
|
|
|
typedef HTTPProxyServer HTTPProxy;
|
|
}
|
|
}
|
|
|
|
#endif |