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
+5 -2
View File
@@ -6,7 +6,6 @@ import (
"context"
"crypto/tls"
"errors"
"fmt"
"io"
"net"
"time"
@@ -33,7 +32,7 @@ func (h *relayHandler) handleConnect(ctx context.Context, conn net.Conn, network
}
log = log.WithFields(map[string]any{
"dst": fmt.Sprintf("%s/%s", address, network),
"dst": address,
"cmd": "connect",
"host": address,
})
@@ -114,6 +113,10 @@ func (h *relayHandler) handleConnect(ctx context.Context, conn net.Conn, network
}
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()
if h.md.noDelay {
if _, err := resp.WriteTo(conn); err != nil {
log.Error(err)