i2pd/SOCKS.h

44 lines
870 B
C
Raw Normal View History

2015-01-03 22:18:05 +01:00
#ifndef SOCKS_H__
#define SOCKS_H__
2014-07-14 18:40:06 +02:00
2014-11-23 17:33:58 +01:00
#include <memory>
#include <set>
#include <boost/asio.hpp>
#include <mutex>
#include "I2PService.h"
2014-07-14 18:40:06 +02:00
namespace i2p
{
namespace proxy
{
class SOCKSHandler;
class SOCKSServer: public i2p::client::I2PService
{
private:
std::set<std::shared_ptr<SOCKSHandler> > 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);
2014-07-14 18:40:06 +02:00
public:
SOCKSServer(int port) : I2PService(nullptr),
m_Acceptor (GetService (), boost::asio::ip::tcp::endpoint (boost::asio::ip::tcp::v4(), port)),
m_Timer (GetService ()) {};
2015-01-03 21:57:15 +01:00
~SOCKSServer() { Stop(); }
void Start ();
void Stop ();
};
2014-07-14 18:40:06 +02:00
2015-01-03 21:57:15 +01:00
typedef SOCKSServer SOCKSProxy;
2014-07-14 18:40:06 +02:00
}
}
#endif