-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtypes.go
More file actions
106 lines (93 loc) · 2.17 KB
/
types.go
File metadata and controls
106 lines (93 loc) · 2.17 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package pixie
import "fmt"
type Version struct {
Major uint8
Minor uint8
}
type Role uint8
type CloseReason uint8
type StreamType uint8
const (
RoleClient Role = iota
RoleServer
)
const (
StrTCP StreamType = 0x01
StrUDP StreamType = 0x02
StrPTY StreamType = 0x03
)
const (
CrUnknown CloseReason = 0x01
CrVoluntary CloseReason = 0x02
CrUnexpected CloseReason = 0x03
CrInvalidExtension CloseReason = 0x04
CrInvalidInfo CloseReason = 0x41
CrUnreachable CloseReason = 0x42
CrConnTimeout CloseReason = 0x43
CrRefused CloseReason = 0x44
CrStreamTimeout CloseReason = 0x47
CrBlockedAddr CloseReason = 0x48
CrThrottled CloseReason = 0x49
CrNetErr CloseReason = 0x4a
CrClientUnexpected CloseReason = 0x81
CrPassAuthFailed CloseReason = 0xc0
CrCertAuthFailed CloseReason = 0xc1
CrAuthReq CloseReason = 0xc2
)
var ProtocolVersion = Version{Major: 2, Minor: 0}
func (v Version) String() string {
return fmt.Sprintf("%d.%d", v.Major, v.Minor)
}
func (s StreamType) String() string {
switch s {
case StrTCP:
return "tcp"
case StrUDP:
return "udp"
case StrPTY:
return "pty"
default:
return fmt.Sprintf("unknown(0x%02x)", uint8(s))
}
}
func (cr CloseReason) String() string {
switch cr {
case CrUnknown:
return "Unknown"
case CrVoluntary:
return "Voluntary"
case CrUnexpected:
return "Unexpected"
case CrInvalidExtension:
return "Incompatible extensions"
case CrInvalidInfo:
return "Invalid information"
case CrUnreachable:
return "Unreachable"
case CrConnTimeout:
return "Connection timed out"
case CrRefused:
return "Connection refused"
case CrStreamTimeout:
return "Stream timed out"
case CrBlockedAddr:
return "Blocked address"
case CrThrottled:
return "Throttled"
case CrNetErr:
return "Network error"
case CrClientUnexpected:
return "Client unexpected error"
case CrPassAuthFailed:
return "Password auth failed"
case CrCertAuthFailed:
return "Certificate auth failed"
case CrAuthReq:
return "Authentication required"
default:
return fmt.Sprintf("Unknown(0x%02x)", uint8(cr))
}
}
func (cr CloseReason) Error() string {
return cr.String()
}