httpTracker

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MPL-2.0 Imports: 21 Imported by: 0

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

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

type DialContextFunc

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

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

type Peers

type Peers struct {
	List    []Peer
	Compact bool
}

func (Peers) MarshalBencode

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