feat: Add RX/TX to audit logging (#13382)

add additional values for audit logging
This commit is contained in:
Harshavardhana
2021-10-07 19:03:46 -07:00
committed by GitHub
parent 3837d2b94b
commit d57b57bddc
4 changed files with 43 additions and 25 deletions

View File

@@ -20,7 +20,6 @@ package cmd
import (
"bytes"
"io"
"io/ioutil"
"net"
"net/http"
"reflect"
@@ -50,6 +49,11 @@ type recordRequest struct {
bytesRead int
}
func (r *recordRequest) Close() error {
// no-op
return nil
}
func (r *recordRequest) Read(p []byte) (n int, err error) {
n, err = r.Reader.Read(p)
r.bytesRead += n
@@ -62,6 +66,7 @@ func (r *recordRequest) Read(p []byte) (n int, err error) {
}
return n, err
}
func (r *recordRequest) Size() int {
sz := r.bytesRead
for k, v := range r.headers {
@@ -122,7 +127,7 @@ func Trace(f http.HandlerFunc, logBody bool, w http.ResponseWriter, r *http.Requ
}
reqBodyRecorder := &recordRequest{Reader: r.Body, logBody: logBody, headers: reqHeaders}
r.Body = ioutil.NopCloser(reqBodyRecorder)
r.Body = reqBodyRecorder
now := time.Now().UTC()
t := madmin.TraceInfo{TraceType: madmin.TraceHTTP, FuncName: name, Time: now}