From 99ffe9338837eff80def7e5d51c2a0e02f56abdb Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Wed, 5 Oct 2022 14:14:13 -0400 Subject: logging: Fix `skip_hosts` with wildcards (#5102) Fix #4859 --- modules/caddyhttp/server.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'modules') diff --git a/modules/caddyhttp/server.go b/modules/caddyhttp/server.go index 4d47d26..60fc3c3 100644 --- a/modules/caddyhttp/server.go +++ b/modules/caddyhttp/server.go @@ -639,21 +639,18 @@ func (s *Server) shouldLogRequest(r *http.Request) bool { // logging is disabled return false } + if _, ok := s.Logs.LoggerNames[r.Host]; ok { + // this host is mapped to a particular logger name + return true + } for _, dh := range s.Logs.SkipHosts { // logging for this particular host is disabled if certmagic.MatchWildcard(r.Host, dh) { return false } } - if _, ok := s.Logs.LoggerNames[r.Host]; ok { - // this host is mapped to a particular logger name - return true - } - if s.Logs.SkipUnmappedHosts { - // this host is not mapped and thus must not be logged - return false - } - return true + // if configured, this host is not mapped and thus must not be logged + return !s.Logs.SkipUnmappedHosts } // protocol returns true if the protocol proto is configured/enabled. -- cgit v1.2.3