From ff4aae6098b4c4336251c60be192caae4b68b6e5 Mon Sep 17 00:00:00 2001 From: WeidiDeng Date: Mon, 28 Apr 2025 16:52:49 +0800 Subject: [PATCH] check if connection implements connectionStater when it should --- modules/caddyhttp/http2listener.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) 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") }