tracker

package
v0.0.0-...-101a212 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package tracker gets peers from (HTTP/S and UDP) tracker servers.

Tracker servers are typically the primary method of peer discovery.

Basic Usage

The Tracker URL string can represent either a HTTP/S or UDP tracker address. tracker.GetPeers() will handle HTTP/S and UDP URLs separately.

// http
peerAddrs, err := tracker.GetPeers("http://academictorrents.com/announce.php")

// udp
peerAddrs, err := tracker.GetPeers("udp://tracker.opentrackr.org:1337/announce")

The UDP Client implementation is exported as well, but does not need to be used in most use cases.

Index

Constants

View Source
const (
	ConnectAction udpMessageAction = iota
	AnnounceAction
	ScrapeAction
	ErrorAction
)

Variables

This section is empty.

Functions

func GetPeers

func GetPeers(trackerURL string, infoHash, peerID [20]byte, port int) ([]net.TCPAddr, error)

GetPeers will attempt to get peers from a http/s or udp tracker server for the given infohash.

Types

type UDPClient

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

UDPClient is an implementation of BEP0015 to locate peers without DHT. http://bittorrent.org/beps/bep_0015.html

func NewUDPClient

func NewUDPClient(trURL *url.URL, infoHash, peerID [20]byte, port int) (*UDPClient, error)

NewUDPClient generates a client to a UDP Tracker server per BEP0015.

func (*UDPClient) GetPeers

func (u *UDPClient) GetPeers() ([]net.TCPAddr, error)

GetPeers connects and announces to the UDP tracker, then returns the peer addresses

Jump to

Keyboard shortcuts

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