peer

package
v0.0.0-...-d54763a Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Peer

type Peer struct {
	ID        string `json:"id,omitempty" bencode:"id,omitempty"`
	IP        string `json:"ip,omitempty" bencode:"ip,omitempty"`
	Port      int    `json:"port,omitempty" bencode:"port,omitempty"`
	InfoHash  string `json:"info_hash,omitempty" bencode:"info_hash,omitempty"`
	Key       string `json:"key,omitempty" bencode:"key,omitempty"`
	BytesLeft uint64 `json:"bytes_left,omitempty" bencode:"bytes_left,omitempty"`
	// contains filtered or unexported fields
}

Peer represents a bittorrent peer

func PeerFromRequest

func PeerFromRequest(r *http.Request) (*Peer, error)

PeerFromRequest returns a peer from an http GET request

func (*Peer) BTSerialize

func (p *Peer) BTSerialize() (string, error)

BTSerialize returns the peer's information serialized in the the bencoding format

func (*Peer) Hash

func (p *Peer) Hash() string

Hash returns a sha1 of the peer ID and InfoHash

func (*Peer) IsSeed

func (p *Peer) IsSeed() bool

IsSeed returns true if the peer has no more bytes left to receive

Jump to

Keyboard shortcuts

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