add src field for logger and recorder
This commit is contained in:
+10
-2
@@ -229,8 +229,9 @@ func (h *httpHandler) handleRequest(ctx context.Context, conn net.Conn, req *htt
|
||||
ro.Host = addr
|
||||
|
||||
fields := map[string]any{
|
||||
"dst": addr,
|
||||
"host": addr,
|
||||
"dst": addr,
|
||||
"host": addr,
|
||||
"network": network,
|
||||
}
|
||||
|
||||
if u, _, _ := h.basicProxyAuth(req.Header.Get("Proxy-Authorization")); u != "" {
|
||||
@@ -288,6 +289,9 @@ func (h *httpHandler) handleRequest(ctx context.Context, conn net.Conn, req *htt
|
||||
return errors.New("authentication failed")
|
||||
}
|
||||
|
||||
log = log.WithFields(map[string]any{"clientID": clientID})
|
||||
ro.ClientID = clientID
|
||||
|
||||
if resp.Header.Get("Proxy-Agent") == "" {
|
||||
resp.Header.Set("Proxy-Agent", h.md.proxyAgent)
|
||||
}
|
||||
@@ -354,6 +358,10 @@ func (h *httpHandler) handleRequest(ctx context.Context, conn net.Conn, req *htt
|
||||
}
|
||||
defer cc.Close()
|
||||
|
||||
log = log.WithFields(map[string]any{"src": cc.LocalAddr().String(), "dst": cc.RemoteAddr().String()})
|
||||
ro.Src = cc.LocalAddr().String()
|
||||
ro.Dst = cc.RemoteAddr().String()
|
||||
|
||||
resp.StatusCode = http.StatusOK
|
||||
resp.Status = "200 Connection established"
|
||||
|
||||
|
||||
@@ -63,6 +63,9 @@ func (h *httpHandler) handleUDP(ctx context.Context, conn net.Conn, ro *xrecorde
|
||||
}
|
||||
defer c.Close()
|
||||
|
||||
log.WithFields(map[string]any{"src": c.LocalAddr().String()})
|
||||
ro.Src = c.LocalAddr().String()
|
||||
|
||||
pc, ok := c.(net.PacketConn)
|
||||
if !ok {
|
||||
err = errors.New("wrong connection type")
|
||||
|
||||
Reference in New Issue
Block a user