7 "github.com/anacrolix/dht/v2/krpc"
10 // Marshalled as binary by the UDP client, so be careful making changes.
11 type AnnounceRequest struct {
15 Left int64 // If less than 0, math.MaxInt64 will be used for HTTP trackers instead.
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 AnnounceEvent int32
28 func (me *AnnounceEvent) UnmarshalText(text []byte) error {
29 for key, str := range announceEventStrings {
30 if string(text) == str {
31 *me = AnnounceEvent(key)
35 return fmt.Errorf("unknown event")
38 var announceEventStrings = []string{"", "completed", "started", "stopped"}
40 func (e AnnounceEvent) String() string {
41 // See BEP 3, "event", and
42 // https://github.com/anacrolix/torrent/issues/416#issuecomment-751427001. Return a safe default
43 // in case event values are not sanitized.
44 if e < 0 || int(e) >= len(announceEventStrings) {
47 return announceEventStrings[e]
50 type AnnounceResponsePeers interface {
51 encoding.BinaryUnmarshaler
52 NodeAddrs() []krpc.NodeAddr