geojs: a visitor's wait no longer cuts off the request to GeoJS (closes #404)
check / check (push) Failing after 3m22s

The GeoJS lookup and its cache move from internal/lookup to internal/geojs,
which imports no other package of this repository. waf hands it functions
to count requests, report failures and count lookups that went without an
answer; waf keeps the log line, the source_failure alert and the metrics.

The caller now passes its wait to each lookup. waf passes
SWW_WAF_ASN_AND_COUNTRY_LOOKUP_TIMEOUT_MS. A request to GeoJS has its own
fixed limit of 10 seconds, and only passing it or an error from GeoJS is a
failure. An answer that comes after the caller stopped waiting is kept.

internal/lookup keeps the lookup database and returns geojs.Answer.

Model: opus-5-5
This commit is contained in:
sneak committed 2026-11-16 23:18:27 +00:00
1 parent a2fcc00ded
commit 56f93d4f74
21 files changed
+645 -484

No files matched your search

+2 -1
View File
@@ -16,6 +16,7 @@ import (
"github.com/maxmind/mmdbwriter/mmdbtype"
"sneak.berlin/go/smallwebwaf/internal/alerts"
"sneak.berlin/go/smallwebwaf/internal/geojs"
"sneak.berlin/go/smallwebwaf/internal/lookup/lookuptest"
)
@@ -68,7 +69,7 @@ func TestFilePlacesClientsAndCountsAnAddressMissingFromItAsUnknown(
prefix := netip.MustParsePrefix(client)
got := f.LookUp(prefix)
if got != (Answer{
if got != (geojs.Answer{
Client: prefix, ASN: want.ASN, ASName: want.ASName, Country: want.Country,
Answered: now,
}) {