7 "github.com/anacrolix/dht/krpc"
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]
41 None AnnounceEvent = iota
42 Completed // The local peer just completed the torrent.
43 Started // The local peer has just resumed this torrent.
44 Stopped // The local peer is leaving the swarm.
48 ErrBadScheme = errors.New("unknown scheme")
51 type Announce struct {
53 Request AnnounceRequest
58 // If the port is zero, it's assumed to be the same as the Request.Port
59 ClientIp4 krpc.NodeAddr
60 // If the port is zero, it's assumed to be the same as the Request.Port
61 ClientIp6 krpc.NodeAddr
64 // In an FP language with currying, what order what you put these params?
66 func (me Announce) Do() (res AnnounceResponse, err error) {
67 _url, err := url.Parse(me.TrackerUrl)
73 return announceHTTP(me, _url)
74 case "udp", "udp4", "udp6":
75 return announceUDP(me, _url)