diff --git a/modules/caddyhttp/http2listener.go b/modules/caddyhttp/http2listener.go index 240870653..ff2d499b9 100644 --- a/modules/caddyhttp/http2listener.go +++ b/modules/caddyhttp/http2listener.go @@ -36,14 +36,11 @@ func (h *http2Listener) Accept() (net.Conn, error) { return nil, err } - if h.useTLS { - // emit a warning - if _, ok := conn.(connectionStater); !ok { - h.logger.Warn("tls is enabled, but listener wrapper returns a connection that doesn't implement connectionStater") - } - } - - if _, ok := conn.(connectionStater); ok { + _, isConnectionStater := conn.(connectionStater) + // emit a warning + if h.useTLS && !isConnectionStater { + h.logger.Warn("tls is enabled, but listener wrapper returns a connection that doesn't implement connectionStater") + } else if isConnectionStater { h.logger.Warn("tls is disabled, but listener wrapper returns a connection that implements connectionStater") }