8 "github.com/anacrolix/dht/krpc"
11 // Marshalled as binary by the UDP client, so be careful making changes.
12 type AnnounceRequest struct {
18 // Apparently this is optional. None can be used for announces done at
23 NumWant int32 // How many peer addresses are desired. -1 for default.
27 type AnnounceResponse struct {
28 Interval int32 // Minimum seconds the local peer should wait before next announce.
34 type AnnounceEvent int32
36 func (e AnnounceEvent) String() string {
37 // See BEP 3, "event".
38 return []string{"empty", "completed", "started", "stopped"}[e]
42 None AnnounceEvent = iota
43 Completed // The local peer just completed the torrent.
44 Started // The local peer has just resumed this torrent.
45 Stopped // The local peer is leaving the swarm.
49 ErrBadScheme = errors.New("unknown scheme")
52 type Announce struct {
54 Request AnnounceRequest
57 HttpClient *http.Client
59 ClientIp4 krpc.NodeAddr
60 ClientIp6 krpc.NodeAddr
63 // In an FP language with currying, what order what you put these params?
65 func (me Announce) Do() (res AnnounceResponse, err error) {
66 _url, err := url.Parse(me.TrackerUrl)
72 return announceHTTP(me, _url)
73 case "udp", "udp4", "udp6":
74 return announceUDP(me, _url)