handshake

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handshake

type Handshake struct {
	Pstr     string
	InfoHash Hash
	PeerID   PeerID
}

Each handshake if formed by: - Pstr: A string identifier - InfoHash Sha1 for the meta info - PeerID: Unique identifier

func NewHandshake

func NewHandshake(peerID PeerID, infoHash Hash) *Handshake

NewHandshake creates a new handshake

func Unmarshal

func Unmarshal(r io.Reader) (*Handshake, error)

Unmarshal reads a buffer and turn it into a handshake response It doesn't the inverse from the marshal function

func (Handshake) Marshal

func (h Handshake) Marshal() []byte

Marshal is the serialization for the handshake It's formed by: - The len of the protocol ID - The protocol ID - Eight reserved bytes (all turned to zero, used for extensions) - The infoHash - The peer ID

type Hash

type Hash [20]byte

type PeerID

type PeerID [20]byte

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL