peer

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 11 Imported by: 4

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"`
	IA        string `json:"ia,omitempty" bencode:"ia,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 scion bittorrent peer

func BTDeserialize

func BTDeserialize(d []byte) (*Peer, error)

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