mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 12:24:38 +03:00
expose fewer internals in packages, for easier software reuse
- prometheus is now behind an interface, they aren't dependencies for the reusable components anymore. - some dependencies have been inverted: instead of packages importing a main package to get configuration, the main package now sets configuration in these packages. that means fewer internals are pulled in. - some functions now have new parameters for values that were retrieved from package "mox-".
This commit is contained in:
29
moxio/tlsinfo.go
Normal file
29
moxio/tlsinfo.go
Normal file
@ -0,0 +1,29 @@
|
||||
package moxio
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// TLSInfo returns human-readable strings about the TLS connection, for use in
|
||||
// logging.
|
||||
func TLSInfo(conn *tls.Conn) (version, ciphersuite string) {
|
||||
st := conn.ConnectionState()
|
||||
|
||||
versions := map[uint16]string{
|
||||
tls.VersionTLS10: "TLS1.0",
|
||||
tls.VersionTLS11: "TLS1.1",
|
||||
tls.VersionTLS12: "TLS1.2",
|
||||
tls.VersionTLS13: "TLS1.3",
|
||||
}
|
||||
|
||||
v, ok := versions[st.Version]
|
||||
if ok {
|
||||
version = v
|
||||
} else {
|
||||
version = fmt.Sprintf("TLS %x", st.Version)
|
||||
}
|
||||
|
||||
ciphersuite = tls.CipherSuiteName(st.CipherSuite)
|
||||
return
|
||||
}
|
Reference in New Issue
Block a user