]> Sergey Matveev's repositories - btrtrc.git/blob - peer_protocol/protocol.go
13d76def401226910ac9aa8232f9500aaabc369e
[btrtrc.git] / peer_protocol / protocol.go
1 package peer_protocol
2
3 import "strconv"
4
5 const (
6         Protocol = "\x13BitTorrent protocol"
7 )
8
9 type (
10         MessageType byte
11 )
12
13 // Hopefully uncaught panics format using this so we don't just see a pair of
14 // unhelpful uintptrs.
15 func (me MessageType) String() string {
16         return strconv.FormatInt(int64(me), 10)
17 }
18
19 const (
20         Choke         MessageType = iota
21         Unchoke                   // 1
22         Interested                // 2
23         NotInterested             // 3
24         Have                      // 4
25         Bitfield                  // 5
26         Request                   // 6
27         Piece                     // 7
28         Cancel                    // 8
29         Port                      // 9
30
31         // BEP 6
32         Suggest     = 0xd  // 13
33         HaveAll     = 0xe  // 14
34         HaveNone    = 0xf  // 15
35         Reject      = 0x10 // 16
36         AllowedFast = 0x11 // 17
37
38         Extended = 20
39
40         HandshakeExtendedID = 0
41
42         RequestMetadataExtensionMsgType = 0
43         DataMetadataExtensionMsgType    = 1
44         RejectMetadataExtensionMsgType  = 2
45 )