-
Notifications
You must be signed in to change notification settings - Fork 82
/
types.go
92 lines (70 loc) · 1.71 KB
/
types.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
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
package util
import (
"bytes"
"fmt"
)
// a JWT bearer token, encoded following the JWT specification
type JWTTokenString struct {
Token string
}
type SSHForwardingProtocol = uint64
type SSHForwardingAddressFamily = uint64
type ChannelID = uint64
const (
SSHProtocolUDP = SSHForwardingProtocol(0)
SSHForwardingProtocolTCP = SSHForwardingProtocol(1)
)
const (
SSHAFIpv4 = SSHForwardingAddressFamily(4)
SSHAFIpv6 = SSHForwardingAddressFamily(6)
)
type UserNotFound struct {
Username string
}
func (e UserNotFound) Error() string {
return fmt.Sprintf("User not found: %s", e.Username)
}
type ChannelNotFound struct {
ChannelID ChannelID
}
func (e ChannelNotFound) Error() string {
return fmt.Sprintf("Channel not found: %d", e.ChannelID)
}
type InvalidSSHString struct {
Reason error
}
func (e InvalidSSHString) Error() string {
return fmt.Sprintf("Invalid SSH string: %s", e.Reason)
}
type Unauthorized struct{}
func (e Unauthorized) Error() string {
return "Unauthorized"
}
type OtherHTTPError struct {
StatusCode int
HasBody bool
Body string
}
func (e OtherHTTPError) Error() string {
str := fmt.Sprintf("HTTP response with %d status code", e.StatusCode)
if e.HasBody {
str = fmt.Sprintf("%s: %s", str, e.Body)
}
return str
}
type InvalidConfig struct {
Field string
Value string
}
func (e InvalidConfig) Error() string {
return fmt.Sprintf("Invalid %s config field: \"%s\"", e.Field, e.Value)
}
type BytesReadCloser struct {
*bytes.Reader
}
func (b *BytesReadCloser) Close() error { return nil }
// sends an ssh3 datagram. The function must know the ID of the channel
type SSH3DatagramSenderFunc func(p []byte) error
type DatagramSender interface {
SendDatagram(p []byte) error
}