logging: Fix skip_hosts with wildcards (#5102)

Fix #4859
This commit is contained in:
Francis Lavoie
2022-10-05 14:14:13 -04:00
committed by GitHub
parent e07a267276
commit 99ffe93388
5 changed files with 23 additions and 38 deletions
+6 -9
View File
@@ -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.