-
Notifications
You must be signed in to change notification settings - Fork 17
/
internal.go
44 lines (38 loc) · 925 Bytes
/
internal.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
package uof
import "crypto/tls"
type Connection struct {
Status ConnectionStatus `json:"status"`
Timestamp int `json:"timestamp,omitempty"`
ServerName string `json:"servername,omitempty"`
LocalAddr string `json:"localaddr,omitempty"`
Network string `json:"network,omitempty"`
TLSVersion uint16 `json:"tlsversion,omitempty"`
}
func (c Connection) TLSVersionToString() string {
switch c.TLSVersion {
case tls.VersionTLS10:
return "1.0"
case tls.VersionTLS11:
return "1.1"
case tls.VersionTLS12:
return "1.2"
case tls.VersionTLS13:
return "1.3"
}
return "unknown"
}
type ConnectionStatus int8
const (
ConnectionStatusUp ConnectionStatus = iota
ConnectionStatusDown
)
func (cs ConnectionStatus) String() string {
switch cs {
case ConnectionStatusDown:
return "down"
case ConnectionStatusUp:
return "up"
default:
return "?"
}
}