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