tracker

package
v0.0.0-...-df66e35 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action uint32
const (
	ActionConnect  Action = 0
	ActionAnnounce Action = 1
)

type AnnounceRequest

type AnnounceRequest struct {
	ConnectionID  uint64
	Action        Action
	TransactionID uint32
	InfoHash      [20]byte
	PeerID        [20]byte
	Downloaded    uint64
	Left          uint64
	Uploaded      uint64
	Event         Event
	IP            uint32
	Key           uint32
	NumWant       uint32
	Port          uint16
}

func (*AnnounceRequest) Bytes

func (r *AnnounceRequest) Bytes() ([]byte, error)

type AnnounceResponse

type AnnounceResponse struct {
	Action        Action
	TransactionID uint32
	Interval      uint32
	Leechers      uint32
	Seeders       uint32
	Peers         []models.Peer
}

type ConnectRequest

type ConnectRequest struct {
	ProtocolID    uint64
	Action        Action
	TransactionID uint32
}

func (ConnectRequest) Bytes

func (request ConnectRequest) Bytes() []byte

type ConnectResponse

type ConnectResponse struct {
	Action        Action
	TransactionID uint32
	ConnectionID  uint64
}

type Event

type Event uint32
const (
	EventNone Event = iota
	EventCompleted
	EventStarted
	EventStopped
)

type HTTPGetter

type HTTPGetter struct {
	// contains filtered or unexported fields
}

func (*HTTPGetter) GetPeers

func (h *HTTPGetter) GetPeers(announce string, metafile models.Metafile) ([]models.Peer, error)

type PeersGetter

type PeersGetter interface {
	GetPeers(announce string, metafile models.Metafile) ([]models.Peer, error)
}

func NewHTTPGetter

func NewHTTPGetter(client *http.Client, peerID string) PeersGetter

func NewUDPGetter

func NewUDPGetter(peerID string) PeersGetter

type Tracker

type Tracker interface {
	GetPeers(models.Metafile) ([]models.Peer, error)
	WithHTTPClient(client *http.Client) Tracker
}

func NewTracker

func NewTracker(announceURL, peerID string) Tracker

type UDPGetter

type UDPGetter struct {
	// contains filtered or unexported fields
}

func (UDPGetter) GetPeers

func (u UDPGetter) GetPeers(announceURL string, metafile models.Metafile) ([]models.Peer, error)

Jump to

Keyboard shortcuts

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