From 02f9134a05bb108ffba68fac5a1d5ee3b93b3029 Mon Sep 17 00:00:00 2001 From: clawbot Date: Fri, 20 Nov 2026 00:44:27 +0000 Subject: [PATCH] waf: refusedWhateverTheAnswer in lookup.go, beside its only caller It decides whether a request skips the wait for GeoJS, and only startLookUp calls it. It is not question or report code, so in questionsandreports.go the file's name did not say what it held. Model: opus-5-5 --- internal/waf/lookup.go | 20 ++++++++++++++++++++ internal/waf/questionsandreports.go | 20 -------------------- 2 files changed, 20 insertions(+), 20 deletions(-) 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.