1
0
Fork 0

Add TLS version and cipher to the accessLog

This commit is contained in:
na4ma4 2021-01-19 18:52:06 +10:00 committed by GitHub
parent 41d22ef17e
commit b05a5c818d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 54 additions and 17 deletions

View file

@ -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"
}