httpTracker

package
v1.54.2-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MPL-2.0 Imports: 21 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnounceOpt

type AnnounceOpt struct {
	UserAgent           string
	HostHeader          string
	ClientIp4           net.IP
	ClientIp6           net.IP
	HttpRequestDirector func(*http.Request) error
}

type AnnounceRequest

type AnnounceRequest = udp.AnnounceRequest

type AnnounceResponse

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

type Client

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

func NewClient

func NewClient(url_ *url.URL, opts NewClientOpts) Client

func (Client) Announce

func (cl Client) Announce(ctx context.Context, ar AnnounceRequest, opt AnnounceOpt) (ret AnnounceResponse, err error)

func (Client) Close

func (cl Client) Close() error

func (Client) Scrape added in v1.53.0

func (cl Client) Scrape(ctx context.Context, ihs []infohash.T) (out udp.ScrapeResponse, err error)

type DialContextFunc added in v1.47.0

type DialContextFunc func(ctx context.Context, network, addr string) (net.Conn, error)

type HttpResponse

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 NewClientOpts

type NewClientOpts struct {
	Proxy          ProxyFunc
	DialContext    DialContextFunc
	ServerName     string
	AllowKeepAlive bool
}

type Peer

type Peer struct {
	IP   net.IP `bencode:"ip"`
	Port int    `bencode:"port"`
	ID   []byte `bencode:"peer id"`
}

TODO: Use netip.Addr and Option[[20]byte].

func (*Peer) FromDictInterface

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

Set from the non-compact form in BEP 3.

func (Peer) FromNodeAddr

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

func (Peer) String

func (p Peer) String() string

func (Peer) ToNetipAddrPort added in v1.49.0

func (p Peer) ToNetipAddrPort() (addrPort netip.AddrPort, ok bool)

type Peers

type Peers struct {
	List    []Peer
	Compact bool
}

func (Peers) MarshalBencode added in v1.48.0

func (me Peers) MarshalBencode() ([]byte, error)

func (*Peers) UnmarshalBencode

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

type ProxyFunc

type ProxyFunc func(*http.Request) (*url.URL, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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