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