|
|
@ -11,28 +11,16 @@ namespace i2p |
|
|
|
{ |
|
|
|
{ |
|
|
|
namespace proxy |
|
|
|
namespace proxy |
|
|
|
{ |
|
|
|
{ |
|
|
|
class SOCKSHandler; |
|
|
|
class SOCKSServer: public i2p::client::TCPIPAcceptor |
|
|
|
class SOCKSServer: public i2p::client::I2PService |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
private: |
|
|
|
protected: |
|
|
|
std::set<std::shared_ptr<SOCKSHandler> > m_Handlers; |
|
|
|
// Implements TCPIPAcceptor
|
|
|
|
boost::asio::ip::tcp::acceptor m_Acceptor; |
|
|
|
std::shared_ptr<i2p::client::I2PServiceHandler> CreateHandler(boost::asio::ip::tcp::socket * socket); |
|
|
|
boost::asio::deadline_timer m_Timer; |
|
|
|
const char* GetName() { return "SOCKS"; } |
|
|
|
std::mutex m_HandlersMutex; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Accept(); |
|
|
|
|
|
|
|
void HandleAccept(const boost::system::error_code& ecode, boost::asio::ip::tcp::socket * socket); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
public: |
|
|
|
SOCKSServer(int port) : I2PService(nullptr), |
|
|
|
SOCKSServer(int port) : TCPIPAcceptor(port) {} |
|
|
|
m_Acceptor (GetService (), boost::asio::ip::tcp::endpoint (boost::asio::ip::tcp::v4(), port)), |
|
|
|
~SOCKSServer() {} |
|
|
|
m_Timer (GetService ()) {}; |
|
|
|
|
|
|
|
~SOCKSServer() { Stop(); } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Start (); |
|
|
|
|
|
|
|
void Stop (); |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
typedef SOCKSServer SOCKSProxy; |
|
|
|
typedef SOCKSServer SOCKSProxy; |
|
|
|