1
0
mirror of https://github.com/veggiedefender/torrent-client.git synced 2025-11-06 09:29:16 +02:00

Implement handshake.New()

This commit is contained in:
Jesse Li
2019-12-24 11:05:22 -05:00
parent c20965ebf5
commit 415666a020
3 changed files with 22 additions and 5 deletions

View File

@@ -100,11 +100,7 @@ func (p *Peer) connect(peerID [20]byte, infoHash [20]byte) (net.Conn, error) {
}
func (d *Downloader) handshake(conn net.Conn) (*handshake.Handshake, error) {
req := handshake.Handshake{
Pstr: "BitTorrent protocol",
InfoHash: d.InfoHash,
PeerID: d.PeerID,
}
req := handshake.New(d.InfoHash, d.PeerID)
_, err := conn.Write(req.Serialize())
if err != nil {
return nil, err