tracker

package
v0.0.0-...-df6d21c Latest Latest
Warning

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

Go to latest
Published: May 16, 2015 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotConnected = errors.New("not connected")
	ErrBadScheme    = errors.New("unknown scheme")
)

Functions

func RegisterClientScheme

func RegisterClientScheme(scheme string, newFunc func(*url.URL) Client)

Types

type Action

type Action int32
const (
	Connect Action = iota
	Announce
	Scrape
	Error
)

type AnnounceEvent

type AnnounceEvent int32
const (
	None      AnnounceEvent = iota
	Completed               // The local peer just completed the torrent.
	Started                 // The local peer has just resumed this torrent.
	Stopped                 // The local peer is leaving the swarm.
)

func (AnnounceEvent) String

func (me AnnounceEvent) String() string

type AnnounceRequest

type AnnounceRequest struct {
	InfoHash   [20]byte
	PeerId     [20]byte
	Downloaded int64
	Left       uint64
	Uploaded   int64
	Event      AnnounceEvent
	IPAddress  int32
	Key        int32
	NumWant    int32 // How many peer addresses are desired. -1 for default.
	Port       uint16

} // 82 bytes

Marshalled as binary by the UDP client, so be careful making changes.

type AnnounceResponse

type AnnounceResponse struct {
	Interval int32 // Minimum seconds the local peer should wait before next announce.
	Leechers int32
	Seeders  int32
	Peers    []Peer
}

type AnnounceResponseHeader

type AnnounceResponseHeader struct {
	Interval int32
	Leechers int32
	Seeders  int32
}

type Client

type Client interface {
	// Returns ErrNotConnected if Connect needs to be called.
	Announce(*AnnounceRequest) (AnnounceResponse, error)
	Connect() error
	String() string
	URL() string
}

func New

func New(rawurl string) (cl Client, err error)

Returns ErrBadScheme if the tracker scheme isn't recognised.

func NewClient

func NewClient(url *url.URL) Client

type ConnectionRequest

type ConnectionRequest struct {
	ConnectionId int64
	Action       int32
	TransctionId int32
}

type ConnectionResponse

type ConnectionResponse struct {
	ConnectionId int64
}

type Peer

type Peer struct {
	IP   net.IP
	Port int
}

type RequestHeader

type RequestHeader struct {
	ConnectionId  int64
	Action        Action
	TransactionId int32

} // 16 bytes

type ResponseHeader

type ResponseHeader struct {
	Action        Action
	TransactionId int32
}

Jump to

Keyboard shortcuts

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