aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-02-13 22:06:06 +0800
committerFelix Lange <fjl@twurst.com>2015-02-13 22:06:47 +0800
commitfd3e1061e01690c7046a0d80635284c1592b7699 (patch)
tree203e487ad4cd9096548a1851474295fa5cc8323c
parentcf754b9483a61075cf50eb4846eeecdc48ad37c0 (diff)
downloaddexon-fd3e1061e01690c7046a0d80635284c1592b7699.tar
dexon-fd3e1061e01690c7046a0d80635284c1592b7699.tar.gz
dexon-fd3e1061e01690c7046a0d80635284c1592b7699.tar.bz2
dexon-fd3e1061e01690c7046a0d80635284c1592b7699.tar.lz
dexon-fd3e1061e01690c7046a0d80635284c1592b7699.tar.xz
dexon-fd3e1061e01690c7046a0d80635284c1592b7699.tar.zst
dexon-fd3e1061e01690c7046a0d80635284c1592b7699.zip
p2p: handle disconnect before protocol handshake
-rw-r--r--p2p/peer.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/p2p/peer.go b/p2p/peer.go
index f779c1c02..6aa78045b 100644
--- a/p2p/peer.go
+++ b/p2p/peer.go
@@ -255,6 +255,13 @@ func readProtocolHandshake(p *Peer, rw MsgReadWriter) error {
if err != nil {
return err
}
+ if msg.Code == discMsg {
+ // disconnect before protocol handshake is valid according to the
+ // spec and we send it ourself if Server.addPeer fails.
+ var reason DiscReason
+ rlp.Decode(msg.Payload, &reason)
+ return discRequestedError(reason)
+ }
if msg.Code != handshakeMsg {
return newPeerError(errProtocolBreach, "expected handshake, got %x", msg.Code)
}