-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbinary.go
58 lines (50 loc) · 1.29 KB
/
binary.go
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package proxyprotocol
// BinarySignature is magic prefix for proxyprotocol Binary
var (
BinarySignature = []byte{0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A}
BinarySignatureLen = len(BinarySignature)
)
// BinaryVersion2 bits
const (
BinaryVersion2 byte = 0x20
BinaryVersionMask byte = 0xF0
)
// Commands
const (
BinaryCommandLocal byte = 0x00
BinaryCommandProxy byte = 0x01
BinaryCommandMask byte = 0x0F
)
// Address families
const (
BinaryAFUnspec byte = 0x00
BinaryAFInet byte = 0x10
BinaryAFInet6 byte = 0x20
BinaryAFUnix byte = 0x30
BinaryAFMask byte = 0xF0
)
// Transport protocols
const (
BinaryTPUnspec byte = 0x00
BinaryTPStream byte = 0x01
BinaryTPDgram byte = 0x02
BinaryTPMask byte = 0x0F
)
// Protocol variants
var (
BinaryProtocolUnspec = BinaryAFUnspec | BinaryTPUnspec
BinaryProtocolTCPoverIPv4 = BinaryAFInet | BinaryTPStream
BinaryProtocolUDPoverIPv4 = BinaryAFInet | BinaryTPDgram
BinaryProtocolTCPoverIPv6 = BinaryAFInet6 | BinaryTPStream
BinaryProtocolUDPoverIPv6 = BinaryAFInet6 | BinaryTPDgram
BinaryProtocolUnixStream = BinaryAFUnix | BinaryTPStream
BinaryProtocolUnixDatagram = BinaryAFUnix | BinaryTPDgram
)
// Expected address length
var (
BinaryPortLen = 2
)
// TLV types
const (
TLVTypeNoop byte = 0x04
)