aboutsummaryrefslogtreecommitdiff
path: root/tracker/messages.go
blob: 8062eaf63527cd2a64b2e79d30e300913ba8581d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package tracker

import "net"

type Event string

const (
	NoEvent   Event = ""
	Started   Event = "started"
	Stopped   Event = "stopped"
	Completed Event = "completed"
)

type Request struct {
	InfoHash   []byte     `query:"info_hash"` // info_hash
	PeerID     []byte     `query:"peer_id"`   // peer_id
	Port       int        `query:"port,optional"`
	Uploaded   int        `query:"uploaded,optional"`
	Downloaded int        `query:"downloaded,optional"`
	Left       int        `query:"left,optional"`
	Compact    bool       `query:"compact,optional"` // always true
	NoPeerID   bool       `query:"no_peer_id,optional"`
	Event      Event      `query:"event,optional"`
	IP         net.IPAddr `query:"ip,optional"`
	NumWant    int        `query:"numwant,optional"`
	Key        []byte     `query:"key,optional"`
	TrackerID  []byte     `query:"tracker_id,optional"`
}

// we support only compact mode
type Response struct {
	Complete       int    `bencode:"complete"`
	FalureReason   string `bencode:"failure reason"`
	Incomplete     int    `bencode:"incomplete"`
	Interval       int    `bencode:"interval"`
	MinInterval    int    `bencode:"min interval"`
	Peers          []byte `bencode:"peers"`
	Peers6         []byte `bencode:"peers6"`
	TrackerId      string `bencode:"tracker id"`
	WarningMessage string `bencode:"warning message"`
}