|
|
|
@ -302,36 +302,31 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { |
|
|
|
|
final DisconnectReason reason, |
|
|
|
|
final boolean initiatedByPeer) { |
|
|
|
|
ethPeers.registerDisconnect(connection); |
|
|
|
|
if (initiatedByPeer) { |
|
|
|
|
LOG.debug( |
|
|
|
|
"Peer requested to be disconnected ({}), {} peers left: {}", |
|
|
|
|
"Disconnect - {} - {} - {} - {} peers left", |
|
|
|
|
initiatedByPeer ? "Inbound" : "Outbound", |
|
|
|
|
reason, |
|
|
|
|
ethPeers.peerCount(), |
|
|
|
|
ethPeers); |
|
|
|
|
} else { |
|
|
|
|
LOG.debug( |
|
|
|
|
"Disconnecting from peer ({}), {} peers left: {}", |
|
|
|
|
reason, |
|
|
|
|
ethPeers.peerCount(), |
|
|
|
|
ethPeers); |
|
|
|
|
} |
|
|
|
|
connection.getPeerInfo(), |
|
|
|
|
ethPeers.peerCount()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handleStatusMessage(final EthPeer peer, final MessageData data) { |
|
|
|
|
final StatusMessage status = StatusMessage.readFrom(data); |
|
|
|
|
try { |
|
|
|
|
if (!status.networkId().equals(networkId)) { |
|
|
|
|
LOG.debug("Disconnecting from peer with mismatched network id: {}", status.networkId()); |
|
|
|
|
LOG.debug("{} has mismatched network id: {}", peer, status.networkId()); |
|
|
|
|
peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED); |
|
|
|
|
} else if (!forkIdManager.peerCheck(status.forkId()) && status.protocolVersion() > 63) { |
|
|
|
|
LOG.debug( |
|
|
|
|
"Disconnecting from peer with matching network id ({}), but non-matching fork id: {}", |
|
|
|
|
"{} has matching network id ({}), but non-matching fork id: {}", |
|
|
|
|
peer, |
|
|
|
|
networkId, |
|
|
|
|
status.forkId()); |
|
|
|
|
peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED); |
|
|
|
|
} else if (forkIdManager.peerCheck(status.genesisHash())) { |
|
|
|
|
LOG.debug( |
|
|
|
|
"Disconnecting from peer with matching network id ({}), but non-matching genesis hash: {}", |
|
|
|
|
"{} has matching network id ({}), but non-matching genesis hash: {}", |
|
|
|
|
peer, |
|
|
|
|
networkId, |
|
|
|
|
status.genesisHash()); |
|
|
|
|
peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED); |
|
|
|
@ -341,7 +336,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { |
|
|
|
|
status.bestHash(), status.totalDifficulty(), status.protocolVersion()); |
|
|
|
|
} |
|
|
|
|
} catch (final RLPException e) { |
|
|
|
|
LOG.debug("Unable to parse status message, disconnecting from peer.", e); |
|
|
|
|
LOG.debug("Unable to parse status message.", e); |
|
|
|
|
// Parsing errors can happen when clients broadcast network ids outside of the int range,
|
|
|
|
|
// So just disconnect with "subprotocol" error rather than "breach of protocol".
|
|
|
|
|
peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED); |
|
|
|
|