bittorrent

package
v0.0.0-...-729a1dc Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressFamily

type AddressFamily uint8

AddressFamily is the address family of an IP address.

const (
	IPv4 AddressFamily = iota
	IPv6
)

AddressFamily constants.

type AnnounceRequest

type AnnounceRequest struct {
	Event           string
	InfoHash        InfoHash
	Compact         bool
	EventProvided   bool
	NumWantProvided bool
	IPProvided      bool
	NumWant         uint32
	Left            uint64
	Downloaded      uint64
	Uploaded        uint64
	NoPeerId        bool
	Expiry          int64
	IsIPv6          bool
	Peer
}

AnnounceRequest represents the parsed parameters from an announce request.

type AnnounceResponse

type AnnounceResponse struct {
	Compact     bool
	Complete    uint32
	Incomplete  uint32
	Interval    time.Duration
	MinInterval time.Duration
	IPv4Peers   []Peer
	IPv6Peers   []Peer
}

AnnounceResponse represents the parameters used to create an announce response.

type ClientError

type ClientError string

ClientError represents an error that should be exposed to the client over the BitTorrent protocol implementation.

func (ClientError) Error

func (c ClientError) Error() string

Error implements the error interface for ClientError.

type ClientID

type ClientID [6]byte

ClientID represents the part of a PeerID that identifies a Peer's client software.

func NewClientID

func NewClientID(pid PeerID) ClientID

NewClientID parses a ClientID from a PeerID.

type IP

type IP struct {
	IP string
	AddressFamily
}

IP is a net.IP with an AddressFamily.

type InfoHash

type InfoHash [20]byte

InfoHash represents an infohash.

func InfoHashFromBytes

func InfoHashFromBytes(b []byte) InfoHash

InfoHashFromBytes creates an InfoHash from a byte slice.

It panics if b is not 20 bytes long.

func InfoHashFromString

func InfoHashFromString(s string) InfoHash

InfoHashFromString creates an InfoHash from a string.

It panics if s is not 20 bytes long.

func (InfoHash) RawString

func (i InfoHash) RawString() string

RawString returns a 20-byte string of the raw bytes of the InfoHash.

func (InfoHash) String

func (i InfoHash) String() string

String implements fmt.Stringer, returning the base16 encoded InfoHash.

type Peer

type Peer struct {
	ID         PeerID
	IP         IP
	Port       uint16
	Complete   bool
	Downloaded uint64
	Uploaded   uint64
}

Peer represents the connection details of a peer that is returned in an announce response.

func (Peer) Equal

func (p Peer) Equal(x Peer) bool

Equal reports whether p and x are the same.

func (Peer) EqualEndpoint

func (p Peer) EqualEndpoint(x Peer) bool

EqualEndpoint reports whether p and x have the same endpoint.

func (Peer) String

func (p Peer) String() string

type PeerID

type PeerID [20]byte

PeerID represents a peer ID.

func PeerIDFromBytes

func PeerIDFromBytes(b []byte) PeerID

PeerIDFromBytes creates a PeerID from a byte slice.

It panics if b is not 20 bytes long.

func PeerIDFromString

func PeerIDFromString(s string) PeerID

PeerIDFromString creates a PeerID from a string.

It panics if s is not 20 bytes long.

func (PeerID) RawBytes

func (p PeerID) RawBytes() []byte

func (PeerID) RawString

func (p PeerID) RawString() string

RawString returns a 20-byte string of the raw bytes of the ID.

func (PeerID) String

func (p PeerID) String() string

String implements fmt.Stringer, returning the base16 encoded PeerID.

type Scrape

type Scrape struct {
	InfoHash   InfoHash
	Snatches   uint32
	Complete   uint32
	Incomplete uint32
}

Scrape represents the state of a swarm that is returned in a scrape response.

type ScrapeResponse

type ScrapeResponse struct {
	Files []Scrape
}

ScrapeResponse represents the parameters used to create a scrape response.

The Scrapes must be in the same order as the InfoHashes in the corresponding ScrapeRequest.

Jump to

Keyboard shortcuts

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