2014-03-18 02:31:29 +04:00
|
|
|
#ifndef HTTP_PROXY_H__
|
|
|
|
#define HTTP_PROXY_H__
|
|
|
|
|
2015-01-07 02:15:38 +03:00
|
|
|
#include <memory>
|
|
|
|
#include <set>
|
2014-03-18 02:31:29 +04:00
|
|
|
#include <boost/asio.hpp>
|
2015-01-07 02:15:38 +03:00
|
|
|
#include <mutex>
|
2015-01-07 21:09:59 +03:00
|
|
|
#include "I2PService.h"
|
2014-03-30 02:16:23 +04:00
|
|
|
|
2014-03-18 02:31:29 +04:00
|
|
|
namespace i2p
|
|
|
|
{
|
|
|
|
namespace proxy
|
|
|
|
{
|
2015-01-07 21:09:59 +03:00
|
|
|
class HTTPProxyHandler;
|
|
|
|
class HTTPProxyServer: public i2p::client::I2PService
|
2014-03-18 02:31:29 +04:00
|
|
|
{
|
2015-01-07 02:15:38 +03:00
|
|
|
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;
|
2014-03-18 02:31:29 +04:00
|
|
|
|
|
|
|
private:
|
2015-01-07 02:15:38 +03:00
|
|
|
|
|
|
|
void Accept();
|
|
|
|
void HandleAccept(const boost::system::error_code& ecode, boost::asio::ip::tcp::socket * socket);
|
|
|
|
|
|
|
|
public:
|
2015-01-07 23:15:04 +03:00
|
|
|
HTTPProxyServer(int port) : I2PService(i2p::data::SIGNING_KEY_TYPE_DSA_SHA1),
|
2015-01-07 02:15:38 +03:00
|
|
|
m_Acceptor (GetService (), boost::asio::ip::tcp::endpoint (boost::asio::ip::tcp::v4(), port)),
|
|
|
|
m_Timer (GetService ()) {};
|
|
|
|
~HTTPProxyServer() { Stop(); }
|
|
|
|
|
|
|
|
void Start ();
|
|
|
|
void Stop ();
|
2014-03-30 02:16:23 +04:00
|
|
|
};
|
2015-01-07 02:15:38 +03:00
|
|
|
|
|
|
|
typedef HTTPProxyServer HTTPProxy;
|
2014-03-18 02:31:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-07 02:15:38 +03:00
|
|
|
#endif
|