-- Protocol implementation

genHandShakeMsg :: ByteString -> String -> ByteString
genHandShakeMsg infoHash peer_id = concat [pstrlen, pstr, reserved, infoHash, peerID]
  where pstrlen = singleton 19
        pstr = BC.pack "BitTorrent protocol"
        reserved = BC.replicate 8 '\0'
        peerID = BC.pack peer_id
genHandShakeMsg :: ByteString -> String -> ByteString
genHandShakeMsg infoHash peer_id = concat [pstrlen, pstr, reserved, infoHash, peerID]
  where pstrlen = singleton 19
        pstr = BC.pack "BitTorrent protocol"
        reserved = BC.replicate 8 '\0'
        peerID = BC.pack peer_id
genHandShakeMsg infoHash peer_id = concat [pstrlen, pstr, reserved, infoHash, peerID]
  where pstrlen = singleton 19
        pstr = BC.pack "BitTorrent protocol"
        reserved = BC.replicate 8 '\0'
        peerID = BC.pack peer_id