mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Only touch remote_endpoint under a try/catch block.
This commit is contained in:
@@ -49,8 +49,16 @@ void RPCDoor::handleConnect(RPCServer::pointer new_connection,
|
||||
if (!error)
|
||||
{
|
||||
// Restrict callers by IP
|
||||
if (!isClientAllowed(new_connection->getSocket().remote_endpoint().address().to_string()))
|
||||
try
|
||||
{
|
||||
if (!isClientAllowed(new_connection->getSocket().remote_endpoint().address().to_string()))
|
||||
{
|
||||
startListening();
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{ // client may have disconnected
|
||||
startListening();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -141,7 +141,13 @@ public:
|
||||
{
|
||||
boost::mutex::scoped_lock sl(mMapLock);
|
||||
|
||||
mMap[cpClient] = boost::make_shared< WSConnection<endpoint_type> >(this, cpClient);
|
||||
try
|
||||
{
|
||||
mMap[cpClient] = boost::make_shared< WSConnection<endpoint_type> >(this, cpClient);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void on_pong(connection_ptr cpClient, std::string data)
|
||||
|
||||
@@ -412,9 +412,21 @@ void PeerImp::handleConnect(const boost::system::error_code& error, boost::asio:
|
||||
// - We don't bother remembering the inbound IP or port. Only useful for debugging.
|
||||
void PeerImp::connected(const boost::system::error_code& error)
|
||||
{
|
||||
boost::asio::ip::tcp::endpoint ep = getSocket().remote_endpoint();
|
||||
int iPort = ep.port();
|
||||
std::string strIp = ep.address().to_string();
|
||||
boost::asio::ip::tcp::endpoint ep;
|
||||
int iPort;
|
||||
std::string strIp;
|
||||
|
||||
try
|
||||
{
|
||||
ep = getSocket().remote_endpoint();
|
||||
iPort = ep.port();
|
||||
strIp = ep.address().to_string();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
detach("edc", false);
|
||||
return;
|
||||
}
|
||||
|
||||
mClientConnect = false;
|
||||
mIpPortConnect = make_pair(strIp, iPort);
|
||||
|
||||
Reference in New Issue
Block a user