feat(botfilter): botfilter.go part 1/2
This commit is contained in:
1 parent
9fe86bc379
commit
1027804b48
1 file changed
+17
@@ -52,3 +52,20 @@ func (b *botFilter) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
match := inspectRequest(r, b.config)
|
||||
paths := requestPaths(r)
|
||||
decision := b.cache.observeRequest(ip, requestObservation{
|
||||
at: now,
|
||||
paths: paths,
|
||||
points: match.points,
|
||||
forceBan: match.forceBan,
|
||||
})
|
||||
if decision.banned {
|
||||
reason := match.reason
|
||||
if reason == "" {
|
||||
reason = "suspicion score threshold"
|
||||
}
|
||||
b.reject(rw, ip, reason, decision)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user