Skip to content

Commit

Permalink
establish a handshake
Browse files Browse the repository at this point in the history
  • Loading branch information
baarayy committed May 16, 2024
1 parent 14204cc commit 88031d1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions p2p/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"crypto/sha1"
"fmt"
"log"
"magnetflow/client"
"magnetflow/message"
"magnetflow/peers"
Expand Down Expand Up @@ -115,3 +116,14 @@ func checkIntegrity(pw *pieceWork, buf []byte) error {
}
return nil
}

func (t *Torrent) startDownloadWorker(peer peers.Peer, workQueue chan *pieceWork, results chan *pieceResult) {
c, err := client.New(peer, t.InfoHash, t.PeerID)
if err != nil {
log.Printf("Could not handshake with %s. Disconnecting\n", peer)
return
}
defer c.Conn.Close()
log.Printf("Completed handshake with %s\n", peer)

}

0 comments on commit 88031d1

Please sign in to comment.