Commit Graph

10 Commits

Author SHA1 Message Date
Felix Lange
79a6782c1c p2p: fix goroutine leak when handshake read fails
This regression was introduced in b3c058a9e4.
2015-04-13 17:06:19 +02:00
Felix Lange
b3c058a9e4 p2p: improve disconnect signaling at handshake time
As of this commit, p2p will disconnect nodes directly after the
encryption handshake if too many peer connections are active.
Errors in the protocol handshake packet are now handled more politely
by sending a disconnect packet before closing the connection.
2015-04-10 16:57:56 +02:00
Felix Lange
f1d710af00 p2p: fix Peer shutdown deadlocks
There were multiple synchronization issues in the disconnect handling,
all caused by the odd special-casing of Peer.readLoop errors. Remove the
special handling of read errors and make readLoop part of the Peer
WaitGroup.

Thanks to @Gustav-Simonsson for pointing at arrows in a diagram
and playing rubber-duck.
2015-04-10 13:26:27 +02:00
Felix Lange
5ba51594c7 p2p: use package rlp to encode messages
Message encoding functions have been renamed to catch any uses.
The switch to the new encoder can cause subtle incompatibilities.
If there are any users outside of our tree, they will at least be
alerted that there was a change.

NewMsg no longer exists. The replacements for EncodeMsg are called
Send and SendItems.
2015-03-19 15:11:02 +01:00
Felix Lange
22659a7fea p2p: restore read/write timeouts
They got lost in the transition to rlpxFrameRW.
2015-03-04 16:42:00 +01:00
Felix Lange
21649100b1 p2p: verify protocol handshake node ID 2015-03-04 12:27:24 +01:00
Felix Lange
7d39fd6678 p2p: make encryption handshake code easier to follow
This mostly changes how information is passed around.
Instead of using many function parameters and return values,
put the entire state in a struct and pass that.

This also adds back derivation of ecdhe-shared-secret. I deleted
it by accident in a previous refactoring.
2015-03-04 12:27:24 +01:00
Felix Lange
736e632215 p2p: use RLPx frames for messaging 2015-03-04 12:27:23 +01:00
Felix Lange
51e01cceca p2p: encrypted and authenticated RLPx frame I/O 2015-03-04 12:27:23 +01:00
Felix Lange
73f94f3755 p2p: disable encryption handshake
The diff is a bit bigger than expected because the protocol handshake
logic has moved out of Peer. This is necessary because the protocol
handshake will have custom framing in the final protocol.
2015-02-19 16:54:53 +01:00