Documentation ¶
Overview ¶
Package peer is a client implementation (TCP only) to peers in the swarm.
The current implementation supports
- the extension protocol BEP0010
- metadata transfer between peers BEP0009
- DHT Port transfer BEP0005
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotInBitfield = errors.New("client does not have piece")
ErrNotInBitfield is returned on a call to *Client.GetPiece() if the peer does not have the requested piece.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
NewClient initializes a connection with a peer, then:
- completes the handshake
- completes the extension handshake if applicable
- receives the bitfield message
- sends an unchoke and interested message to the peer
func (*Client) DHTAddr ¶
DHTAddr returns the UDP address to reach this peer's DHT node. The peer should have sent a Port message after the BitTorrent handshake (per BEP0005). If it did not, a non-nil error is returned. http://bittorrent.org/beps/bep_0005.html
func (*Client) GetMetadata ¶
GetMetadata requests and receives the raw metadata/info dictionary from the peer (per BEP0009). If the peer does not support this extension, a non-nil error is returned. http://bittorrent.org/beps/bep_0009.html