Update bouncer pull in rupture mode (#1445)

* Update bouncer pull in rupture mode

Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
This commit is contained in:
Shivam Sandbhor 2022-04-15 15:54:01 +05:30 committed by GitHub
parent b3786961de
commit 4a3ec85686
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,6 +7,7 @@ import (
"fmt"
"net/http"
"strings"
"time"
"github.com/crowdsecurity/crowdsec/pkg/database"
"github.com/gin-gonic/gin"
@ -109,6 +110,12 @@ func (a *APIKey) MiddlewareFunc() gin.HandlerFunc {
}
}
if c.Request.Method != "HEAD" && time.Now().UTC().Sub(bouncer.LastPull) >= time.Minute {
if err := a.DbClient.UpdateBouncerLastPull(time.Now().UTC(), bouncer.ID); err != nil {
log.Errorf("failed to update bouncer last pull: %v", err)
}
}
c.Next()
}
}