diff options
author | Cory Fields <cory-nospam-@coryfields.com> | 2017-02-08 01:04:53 -0500 |
---|---|---|
committer | Cory Fields <cory-nospam-@coryfields.com> | 2017-02-13 18:55:35 -0500 |
commit | cbfc5a6728d389fbb15e0555cdf50f1b04595106 (patch) | |
tree | 81dc1e8af09985a0bb8ec094af118261cd84c595 /src/net_processing.cpp | |
parent | 8502e7acbe0f42fd6e6979681bc9c4610c4fb8cb (diff) |
net: require a verack before responding to anything else
7a8c251901 made this logic hard to follow. After that change, messages would
not be sent to a peer via SendMessages() before the handshake was complete, but
messages could still be sent as a response to an incoming message.
For example, if a peer had not yet sent a verack, we wouldn't notify it about
new blocks, but we would respond to a PING with a PONG.
This change makes the behavior straightforward: until we've received a verack,
never send any message other than version/verack/reject.
The behavior until a VERACK is received has always been undefined, this change
just tightens our policy.
This also makes testing much easier, because we can now connect but not send
version/verack, and anything sent to us is an error.
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r-- | src/net_processing.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index b304da76c2..f458a35256 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1420,6 +1420,13 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr pfrom->fSuccessfullyConnected = true; } + else if (!pfrom->fSuccessfullyConnected) + { + // Must have a verack message before anything else + LOCK(cs_main); + Misbehaving(pfrom->GetId(), 1); + return false; + } else if (strCommand == NetMsgType::ADDR) { |