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
56 HTTPProxy func(*http.Request) (*url.URL, error)
60 // If the port is zero, it's assumed to be the same as the Request.Port
61 ClientIp4 krpc.NodeAddr
62 // If the port is zero, it's assumed to be the same as the Request.Port
63 ClientIp6 krpc.NodeAddr
66 // In an FP language with currying, what order what you put these params?
68 func (me Announce) Do() (res AnnounceResponse, err error) {
69 _url, err := url.Parse(me.TrackerUrl)
75 return announceHTTP(me, _url)
76 case "udp", "udp4", "udp6":
77 return announceUDP(me, _url)