File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ func markDialError(err error) {
6868 return
6969 }
7070
71+ var e * protoHandshakeError
7172 switch {
7273 case errors .Is (err , DiscTooManyPeers ):
7374 dialTooManyPeers .Mark (1 )
@@ -81,7 +82,7 @@ func markDialError(err error) {
8182 dialUnexpectedIdentity .Mark (1 )
8283 case errors .Is (err , errEncHandshakeError ):
8384 dialEncHandshakeError .Mark (1 )
84- case errors .Is (err , errProtoHandshakeError ):
85+ case errors .As (err , & e ):
8586 dialProtoHandshakeError .Mark (1 )
8687 }
8788}
Original file line number Diff line number Diff line change @@ -66,11 +66,15 @@ const (
6666)
6767
6868var (
69- errServerStopped = errors .New ("server stopped" )
70- errEncHandshakeError = errors .New ("rlpx enc error" )
71- errProtoHandshakeError = errors .New ("rlpx proto error" )
69+ errServerStopped = errors .New ("server stopped" )
70+ errEncHandshakeError = errors .New ("rlpx enc error" )
7271)
7372
73+ type protoHandshakeError struct { err error }
74+
75+ func (e * protoHandshakeError ) Error () string { return fmt .Sprintf ("rlpx proto error: %s" , e .err ) }
76+ func (e * protoHandshakeError ) Unwrap () error { return e .err }
77+
7478// Server manages all peer connections.
7579type Server struct {
7680 // Config fields may not be modified while the server is running.
@@ -908,7 +912,7 @@ func (srv *Server) setupConn(c *conn, dialDest *enode.Node) error {
908912 if err != nil {
909913 clog .Trace ("Failed p2p handshake" , "err" , err )
910914 //Wrapping both errors for later inspection
911- return fmt . Errorf ( "%w: %w" , errProtoHandshakeError , err )
915+ return & protoHandshakeError { err : err }
912916 }
913917 if id := c .node .ID (); ! bytes .Equal (crypto .Keccak256 (phs .ID ), id [:]) {
914918 clog .Trace ("Wrong devp2p handshake identity" , "phsid" , hex .EncodeToString (phs .ID ))
You can’t perform that action at this time.
0 commit comments