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"
"time"
@@ -223,8 +222,9 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn, opts ...hand
ro.Host = addr
log = log.WithFields(map[string]any{
"node": target.Name,
"dst": fmt.Sprintf("%s/%s", addr, network),
"node": target.Name,
"dst": addr,
"network": network,
})
log.Debugf("%s >> %s", conn.RemoteAddr(), addr)
@@ -246,6 +246,10 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn, opts ...hand
}
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()
t := time.Now()
log.Infof("%s <-> %s", conn.RemoteAddr(), target.Addr)
xnet.Transport(conn, cc)