forked from cerc-io/plugeth
p2p: handle disconnect before protocol handshake
This commit is contained in:
parent
cf754b9483
commit
fd3e1061e0
@ -255,6 +255,13 @@ func readProtocolHandshake(p *Peer, rw MsgReadWriter) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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 {
|
if msg.Code != handshakeMsg {
|
||||||
return newPeerError(errProtocolBreach, "expected handshake, got %x", msg.Code)
|
return newPeerError(errProtocolBreach, "expected handshake, got %x", msg.Code)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user