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.
This commit is contained in:
Cuong Manh Le authored and Cuong Manh Le committed 2026-04-30 19:19:18 +07:00
1 parent a63fa31969
commit f573de851a
3 files changed
+5 -5

No files matched your search

+2 -2
View File
@@ -552,7 +552,7 @@ func (uc *UpstreamConfig) newDOHTransport(ctx context.Context, addrs []string) *
if uc.BootstrapIP != "" { if uc.BootstrapIP != "" {
dialer := net.Dialer{Timeout: dialerTimeout, KeepAlive: dialerTimeout} dialer := net.Dialer{Timeout: dialerTimeout, KeepAlive: dialerTimeout}
addr := net.JoinHostPort(uc.BootstrapIP, port) 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) return dialer.DialContext(ctx, network, addr)
} }
pd := &ctrldnet.ParallelDialer{} pd := &ctrldnet.ParallelDialer{}
@@ -566,7 +566,7 @@ func (uc *UpstreamConfig) newDOHTransport(ctx context.Context, addrs []string) *
if err != nil { if err != nil {
return nil, err 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 return conn, nil
} }
runtime.SetFinalizer(transport, func(transport *http.Transport) { runtime.SetFinalizer(transport, func(transport *http.Transport) {
+2 -2
View File
@@ -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 we have a bootstrap ip set, use it to avoid DNS lookup
if uc.BootstrapIP != "" { if uc.BootstrapIP != "" {
addr = net.JoinHostPort(uc.BootstrapIP, port) 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) udpConn, err := net.ListenUDP("udp", nil)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -62,7 +62,7 @@ func (uc *UpstreamConfig) newDOH3Transport(ctx context.Context, addrs []string)
if err != nil { if err != nil {
return nil, err 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 return conn, err
} }
runtime.SetFinalizer(rt, func(rt *http3.Transport) { runtime.SetFinalizer(rt, func(rt *http3.Transport) {
+1 -1
View File
@@ -165,7 +165,7 @@ func addHeader(ctx context.Context, req *http.Request, uc *UpstreamConfig) {
} }
if printed { if printed {
logger := LoggerFromCtx(ctx) 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("Content-Type", headerApplicationDNS)
dohHeader.Set("Accept", headerApplicationDNS) dohHeader.Set("Accept", headerApplicationDNS)