7 "github.com/anacrolix/log"
8 trHttp "github.com/anacrolix/torrent/tracker/http"
9 "github.com/anacrolix/torrent/tracker/udp"
12 type Client interface {
13 Announce(context.Context, AnnounceRequest, AnnounceOpt) (AnnounceResponse, error)
17 type AnnounceOpt = trHttp.AnnounceOpt
19 type NewClientOpts struct {
20 Http trHttp.NewClientOpts
21 // Overrides the network in the scheme. Probably a legacy thing.
26 func NewClient(urlStr string, opts NewClientOpts) (Client, error) {
27 _url, err := url.Parse(urlStr)
33 return trHttp.NewClient(_url, opts.Http), nil
34 case "udp", "udp4", "udp6":
35 network := _url.Scheme
36 if opts.UdpNetwork != "" {
37 network = opts.UdpNetwork
39 cc, err := udp.NewConnClient(udp.NewConnClientOpts{
49 requestUri: _url.RequestURI(),
52 return nil, ErrBadScheme