You've already forked torrent-client
mirror of
https://github.com/veggiedefender/torrent-client.git
synced 2025-11-06 09:29:16 +02:00
Handle keep-alive in recvBitfield
This commit is contained in:
@@ -52,6 +52,10 @@ func recvBitfield(conn net.Conn) (bitfield.Bitfield, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if msg == nil {
|
||||
err := fmt.Errorf("Expected bitfield but got %s", msg)
|
||||
return nil, err
|
||||
}
|
||||
if msg.ID != message.MsgBitfield {
|
||||
err := fmt.Errorf("Expected bitfield but got ID %d", msg.ID)
|
||||
return nil, err
|
||||
|
||||
@@ -48,6 +48,11 @@ func TestRecvBitfield(t *testing.T) {
|
||||
output: nil,
|
||||
fails: true,
|
||||
},
|
||||
"message is keep-alive": {
|
||||
msg: []byte{0x00, 0x00, 0x00, 0x00},
|
||||
output: nil,
|
||||
fails: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
Reference in New Issue
Block a user