update handler recorder object
This commit is contained in:
@@ -242,17 +242,20 @@ func (h *forwardHandler) handleHTTP(ctx context.Context, rw io.ReadWriteCloser,
|
|||||||
start := time.Now()
|
start := time.Now()
|
||||||
ro.Time = start
|
ro.Time = start
|
||||||
ro.HTTP = &xrecorder.HTTPRecorderObject{
|
ro.HTTP = &xrecorder.HTTPRecorderObject{
|
||||||
Host: req.Host,
|
Host: req.Host,
|
||||||
Proto: req.Proto,
|
Proto: req.Proto,
|
||||||
Scheme: req.URL.Scheme,
|
Scheme: req.URL.Scheme,
|
||||||
Method: req.Method,
|
Method: req.Method,
|
||||||
URI: req.RequestURI,
|
URI: req.RequestURI,
|
||||||
RequestHeader: req.Header.Clone(),
|
Request: xrecorder.HTTPRequestRecorderObject{
|
||||||
|
ContentLength: req.ContentLength,
|
||||||
|
Header: req.Header.Clone(),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ro.HTTP.StatusCode = resp.StatusCode
|
ro.HTTP.StatusCode = resp.StatusCode
|
||||||
ro.HTTP.ResponseHeader = resp.Header
|
ro.HTTP.Response.Header = resp.Header
|
||||||
|
|
||||||
ro.Duration = time.Since(start)
|
ro.Duration = time.Since(start)
|
||||||
ro.Err = err.Error()
|
ro.Err = err.Error()
|
||||||
@@ -393,7 +396,8 @@ func (h *forwardHandler) handleHTTP(ctx context.Context, rw io.ReadWriteCloser,
|
|||||||
ro.Err = err.Error()
|
ro.Err = err.Error()
|
||||||
}
|
}
|
||||||
if res != nil && ro.HTTP != nil {
|
if res != nil && ro.HTTP != nil {
|
||||||
ro.HTTP.ResponseHeader = res.Header
|
ro.HTTP.Response.ContentLength = res.ContentLength
|
||||||
|
ro.HTTP.Response.Header = res.Header
|
||||||
ro.HTTP.StatusCode = res.StatusCode
|
ro.HTTP.StatusCode = res.StatusCode
|
||||||
}
|
}
|
||||||
ro.Record(ctx, h.recorder.Recorder)
|
ro.Record(ctx, h.recorder.Recorder)
|
||||||
|
|||||||
@@ -242,17 +242,20 @@ func (h *forwardHandler) handleHTTP(ctx context.Context, rw io.ReadWriteCloser,
|
|||||||
start := time.Now()
|
start := time.Now()
|
||||||
ro.Time = start
|
ro.Time = start
|
||||||
ro.HTTP = &xrecorder.HTTPRecorderObject{
|
ro.HTTP = &xrecorder.HTTPRecorderObject{
|
||||||
Host: req.Host,
|
Host: req.Host,
|
||||||
Proto: req.Proto,
|
Proto: req.Proto,
|
||||||
Scheme: req.URL.Scheme,
|
Scheme: req.URL.Scheme,
|
||||||
Method: req.Method,
|
Method: req.Method,
|
||||||
URI: req.RequestURI,
|
URI: req.RequestURI,
|
||||||
RequestHeader: req.Header.Clone(),
|
Request: xrecorder.HTTPRequestRecorderObject{
|
||||||
|
ContentLength: req.ContentLength,
|
||||||
|
Header: req.Header.Clone(),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ro.HTTP.StatusCode = resp.StatusCode
|
ro.HTTP.StatusCode = resp.StatusCode
|
||||||
ro.HTTP.ResponseHeader = resp.Header
|
ro.HTTP.Response.Header = resp.Header
|
||||||
|
|
||||||
ro.Duration = time.Since(start)
|
ro.Duration = time.Since(start)
|
||||||
ro.Err = err.Error()
|
ro.Err = err.Error()
|
||||||
@@ -394,7 +397,8 @@ func (h *forwardHandler) handleHTTP(ctx context.Context, rw io.ReadWriteCloser,
|
|||||||
ro.Err = err.Error()
|
ro.Err = err.Error()
|
||||||
}
|
}
|
||||||
if res != nil && ro.HTTP != nil {
|
if res != nil && ro.HTTP != nil {
|
||||||
ro.HTTP.ResponseHeader = res.Header
|
ro.HTTP.Response.ContentLength = res.ContentLength
|
||||||
|
ro.HTTP.Response.Header = res.Header
|
||||||
ro.HTTP.StatusCode = res.StatusCode
|
ro.HTTP.StatusCode = res.StatusCode
|
||||||
}
|
}
|
||||||
ro.Record(ctx, h.recorder.Recorder)
|
ro.Record(ctx, h.recorder.Recorder)
|
||||||
|
|||||||
+22
-15
@@ -203,16 +203,19 @@ func (h *httpHandler) handleRequest(ctx context.Context, conn net.Conn, req *htt
|
|||||||
}
|
}
|
||||||
|
|
||||||
ro.HTTP = &xrecorder.HTTPRecorderObject{
|
ro.HTTP = &xrecorder.HTTPRecorderObject{
|
||||||
Host: req.Host,
|
Host: req.Host,
|
||||||
Proto: req.Proto,
|
Proto: req.Proto,
|
||||||
Scheme: req.URL.Scheme,
|
Scheme: req.URL.Scheme,
|
||||||
Method: req.Method,
|
Method: req.Method,
|
||||||
URI: req.RequestURI,
|
URI: req.RequestURI,
|
||||||
RequestHeader: req.Header.Clone(),
|
Request: xrecorder.HTTPRequestRecorderObject{
|
||||||
|
ContentLength: req.ContentLength,
|
||||||
|
Header: req.Header.Clone(),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
ro.HTTP.StatusCode = resp.StatusCode
|
ro.HTTP.StatusCode = resp.StatusCode
|
||||||
ro.HTTP.ResponseHeader = resp.Header
|
ro.HTTP.Response.Header = resp.Header
|
||||||
}()
|
}()
|
||||||
|
|
||||||
clientID, ok := h.authenticate(ctx, conn, req, resp, log)
|
clientID, ok := h.authenticate(ctx, conn, req, resp, log)
|
||||||
@@ -334,13 +337,16 @@ func (h *httpHandler) handleProxy(ctx context.Context, rw io.ReadWriteCloser, cc
|
|||||||
|
|
||||||
if ro.HTTP != nil {
|
if ro.HTTP != nil {
|
||||||
ro.HTTP = &xrecorder.HTTPRecorderObject{
|
ro.HTTP = &xrecorder.HTTPRecorderObject{
|
||||||
Host: req.Host,
|
Host: req.Host,
|
||||||
Proto: req.Proto,
|
Proto: req.Proto,
|
||||||
Scheme: req.URL.Scheme,
|
Scheme: req.URL.Scheme,
|
||||||
Method: req.Method,
|
Method: req.Method,
|
||||||
URI: req.RequestURI,
|
URI: req.RequestURI,
|
||||||
RequestHeader: req.Header.Clone(),
|
StatusCode: resp.StatusCode,
|
||||||
StatusCode: resp.StatusCode,
|
Request: xrecorder.HTTPRequestRecorderObject{
|
||||||
|
ContentLength: req.ContentLength,
|
||||||
|
Header: req.Header.Clone(),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,7 +384,8 @@ func (h *httpHandler) handleProxy(ctx context.Context, rw io.ReadWriteCloser, cc
|
|||||||
ro.Err = err.Error()
|
ro.Err = err.Error()
|
||||||
}
|
}
|
||||||
if res != nil && ro.HTTP != nil {
|
if res != nil && ro.HTTP != nil {
|
||||||
ro.HTTP.ResponseHeader = res.Header
|
ro.HTTP.Response.ContentLength = res.ContentLength
|
||||||
|
ro.HTTP.Response.Header = res.Header
|
||||||
ro.HTTP.StatusCode = res.StatusCode
|
ro.HTTP.StatusCode = res.StatusCode
|
||||||
}
|
}
|
||||||
ro.Record(ctx, h.recorder.Recorder)
|
ro.Record(ctx, h.recorder.Recorder)
|
||||||
|
|||||||
@@ -198,16 +198,19 @@ func (h *http2Handler) roundTrip(ctx context.Context, w http.ResponseWriter, req
|
|||||||
}
|
}
|
||||||
|
|
||||||
ro.HTTP = &xrecorder.HTTPRecorderObject{
|
ro.HTTP = &xrecorder.HTTPRecorderObject{
|
||||||
Host: req.Host,
|
Host: req.Host,
|
||||||
Proto: req.Proto,
|
Proto: req.Proto,
|
||||||
Scheme: req.URL.Scheme,
|
Scheme: req.URL.Scheme,
|
||||||
Method: req.Method,
|
Method: req.Method,
|
||||||
URI: req.RequestURI,
|
URI: req.RequestURI,
|
||||||
RequestHeader: req.Header.Clone(),
|
Request: xrecorder.HTTPRequestRecorderObject{
|
||||||
|
ContentLength: req.ContentLength,
|
||||||
|
Header: req.Header.Clone(),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
ro.HTTP.StatusCode = resp.StatusCode
|
ro.HTTP.StatusCode = resp.StatusCode
|
||||||
ro.HTTP.ResponseHeader = resp.Header
|
ro.HTTP.Response.Header = resp.Header
|
||||||
}()
|
}()
|
||||||
|
|
||||||
clientID, ok := h.authenticate(ctx, w, req, resp, log)
|
clientID, ok := h.authenticate(ctx, w, req, resp, log)
|
||||||
|
|||||||
@@ -180,12 +180,15 @@ func (h *redirectHandler) handleHTTP(ctx context.Context, rw io.ReadWriter, radd
|
|||||||
}
|
}
|
||||||
|
|
||||||
ro.HTTP = &xrecorder.HTTPRecorderObject{
|
ro.HTTP = &xrecorder.HTTPRecorderObject{
|
||||||
Host: req.Host,
|
Host: req.Host,
|
||||||
Proto: req.Proto,
|
Proto: req.Proto,
|
||||||
Scheme: req.URL.Scheme,
|
Scheme: req.URL.Scheme,
|
||||||
Method: req.Method,
|
Method: req.Method,
|
||||||
URI: req.RequestURI,
|
URI: req.RequestURI,
|
||||||
RequestHeader: req.Header,
|
Request: xrecorder.HTTPRequestRecorderObject{
|
||||||
|
ContentLength: req.ContentLength,
|
||||||
|
Header: req.Header,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if log.IsLevelEnabled(logger.TraceLevel) {
|
if log.IsLevelEnabled(logger.TraceLevel) {
|
||||||
@@ -246,7 +249,8 @@ func (h *redirectHandler) handleHTTP(ctx context.Context, rw io.ReadWriter, radd
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
ro.HTTP.StatusCode = resp.StatusCode
|
ro.HTTP.StatusCode = resp.StatusCode
|
||||||
ro.HTTP.ResponseHeader = resp.Header
|
ro.HTTP.Response.ContentLength = resp.ContentLength
|
||||||
|
ro.HTTP.Response.Header = resp.Header
|
||||||
|
|
||||||
if log.IsLevelEnabled(logger.TraceLevel) {
|
if log.IsLevelEnabled(logger.TraceLevel) {
|
||||||
dump, _ := httputil.DumpResponse(resp, false)
|
dump, _ := httputil.DumpResponse(resp, false)
|
||||||
|
|||||||
+11
-7
@@ -129,12 +129,15 @@ func (h *sniHandler) handleHTTP(ctx context.Context, rw io.ReadWriter, raddr net
|
|||||||
}
|
}
|
||||||
|
|
||||||
ro.HTTP = &xrecorder.HTTPRecorderObject{
|
ro.HTTP = &xrecorder.HTTPRecorderObject{
|
||||||
Host: req.Host,
|
Host: req.Host,
|
||||||
Proto: req.Proto,
|
Proto: req.Proto,
|
||||||
Scheme: req.URL.Scheme,
|
Scheme: req.URL.Scheme,
|
||||||
Method: req.Method,
|
Method: req.Method,
|
||||||
URI: req.RequestURI,
|
URI: req.RequestURI,
|
||||||
RequestHeader: req.Header,
|
Request: xrecorder.HTTPRequestRecorderObject{
|
||||||
|
ContentLength: req.ContentLength,
|
||||||
|
Header: req.Header,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if log.IsLevelEnabled(logger.TraceLevel) {
|
if log.IsLevelEnabled(logger.TraceLevel) {
|
||||||
@@ -192,7 +195,8 @@ func (h *sniHandler) handleHTTP(ctx context.Context, rw io.ReadWriter, raddr net
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
ro.HTTP.StatusCode = resp.StatusCode
|
ro.HTTP.StatusCode = resp.StatusCode
|
||||||
ro.HTTP.ResponseHeader = resp.Header
|
ro.HTTP.Response.ContentLength = resp.ContentLength
|
||||||
|
ro.HTTP.Response.Header = resp.Header
|
||||||
|
|
||||||
if log.IsLevelEnabled(logger.TraceLevel) {
|
if log.IsLevelEnabled(logger.TraceLevel) {
|
||||||
dump, _ := httputil.DumpResponse(resp, false)
|
dump, _ := httputil.DumpResponse(resp, false)
|
||||||
|
|||||||
@@ -91,12 +91,15 @@ func (ep *entrypoint) handle(ctx context.Context, conn net.Conn) error {
|
|||||||
Host: req.Host,
|
Host: req.Host,
|
||||||
Time: start,
|
Time: start,
|
||||||
HTTP: &xrecorder.HTTPRecorderObject{
|
HTTP: &xrecorder.HTTPRecorderObject{
|
||||||
Host: req.Host,
|
Host: req.Host,
|
||||||
Method: req.Method,
|
Method: req.Method,
|
||||||
Proto: req.Proto,
|
Proto: req.Proto,
|
||||||
Scheme: req.URL.Scheme,
|
Scheme: req.URL.Scheme,
|
||||||
URI: req.RequestURI,
|
URI: req.RequestURI,
|
||||||
RequestHeader: req.Header,
|
Request: xrecorder.HTTPRequestRecorderObject{
|
||||||
|
ContentLength: req.ContentLength,
|
||||||
|
Header: req.Header,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
@@ -107,7 +110,7 @@ func (ep *entrypoint) handle(ctx context.Context, conn net.Conn) error {
|
|||||||
}).Debugf("%s >-< %s", conn.RemoteAddr(), req.Host)
|
}).Debugf("%s >-< %s", conn.RemoteAddr(), req.Host)
|
||||||
|
|
||||||
ro.HTTP.StatusCode = resp.StatusCode
|
ro.HTTP.StatusCode = resp.StatusCode
|
||||||
ro.HTTP.ResponseHeader = resp.Header
|
ro.HTTP.Response.Header = resp.Header
|
||||||
|
|
||||||
ro.Duration = d
|
ro.Duration = d
|
||||||
ro.Err = err.Error()
|
ro.Err = err.Error()
|
||||||
@@ -243,8 +246,9 @@ func (ep *entrypoint) handle(ctx context.Context, conn net.Conn) error {
|
|||||||
ro.Err = err.Error()
|
ro.Err = err.Error()
|
||||||
}
|
}
|
||||||
if res != nil && ro.HTTP != nil {
|
if res != nil && ro.HTTP != nil {
|
||||||
ro.HTTP.ResponseHeader = res.Header
|
|
||||||
ro.HTTP.StatusCode = res.StatusCode
|
ro.HTTP.StatusCode = res.StatusCode
|
||||||
|
ro.HTTP.Response.ContentLength = res.ContentLength
|
||||||
|
ro.HTTP.Response.Header = res.Header
|
||||||
}
|
}
|
||||||
ro.Record(ctx, ep.recorder.Recorder)
|
ro.Record(ctx, ep.recorder.Recorder)
|
||||||
}()
|
}()
|
||||||
|
|||||||
+18
-10
@@ -15,17 +15,25 @@ const (
|
|||||||
RecorderServiceHandlerTunnel = "recorder.service.handler.tunnel"
|
RecorderServiceHandlerTunnel = "recorder.service.handler.tunnel"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type HTTPRequestRecorderObject struct {
|
||||||
|
ContentLength int64 `json:"contentLength"`
|
||||||
|
Header http.Header `json:"header"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type HTTPResponseRecorderObject struct {
|
||||||
|
ContentLength int64 `json:"contentLength"`
|
||||||
|
Header http.Header `json:"header"`
|
||||||
|
}
|
||||||
|
|
||||||
type HTTPRecorderObject struct {
|
type HTTPRecorderObject struct {
|
||||||
Host string `json:"host"`
|
Host string `json:"host"`
|
||||||
Method string `json:"method"`
|
Method string `json:"method"`
|
||||||
Proto string `json:"proto"`
|
Proto string `json:"proto"`
|
||||||
Scheme string `json:"scheme"`
|
Scheme string `json:"scheme"`
|
||||||
URI string `json:"uri"`
|
URI string `json:"uri"`
|
||||||
StatusCode int `json:"statusCode"`
|
StatusCode int `json:"statusCode"`
|
||||||
RequestHeader http.Header `json:"requestHeader"`
|
Request HTTPRequestRecorderObject `json:"request"`
|
||||||
ResponseHeader http.Header `json:"responseHeader"`
|
Response HTTPResponseRecorderObject `json:"response"`
|
||||||
// RequestBody string
|
|
||||||
// ResponseBody string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type DNSRecorderObject struct {
|
type DNSRecorderObject struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user