[services] handle binding errors in tunnels, webconsole

Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
R4SAS 2019-05-17 11:04:44 +03:00
parent 4d48d35ad7
commit d991cc3b96
No known key found for this signature in database
GPG key ID: 66F6C87B98EBCFE2
4 changed files with 18 additions and 9 deletions

View file

@ -1226,10 +1226,15 @@ namespace http {
i2p::config::SetOption("http.pass", pass); i2p::config::SetOption("http.pass", pass);
LogPrint(eLogInfo, "HTTPServer: password set to ", pass); LogPrint(eLogInfo, "HTTPServer: password set to ", pass);
} }
try {
m_IsRunning = true; m_IsRunning = true;
m_Thread = std::unique_ptr<std::thread>(new std::thread (std::bind (&HTTPServer::Run, this))); m_Thread = std::unique_ptr<std::thread>(new std::thread (std::bind (&HTTPServer::Run, this)));
m_Acceptor.listen (); m_Acceptor.listen ();
Accept (); Accept ();
} catch (std::exception& ex) {
LogPrint (eLogError, "HTTPServer: failed to start webconsole: ", ex.what ());
}
} }
void HTTPServer::Stop () void HTTPServer::Stop ()

View file

@ -285,8 +285,12 @@ namespace client
m_Acceptor.reset (new boost::asio::ip::tcp::acceptor (GetService (), m_LocalEndpoint)); m_Acceptor.reset (new boost::asio::ip::tcp::acceptor (GetService (), m_LocalEndpoint));
// update the local end point in case port has been set zero and got updated now // update the local end point in case port has been set zero and got updated now
m_LocalEndpoint = m_Acceptor->local_endpoint(); m_LocalEndpoint = m_Acceptor->local_endpoint();
try {
m_Acceptor->listen (); m_Acceptor->listen ();
Accept (); Accept ();
} catch (std::exception& ex) {
LogPrint (eLogError, "I2PService: failed to start ", GetName(), " acceptor: ", ex.what ());
}
} }
void TCPIPAcceptor::Stop () void TCPIPAcceptor::Stop ()

View file

@ -389,7 +389,7 @@ namespace client
} }
/* This handler tries to stablish a connection with the desired server and dies if it fails to do so */ /* This handler tries to establish a connection with the desired server and dies if it fails to do so */
class I2PClientTunnelHandler: public I2PServiceHandler, public std::enable_shared_from_this<I2PClientTunnelHandler> class I2PClientTunnelHandler: public I2PServiceHandler, public std::enable_shared_from_this<I2PClientTunnelHandler>
{ {
public: public: