fix 1 byte long disconnect reason (#4150)

Signed-off-by: Stefan <stefan.pingel@consensys.net>
pull/4155/head
Stefan Pingel 2 years ago committed by GitHub
parent de91d3122b
commit be133b8d34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/DeFramer.java
  2. 11
      ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/wire/messages/DisconnectMessage.java

@ -205,7 +205,7 @@ final class DeFramer extends ByteToMessageDecoder {
if (remoteAddress == null) {
return Optional.empty();
}
int port = peerInfo.getPort();
final int port = peerInfo.getPort();
return Optional.of(
DefaultPeer.fromEnodeURL(
EnodeURLImpl.builder()

@ -80,9 +80,14 @@ public final class DisconnectMessage extends AbstractMessageData {
}
public static Data readFrom(final RLPInput in) {
in.enterList();
Bytes reasonData = in.readBytes();
in.leaveList();
Bytes reasonData = Bytes.EMPTY;
if (in.nextIsList()) {
in.enterList();
reasonData = in.readBytes();
in.leaveList();
} else if (in.nextSize() == 1) {
reasonData = in.readBytes();
}
// Disconnect reason should be at most 1 byte, otherwise, just return UNKNOWN
final DisconnectReason reason =

Loading…
Cancel
Save