From 9c2a6344086662732efd3e7814d0251a30a43f69 Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Tue, 1 Nov 2022 16:28:39 -0700 Subject: [PATCH] Fix ctr crash when pulling with http-trace and http-dump Signed-off-by: Maksym Pavlenko --- cmd/ctr/commands/resolver.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/ctr/commands/resolver.go b/cmd/ctr/commands/resolver.go index bfeccf580..bd533e171 100644 --- a/cmd/ctr/commands/resolver.go +++ b/cmd/ctr/commands/resolver.go @@ -200,7 +200,12 @@ func NewDebugClientTrace(ctx gocontext.Context) *httptrace.ClientTrace { } }, GotConn: func(connInfo httptrace.GotConnInfo) { - log.G(ctx).WithField("reused", connInfo.Reused).WithField("remote_addr", connInfo.Conn.RemoteAddr().String()).Debugf("Connection successful") + remoteAddr := "" + if addr := connInfo.Conn.RemoteAddr(); addr != nil { + remoteAddr = addr.String() + } + + log.G(ctx).WithField("reused", connInfo.Reused).WithField("remote_addr", remoteAddr).Debugf("Connection successful") }, } }