🐛 Revert condition of healthy stream in stream mode (#48)

* 🐛 Revert condition of healthy stream in stream mode

* 🔊 Update logs format for error case

* ♻️ Invest condition for is stream healthy
This commit is contained in:
mathieuHa
2022-11-27 11:52:41 +01:00
committed by GitHub
parent 70558c781a
commit 16d392ebeb
+3 -3
View File
@@ -194,15 +194,15 @@ func (bouncer *Bouncer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
// Right here if we cannot join the stream we forbid the request to go on.
if bouncer.crowdsecMode == streamMode {
if isCrowdsecStreamHealthy {
bouncer.next.ServeHTTP(rw, req)
} else {
logger.Error(fmt.Sprintf("ServeHTTP:isCrowdsecStreamHealthy ip:%s", remoteIP))
rw.WriteHeader(http.StatusForbidden)
} else {
bouncer.next.ServeHTTP(rw, req)
}
} else {
err = handleNoStreamCache(bouncer, remoteIP)
if err != nil {
logger.Debug(err.Error())
logger.Debug(fmt.Sprintf("ServeHTTP:handleNoStreamCache ip:%s %s", remoteIP, err.Error()))
rw.WriteHeader(http.StatusForbidden)
} else {
bouncer.next.ServeHTTP(rw, req)