diff --git a/handler/forward/local/handler.go b/handler/forward/local/handler.go index 50b53939..2d8946d3 100644 --- a/handler/forward/local/handler.go +++ b/handler/forward/local/handler.go @@ -105,6 +105,12 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn, opts ...hand }) log.Infof("%s <> %s", conn.RemoteAddr(), conn.LocalAddr()) + network := "tcp" + if _, ok := conn.(net.PacketConn); ok { + network = "udp" + } + ro.Network = network + pStats := stats.Stats{} conn = stats_wrapper.WrapConn(conn, &pStats) @@ -130,12 +136,6 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn, opts ...hand return rate_limiter.ErrRateLimit } - network := "tcp" - if _, ok := conn.(net.PacketConn); ok { - network = "udp" - } - ro.Network = network - var proto string if network == "tcp" && h.md.sniffing { if h.md.sniffingTimeout > 0 { diff --git a/handler/forward/remote/handler.go b/handler/forward/remote/handler.go index 4ac4461a..3cc6bd4b 100644 --- a/handler/forward/remote/handler.go +++ b/handler/forward/remote/handler.go @@ -106,6 +106,12 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn, opts ...hand }) log.Infof("%s <> %s", conn.RemoteAddr(), conn.LocalAddr()) + network := "tcp" + if _, ok := conn.(net.PacketConn); ok { + network = "udp" + } + ro.Network = network + pStats := stats.Stats{} conn = stats_wrapper.WrapConn(conn, &pStats) @@ -131,12 +137,6 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn, opts ...hand return rate_limiter.ErrRateLimit } - network := "tcp" - if _, ok := conn.(net.PacketConn); ok { - network = "udp" - } - ro.Network = network - var proto string if network == "tcp" && h.md.sniffing { if h.md.sniffingTimeout > 0 {