diff --git a/p2p/client.go b/p2p/client.go index 658ddd1..62ce4a4 100644 --- a/p2p/client.go +++ b/p2p/client.go @@ -2,6 +2,7 @@ package p2p import ( "bufio" + "bytes" "fmt" "net" "strconv" @@ -39,6 +40,9 @@ func completeHandshake(conn net.Conn, r *bufio.Reader, infohash, peerID [20]byte if err != nil { return nil, err } + if !bytes.Equal(res.InfoHash[:], infohash[:]) { + return nil, fmt.Errorf("Expected infohash %x but got %x", res.InfoHash, infohash) + } return res, nil }