Add TLS version and cipher to the accessLog
This commit is contained in:
parent
41d22ef17e
commit
b05a5c818d
6 changed files with 54 additions and 17 deletions
|
@ -18,6 +18,7 @@ import (
|
|||
"github.com/sirupsen/logrus"
|
||||
ptypes "github.com/traefik/paerser/types"
|
||||
"github.com/traefik/traefik/v2/pkg/log"
|
||||
traefiktls "github.com/traefik/traefik/v2/pkg/tls"
|
||||
"github.com/traefik/traefik/v2/pkg/types"
|
||||
)
|
||||
|
||||
|
@ -209,6 +210,8 @@ func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request, next http
|
|||
core[RequestScheme] = "http"
|
||||
if req.TLS != nil {
|
||||
core[RequestScheme] = "https"
|
||||
core[TLSVersion] = getRequestTLSVersion(req)
|
||||
core[TLSCipher] = getRequestTLSCipher(req)
|
||||
}
|
||||
|
||||
core[ClientAddr] = req.RemoteAddr
|
||||
|
@ -382,3 +385,19 @@ var requestCounter uint64 // Request ID
|
|||
func nextRequestCount() uint64 {
|
||||
return atomic.AddUint64(&requestCounter, 1)
|
||||
}
|
||||
|
||||
func getRequestTLSVersion(req *http.Request) string {
|
||||
if version, ok := traefiktls.VersionsReversed[req.TLS.Version]; ok {
|
||||
return version
|
||||
}
|
||||
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
func getRequestTLSCipher(req *http.Request) string {
|
||||
if cypher, ok := traefiktls.CipherSuitesReversed[req.TLS.CipherSuite]; ok {
|
||||
return cypher
|
||||
}
|
||||
|
||||
return "unknown"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue