From 05d183c94bbc11b6319db7115fe37fbee6645d82 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Mon, 7 Jul 2025 17:36:25 +0700 Subject: [PATCH] Correct debug logging in DNS-over-HTTP transport Logging there should use Log function to include the request ID if present. Changes were made unintentionally during the refactoring to eliminate usage of global logger. This commits message restores the correct/old behavior. --- config.go | 4 ++-- config_quic.go | 4 ++-- doh.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config.go b/config.go index 14dd76c..8b359ed 100644 --- a/config.go +++ b/config.go @@ -552,7 +552,7 @@ func (uc *UpstreamConfig) newDOHTransport(ctx context.Context, addrs []string) * if uc.BootstrapIP != "" { dialer := net.Dialer{Timeout: dialerTimeout, KeepAlive: dialerTimeout} addr := net.JoinHostPort(uc.BootstrapIP, port) - logger.Debug().Msgf("sending doh request to: %s", addr) + Log(ctx, logger.Debug(), "sending doh request to: %s", addr) return dialer.DialContext(ctx, network, addr) } pd := &ctrldnet.ParallelDialer{} @@ -566,7 +566,7 @@ func (uc *UpstreamConfig) newDOHTransport(ctx context.Context, addrs []string) * if err != nil { return nil, err } - logger.Debug().Msgf("sending doh request to: %s", conn.RemoteAddr()) + Log(ctx, logger.Debug(), "sending doh request to: %s", conn.RemoteAddr()) return conn, nil } runtime.SetFinalizer(transport, func(transport *http.Transport) { diff --git a/config_quic.go b/config_quic.go index 8f27bf3..fb5ff9c 100644 --- a/config_quic.go +++ b/config_quic.go @@ -42,7 +42,7 @@ func (uc *UpstreamConfig) newDOH3Transport(ctx context.Context, addrs []string) // if we have a bootstrap ip set, use it to avoid DNS lookup if uc.BootstrapIP != "" { addr = net.JoinHostPort(uc.BootstrapIP, port) - logger.Debug().Msgf("sending doh3 request to: %s", addr) + Log(ctx, logger.Debug(), "sending doh3 request to: %s", addr) udpConn, err := net.ListenUDP("udp", nil) if err != nil { return nil, err @@ -62,7 +62,7 @@ func (uc *UpstreamConfig) newDOH3Transport(ctx context.Context, addrs []string) if err != nil { return nil, err } - logger.Debug().Msgf("sending doh3 request to: %s", conn.RemoteAddr()) + Log(ctx, logger.Debug(), "sending doh3 request to: %s", conn.RemoteAddr()) return conn, err } runtime.SetFinalizer(rt, func(rt *http3.Transport) { diff --git a/doh.go b/doh.go index f93dc88..6fbfb71 100644 --- a/doh.go +++ b/doh.go @@ -165,7 +165,7 @@ func addHeader(ctx context.Context, req *http.Request, uc *UpstreamConfig) { } if printed { logger := LoggerFromCtx(ctx) - logger.Debug().Msgf("sending request header: %v", dohHeader) + Log(ctx, logger.Debug(), "sending request header: %v", dohHeader) } dohHeader.Set("Content-Type", headerApplicationDNS) dohHeader.Set("Accept", headerApplicationDNS)