torrent: Index | Files

package tracker

import ""


Package Files

expvar.go http.go peer.go server.go tracker.go udp.go


const DefaultTrackerAnnounceTimeout = 15 * time.Second

The code *is* the documentation.


var (
    ErrBadScheme = errors.New("unknown scheme")

type Action Uses

type Action int32
const (
    ActionConnect Action = iota

type Announce Uses

type Announce struct {
    TrackerUrl string
    Request    AnnounceRequest
    HostHeader string
    HTTPProxy  func(*http.Request) (*url.URL, error)
    ServerName string
    UserAgent  string
    UdpNetwork string
    // If the port is zero, it's assumed to be the same as the Request.Port.
    ClientIp4 krpc.NodeAddr
    // If the port is zero, it's assumed to be the same as the Request.Port.
    ClientIp6 krpc.NodeAddr
    Context   context.Context

func (Announce) Do Uses

func (me Announce) Do() (res AnnounceResponse, err error)

type AnnounceEvent Uses

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 Uses

func (e AnnounceEvent) String() string

type AnnounceRequest Uses

type AnnounceRequest struct {
    InfoHash   [20]byte
    PeerId     [20]byte
    Downloaded int64
    Left       int64 // If less than 0, math.MaxInt64 will be used for HTTP trackers instead.
    Uploaded   int64
    // Apparently this is optional. None can be used for announces done at
    // regular intervals.
    Event     AnnounceEvent
    IPAddress uint32
    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 Uses

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

type AnnounceResponseHeader Uses

type AnnounceResponseHeader struct {
    Interval int32
    Leechers int32
    Seeders  int32

type ConnectionRequest Uses

type ConnectionRequest struct {
    ConnectionId int64
    Action       int32
    TransctionId int32

type ConnectionResponse Uses

type ConnectionResponse struct {
    ConnectionId int64

type HttpResponse Uses

type HttpResponse struct {
    FailureReason string `bencode:"failure reason"`
    Interval      int32  `bencode:"interval"`
    TrackerId     string `bencode:"tracker id"`
    Complete      int32  `bencode:"complete"`
    Incomplete    int32  `bencode:"incomplete"`
    Peers         Peers  `bencode:"peers"`
    // BEP 7
    Peers6 krpc.CompactIPv6NodeAddrs `bencode:"peers6"`

type Peer Uses

type Peer struct {
    IP   net.IP
    Port int
    ID   []byte

func (*Peer) FromDictInterface Uses

func (p *Peer) FromDictInterface(d map[string]interface{})

Set from the non-compact form in BEP 3.

func (Peer) FromNodeAddr Uses

func (p Peer) FromNodeAddr(na krpc.NodeAddr) Peer

func (Peer) String Uses

func (p Peer) String() string

type Peers Uses

type Peers []Peer

func (*Peers) UnmarshalBencode Uses

func (me *Peers) UnmarshalBencode(b []byte) (err error)

type RequestHeader Uses

type RequestHeader struct {
    ConnectionId  int64
    Action        Action
    TransactionId int32
}   // 16 bytes

type ResponseHeader Uses

type ResponseHeader struct {
    Action        Action
    TransactionId int32

Package tracker imports 22 packages (graph) and is imported by 31 packages. Updated 2020-12-30. Refresh now. Tools for package owners.