|
|
@ -226,6 +226,12 @@ void Host::startPeerSession(Public const& _id, RLP const& _rlp, RLPXFrameIO* _io |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (peerCount() > 2 * m_idealPeerCount) |
|
|
|
{ |
|
|
|
ps->disconnect(TooManyPeers); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// todo: mutex Session::m_capabilities and move for(:caps) out of mutex.
|
|
|
|
unsigned o = (unsigned)UserPacket; |
|
|
|
for (auto const& i: caps) |
|
|
@ -335,6 +341,15 @@ void Host::runAcceptor() |
|
|
|
auto socket = make_shared<RLPXSocket>(new bi::tcp::socket(m_ioService)); |
|
|
|
m_tcp4Acceptor.async_accept(socket->ref(), [=](boost::system::error_code ec) |
|
|
|
{ |
|
|
|
if (peerCount() > 2 * m_idealPeerCount) |
|
|
|
{ |
|
|
|
clog(NetConnect) << "Dropping incoming connect due to maximum peer count (2 * ideal peer count): " << socket->remoteEndpoint(); |
|
|
|
socket->close(); |
|
|
|
if (ec.value() < 1) |
|
|
|
runAcceptor(); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// if no error code
|
|
|
|
bool success = false; |
|
|
|
if (!ec) |
|
|
|