10 // Marshalled as binary by the UDP client, so be careful making changes.
11 type AnnounceRequest struct {
17 // Apparently this is optional. None can be used for announces done at
22 NumWant int32 // How many peer addresses are desired. -1 for default.
26 type AnnounceResponse struct {
27 Interval int32 // Minimum seconds the local peer should wait before next announce.
33 type AnnounceEvent int32
35 func (e AnnounceEvent) String() string {
36 // See BEP 3, "event".
37 return []string{"empty", "completed", "started", "stopped"}[e]
47 None AnnounceEvent = iota
48 Completed // The local peer just completed the torrent.
49 Started // The local peer has just resumed this torrent.
50 Stopped // The local peer is leaving the swarm.
54 ErrBadScheme = errors.New("unknown scheme")
57 func Announce(cl *http.Client, urlStr string, req *AnnounceRequest) (res AnnounceResponse, err error) {
58 return AnnounceHost(cl, urlStr, req, "")
61 func AnnounceHost(cl *http.Client, urlStr string, req *AnnounceRequest, host string) (res AnnounceResponse, err error) {
62 _url, err := url.Parse(urlStr)
68 return announceHTTP(cl, req, _url, host)
70 return announceUDP(req, _url)