add src field for logger and recorder

This commit is contained in:
ginuerzh
2025-07-02 21:35:02 +08:00
parent 97ed5080a6
commit d9a2f44a78
27 changed files with 217 additions and 92 deletions
+7 -3
View File
@@ -5,7 +5,6 @@ import (
"bytes"
"context"
"errors"
"fmt"
"net"
"strconv"
"time"
@@ -233,8 +232,9 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn, opts ...hand
ro.Host = target.Addr
log = log.WithFields(map[string]any{
"node": target.Name,
"dst": fmt.Sprintf("%s/%s", target.Addr, network),
"node": target.Name,
"dst": target.Addr,
"network": network,
})
log.Debugf("%s >> %s", conn.RemoteAddr(), target.Addr)
@@ -256,6 +256,10 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn, opts ...hand
marker.Reset()
}
log = log.WithFields(map[string]any{"src": cc.LocalAddr().String(), "dst": cc.RemoteAddr().String()})
ro.Src = cc.LocalAddr().String()
ro.Dst = cc.RemoteAddr().String()
cc = proxyproto.WrapClientConn(h.md.proxyProtocol, conn.RemoteAddr(), convertAddr(conn.LocalAddr()), cc)
t := time.Now()