Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Log disconnect reason when receiving disconnect packet during RLPX handshake #5569

@halfalicious

Description

@halfalicious

Running a private build of #5568 and I'm seeing some nodes which respond to our auth with an auth-ack then send us a Disconnect message instead of a Hello message. For example:

DEBUG 04-14 21:58:07 p2p  rlpx   p2p.connect.egress: HelloPacket to ##15ac307a…@52.176.7.10:30303
DEBUG 04-14 21:58:07 p2p  rlpx   p2p.connect.egress: Frame header from ##15ac307a…@52.176.7.10:30303
DEBUG 04-14 21:58:07 p2p  rlpx   p2p.connect.egress: Successfully decrypted frame header from ##15ac307a…@52.176.7.10:30303. Validating contents...
DEBUG 04-14 21:58:07 p2p  rlpx   p2p.connect.egress: Frame body from ##15ac307a…@52.176.7.10:30303
DEBUG 04-14 21:58:07 p2p  rlpx   p2p.connect.egress: Invalid packet type. Expected: HelloPacket, received: DisconnectPacket (##15ac307a…@52.176.7.10:30303)
DEBUG 04-14 21:58:07 p2p  rlpx   p2p.connect.egress: Handshake Failed (##15ac307a…@52.176.7.10:30303)

According to the Disconnect message description in the RLPX spec, the message can include an optional reason:

reason is an optional integer specifying one of a number of reasons for disconnect:
    0x00 Disconnect requested;
    0x01 TCP sub-system error;
    0x02 Breach of protocol, e.g. a malformed message, bad RLP, incorrect magic number &c.;
    0x03 Useless peer;
    0x04 Too many peers;
    0x05 Already connected;
    0x06 Incompatible P2P protocol version;
    0x07 Null node identity received - this is automatically invalid;
    0x08 Client quitting;
    0x09 Unexpected identity (i.e. a different identity to a previous connection/what a trusted peer told us).
    0x0a Identity is the same as this node (i.e. connected to itself);
    0x0b Timeout on receiving a message (i.e. nothing received since sending last ping);
    0x10 Some other reason specific to a subprotocol.

We should log this reason (if it's available in the packet).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions