You've already forked torrent-client
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:
@@ -12,6 +12,15 @@ type Handshake struct {
|
||||
PeerID [20]byte
|
||||
}
|
||||
|
||||
// New creates a new handshake with the standard pstr
|
||||
func New(infoHash, peerID [20]byte) *Handshake {
|
||||
return &Handshake{
|
||||
Pstr: "BitTorrent protocol",
|
||||
InfoHash: infoHash,
|
||||
PeerID: peerID,
|
||||
}
|
||||
}
|
||||
|
||||
// Serialize serializes the handshake to a buffer
|
||||
func (h *Handshake) Serialize() []byte {
|
||||
pstrlen := len(h.Pstr)
|
||||
|
||||
Reference in New Issue
Block a user