diff --git a/internal/waf/lookup.go b/internal/waf/lookup.go index e558cee..f6c43d2 100644 --- a/internal/waf/lookup.go +++ b/internal/waf/lookup.go @@ -80,6 +80,26 @@ func (rq *request) startLookUp( return result } +// refusedWhateverTheAnswer reports whether the request is one that does not wait +// for GeoJS, since the checks will refuse it at now whatever GeoJS answers about +// its client: a heuristic of afterLookup that implements refusesWithoutLookup +// says it will refuse it. In observe mode, which refuses nothing, none is. +// rproxy lets a request through when waf answers too late. +func (rq *request) refusedWhateverTheAnswer(now time.Time) bool { + if rq.h.config.Observe { + return false + } + + for _, each := range rq.h.afterLookup { + knows, ok := each.(refusesWithoutLookup) + if ok && knows.refusesWhateverTheLookupAnswers(rq, now) { + return true + } + } + + return false +} + // noteLookup notes result for the log line and as the request's asn= and // country= tags. func (rq *request) noteLookup(result lookupResult) { diff --git a/internal/waf/questionsandreports.go b/internal/waf/questionsandreports.go index 3ea94ef..72e3aed 100644 --- a/internal/waf/questionsandreports.go +++ b/internal/waf/questionsandreports.go @@ -11,26 +11,6 @@ import ( "sneak.berlin/go/smallwebwaf/internal/wafprotocol" ) -// refusedWhateverTheAnswer reports whether the request is one that does not wait -// for GeoJS, since the checks will refuse it at now whatever GeoJS answers about -// its client: a heuristic of afterLookup that implements refusesWithoutLookup -// says it will refuse it. In observe mode, which refuses nothing, none is. -// rproxy lets a request through when waf answers too late. -func (rq *request) refusedWhateverTheAnswer(now time.Time) bool { - if rq.h.config.Observe { - return false - } - - for _, each := range rq.h.afterLookup { - knows, ok := each.(refusesWithoutLookup) - if ok && knows.refusesWhateverTheLookupAnswers(rq, now) { - return true - } - } - - return false -} - // answerQuestion runs the checks on the visitor's request a question // carries, and answers rproxy what to do with it. A denied request's counting // is finished here, and an allowed one's by its report.