From ce2da421fa13fe39e2ec58251a8b43e71a2a0288 Mon Sep 17 00:00:00 2001 From: ginuerzh Date: Sun, 15 Sep 2024 18:37:49 +0800 Subject: [PATCH] fix recorder clientIP --- handler/dns/handler.go | 1 + handler/redirect/udp/handler.go | 1 + handler/relay/handler.go | 1 + handler/socks/v4/handler.go | 1 + handler/socks/v5/handler.go | 1 + handler/ss/handler.go | 1 + handler/ss/udp/handler.go | 1 + handler/sshd/handler.go | 1 + handler/unix/handler.go | 1 + 9 files changed, 9 insertions(+) diff --git a/handler/dns/handler.go b/handler/dns/handler.go index 1880a944..34280ddf 100644 --- a/handler/dns/handler.go +++ b/handler/dns/handler.go @@ -141,6 +141,7 @@ func (h *dnsHandler) Handle(ctx context.Context, conn net.Conn, opts ...handler. Time: start, SID: string(ctxvalue.SidFromContext(ctx)), } + ro.ClientIP, _, _ = net.SplitHostPort(conn.RemoteAddr().String()) log := h.options.Logger.WithFields(map[string]any{ "remote": conn.RemoteAddr().String(), diff --git a/handler/redirect/udp/handler.go b/handler/redirect/udp/handler.go index 38970183..d8a8e547 100644 --- a/handler/redirect/udp/handler.go +++ b/handler/redirect/udp/handler.go @@ -65,6 +65,7 @@ func (h *redirectHandler) Handle(ctx context.Context, conn net.Conn, opts ...han Time: start, SID: string(ctxvalue.SidFromContext(ctx)), } + ro.ClientIP, _, _ = net.SplitHostPort(conn.RemoteAddr().String()) log := h.options.Logger.WithFields(map[string]any{ "remote": conn.RemoteAddr().String(), diff --git a/handler/relay/handler.go b/handler/relay/handler.go index d980f34f..7580392f 100644 --- a/handler/relay/handler.go +++ b/handler/relay/handler.go @@ -96,6 +96,7 @@ func (h *relayHandler) Handle(ctx context.Context, conn net.Conn, opts ...handle Time: start, SID: string(ctxvalue.SidFromContext(ctx)), } + ro.ClientIP, _, _ = net.SplitHostPort(conn.RemoteAddr().String()) log := h.options.Logger.WithFields(map[string]any{ "remote": conn.RemoteAddr().String(), diff --git a/handler/socks/v4/handler.go b/handler/socks/v4/handler.go index b2351748..451b87e6 100644 --- a/handler/socks/v4/handler.go +++ b/handler/socks/v4/handler.go @@ -95,6 +95,7 @@ func (h *socks4Handler) Handle(ctx context.Context, conn net.Conn, opts ...handl Time: start, SID: string(ctxvalue.SidFromContext(ctx)), } + ro.ClientIP, _, _ = net.SplitHostPort(conn.RemoteAddr().String()) log := h.options.Logger.WithFields(map[string]any{ "remote": conn.RemoteAddr().String(), diff --git a/handler/socks/v5/handler.go b/handler/socks/v5/handler.go index 3ad16cfc..444653fc 100644 --- a/handler/socks/v5/handler.go +++ b/handler/socks/v5/handler.go @@ -97,6 +97,7 @@ func (h *socks5Handler) Handle(ctx context.Context, conn net.Conn, opts ...handl Time: start, SID: string(ctxvalue.SidFromContext(ctx)), } + ro.ClientIP, _, _ = net.SplitHostPort(conn.RemoteAddr().String()) log := h.options.Logger.WithFields(map[string]any{ "remote": conn.RemoteAddr().String(), diff --git a/handler/ss/handler.go b/handler/ss/handler.go index 81bb5d82..1f8ce0a3 100644 --- a/handler/ss/handler.go +++ b/handler/ss/handler.go @@ -77,6 +77,7 @@ func (h *ssHandler) Handle(ctx context.Context, conn net.Conn, opts ...handler.H Time: start, SID: string(ctxvalue.SidFromContext(ctx)), } + ro.ClientIP, _, _ = net.SplitHostPort(conn.RemoteAddr().String()) log := h.options.Logger.WithFields(map[string]any{ "remote": conn.RemoteAddr().String(), diff --git a/handler/ss/udp/handler.go b/handler/ss/udp/handler.go index 9d33b181..686bbf33 100644 --- a/handler/ss/udp/handler.go +++ b/handler/ss/udp/handler.go @@ -79,6 +79,7 @@ func (h *ssuHandler) Handle(ctx context.Context, conn net.Conn, opts ...handler. Time: start, SID: string(ctxvalue.SidFromContext(ctx)), } + ro.ClientIP, _, _ = net.SplitHostPort(conn.RemoteAddr().String()) log := h.options.Logger.WithFields(map[string]any{ "remote": conn.RemoteAddr().String(), diff --git a/handler/sshd/handler.go b/handler/sshd/handler.go index a6f9e1be..1f21201d 100644 --- a/handler/sshd/handler.go +++ b/handler/sshd/handler.go @@ -77,6 +77,7 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn, opts ...hand Time: start, SID: string(ctxvalue.SidFromContext(ctx)), } + ro.ClientIP, _, _ = net.SplitHostPort(conn.RemoteAddr().String()) log := h.options.Logger.WithFields(map[string]any{ "remote": conn.RemoteAddr().String(), diff --git a/handler/unix/handler.go b/handler/unix/handler.go index 1801990c..7a165cba 100644 --- a/handler/unix/handler.go +++ b/handler/unix/handler.go @@ -74,6 +74,7 @@ func (h *unixHandler) Handle(ctx context.Context, conn net.Conn, opts ...handler Time: start, SID: string(ctxvalue.SidFromContext(ctx)), } + ro.ClientIP, _, _ = net.SplitHostPort(conn.RemoteAddr().String()) log := h.options.Logger.WithFields(map[string]any{ "remote": conn.RemoteAddr().String(),