Skip to content

Commit

Permalink
Warn on unhandled v2 protocol messages
Browse files Browse the repository at this point in the history
  • Loading branch information
anacrolix committed Feb 28, 2024
1 parent e9355d9 commit fd97a99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions peer_protocol/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ const (

// BEP 10
Extended MessageType = 20

// BEP 52
HashRequest = 21
Hashes = 22
HashReject = 23
)

const (
Expand Down
2 changes: 2 additions & 0 deletions peerconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,8 @@ func (c *PeerConn) mainReadLoop() (err error) {
c.updateRequests("PeerConn.mainReadLoop allowed fast")
case pp.Extended:
err = c.onReadExtendedMsg(msg.ExtendedID, msg.ExtendedPayload)
case pp.HashRequest, pp.Hashes, pp.HashReject:
err = log.WithLevel(log.Warning, fmt.Errorf("received unimplemented BitTorrent v2 message: %v", msg.Type))
default:
err = fmt.Errorf("received unknown message type: %#v", msg.Type)
}
Expand Down

0 comments on commit fd97a99

Please sign in to comment.