forked from Qortal/qortal
Immediately close socketChannels after accepting peers we won't use
This commit is contained in:
parent
12f9ecaaca
commit
4a4678b331
@ -481,18 +481,20 @@ public class Network {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (now == null) {
|
if (now == null) {
|
||||||
LOGGER.debug(String.format("Connection discarded from peer %s due to lack of NTP sync", socketChannel.getRemoteAddress()));
|
LOGGER.debug(() -> String.format("Connection discarded from peer %s due to lack of NTP sync", PeerAddress.fromSocket(socketChannel.socket())));
|
||||||
|
socketChannel.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (this.connectedPeers) {
|
synchronized (this.connectedPeers) {
|
||||||
if (connectedPeers.size() >= maxPeers) {
|
if (connectedPeers.size() >= maxPeers) {
|
||||||
// We have enough peers
|
// We have enough peers
|
||||||
LOGGER.debug(String.format("Connection discarded from peer %s", socketChannel.getRemoteAddress()));
|
LOGGER.debug(() -> String.format("Connection discarded from peer %s", PeerAddress.fromSocket(socketChannel.socket())));
|
||||||
|
socketChannel.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.debug(String.format("Connection accepted from peer %s", socketChannel.getRemoteAddress()));
|
LOGGER.debug(() -> String.format("Connection accepted from peer %s", PeerAddress.fromSocket(socketChannel.socket())));
|
||||||
|
|
||||||
newPeer = new Peer(socketChannel);
|
newPeer = new Peer(socketChannel);
|
||||||
this.connectedPeers.add(newPeer);
|
this.connectedPeers.add(newPeer);
|
||||||
|
Loading…
Reference in New Issue
Block a user