Check protocol version, on both connection sides, before parsing any packet
This fixes 2 issues: - Because neoctl connects to admin nodes without requesting identification, the protocol version was not checked, which could even be dangerous (think of a user asking for information, but the packet sent by neoctl could be decoded as a packet to alter data, like Truncate). - In case of mismatched protocol version, the error was not loggued on the node that initiated the connection. Compatibility is handled as follows: - For an old node receiving data from a new node, the 2 high order bytes of the packet id, which is always 0 for the first packet, is decoded as the packet code. Packet 0 has never existed, which results in PacketMalformedError. - For a new node receiving data from an old node, the id of the first packet, which is always 0, is decoded as the version, which results in a version mismatch error. This new protocol also guarantees that there's no conflict with SSL. For simplification, the packet length does not count the header anymore.
Showing
This diff is collapsed.
This diff is collapsed.
Please register or sign in to comment