poke

package module
v0.0.0-...-9dfd8d9 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2016 License: MIT Imports: 5 Imported by: 0

README

poke

A tool to feature-test BitTorrent trackers via HTTP and UDP announces

How to get it

A simple

go get github.com/mrd0ll4r/poke/cmd/poke

should get and build it.

How to use it

Run

poke -a <announce URI> [-debug]

to test the tracker specified by <announce URI> via HTTP. To use UDP, specify the UDP endpoing (e.g. localhost:1234) via the -u flag. The -u flag has priority over the -a flag.

License

MIT

Documentation

Index

Constants

View Source
const (
	EventStarted = iota
	EventStopped
	EventCompleted
	EventNone
	EventInvalid = 9
)

Events for announces.

Variables

View Source
var Debug bool

Debug enables debug logging.

Functions

func Debugf

func Debugf(format string, v ...interface{})

Debugf writes to the log a formatted message if Debug==true.

func WrapError

func WrapError(msg string, err error) error

WrapError wraps an error inside another error, adding a higher-level description of what happened.

Types

type AnnounceRequest

type AnnounceRequest struct {
	InfoHash   InfoHash
	Uploaded   int
	Downloaded int
	Left       int
	Compact    bool
	Event      Event
	Numwant    int
	Peer
}

AnnounceRequest represents an announce request.

type AnnounceResponse

type AnnounceResponse struct {
	Interval    int
	MinInterval int
	Complete    int
	Incomplete  int
	Peers       []Peer
}

AnnounceResponse represents an announce response.

type Announcer

type Announcer interface {
	Announce(AnnounceRequest) (OptionalAnnounceResponse, error)
}

Announcer provides the Announce method.

type ErrorResponse

type ErrorResponse string

ErrorResponse represents a tracker error response.

type Event

type Event int

Event represents an event provided in a BitTorrent announce.

type InfoHash

type InfoHash []byte

InfoHash represents a 20-byte infohash in hexadecimal format.

func NewInfohash

func NewInfohash(r *rand.Rand) InfoHash

NewInfohash generates a unique, random InfoHash.

type OptionalAnnounceResponse

type OptionalAnnounceResponse interface {
	// contains filtered or unexported methods
}

OptionalAnnounceResponse is a marker interface for all types that could be returned for an announce request. It is implemented by AnnounceResponse, ErrorResponse and WarningResponse.

type OptionalScrapeResponse

type OptionalScrapeResponse interface {
	// contains filtered or unexported methods
}

OptionalScrapeResponse is a marker interface for all types that could be returned for a scrape request. It is implemented by ScrapeResponse and ErrorResponse.

type Peer

type Peer struct {
	ID   string
	Port uint16
	IP   net.IP
}

Peer represents a peer in a BitTorrent swarm.

func NewPeer

func NewPeer(r *rand.Rand) Peer

NewPeer generates a random, unique Peer. The peer will have its ID prefixed by peerPrefix.

func (Peer) IsEqual

func (p Peer) IsEqual(other Peer) bool

IsEqual compares the peer to another peer and returns true if their ports are equal.

This works for Peers generated by Poke because they are guaranteed to have unique ports.

func (Peer) IsReallyEqual

func (p Peer) IsReallyEqual(other Peer) bool

IsReallyEqual compares the peer to another peer and returns true if they are equal.

type Scrape

type Scrape struct {
	InfoHash   InfoHash
	Complete   int
	Downloaded int
	Incomplete int
}

Scrape represents the set of information scraped for a single infohash.

type ScrapeRequest

type ScrapeRequest struct {
	InfoHashes []InfoHash
}

ScrapeRequest respresents a scrape request.

type ScrapeResponse

type ScrapeResponse struct {
	Files []Scrape
}

ScrapeResponse represents a scrape response.

type Scraper

type Scraper interface {
	Scrape(ScrapeRequest) (OptionalScrapeResponse, error)
}

Scraper provides the Scrape method.

type WarningResponse

type WarningResponse string

WarningResponse represents a tracker warning response.

Directories

Path Synopsis
cmd
poke command

Jump to

Keyboard shortcuts

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