Make the HTTP Proxy use TCPIPAcceptor

This commit is contained in:
Francisco Blas (klondike) Izquierdo Riera 2015-01-08 01:35:42 +01:00
parent 114022d18a
commit 8a6bea64bc
2 changed files with 9 additions and 52 deletions

View file

@ -231,41 +231,9 @@ namespace proxy
}
}
void HTTPProxyServer::Start ()
std::shared_ptr<i2p::client::I2PServiceHandler> HTTPProxyServer::CreateHandler(boost::asio::ip::tcp::socket * socket)
{
m_Acceptor.listen ();
Accept ();
}
void HTTPProxyServer::Stop ()
{
m_Acceptor.close();
m_Timer.cancel ();
ClearHandlers();
}
void HTTPProxyServer::Accept ()
{
auto newSocket = new boost::asio::ip::tcp::socket (GetService ());
m_Acceptor.async_accept (*newSocket, std::bind (&HTTPProxyServer::HandleAccept, this,
std::placeholders::_1, newSocket));
}
void HTTPProxyServer::HandleAccept (const boost::system::error_code& ecode, boost::asio::ip::tcp::socket * socket)
{
if (!ecode)
{
LogPrint(eLogDebug,"--- HTTP Proxy accepted");
auto handler = std::make_shared<HTTPProxyHandler> (this, socket);
AddHandler(handler);
handler->Handle();
Accept();
}
else
{
LogPrint (eLogError,"--- HTTP Proxy Closing socket on accept because: ", ecode.message ());
delete socket;
}
return std::make_shared<HTTPProxyHandler> (this, socket);
}
}