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