geojs: a visitor's wait no longer cuts off the request to GeoJS (closes #404)
check / check (push) Failing after 3m22s
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:
1 parent
a2fcc00ded
commit
56f93d4f74
21 files changed
+645
-484
No files matched your search
@@ -46,7 +46,7 @@ import (
|
||||
"sneak.berlin/go/smallwebwaf/internal/alerts"
|
||||
"sneak.berlin/go/smallwebwaf/internal/anomaly"
|
||||
"sneak.berlin/go/smallwebwaf/internal/bans"
|
||||
"sneak.berlin/go/smallwebwaf/internal/lookup"
|
||||
"sneak.berlin/go/smallwebwaf/internal/geojs"
|
||||
"sneak.berlin/go/smallwebwaf/internal/metrics"
|
||||
"sneak.berlin/go/smallwebwaf/internal/ratelimit"
|
||||
"sneak.berlin/go/smallwebwaf/internal/reputation"
|
||||
@@ -135,7 +135,7 @@ type Params struct {
|
||||
// sww runs.
|
||||
Ledger *bans.Ledger
|
||||
Limiter *ratelimit.Limiter
|
||||
GeoJS *lookup.GeoJS
|
||||
GeoJS *geojs.GeoJS
|
||||
Lists *reputation.Lists
|
||||
DNSBL *reputation.DNSBL
|
||||
AbuseIPDB *reputation.AbuseIPDB
|
||||
@@ -195,8 +195,8 @@ type clientsFile struct {
|
||||
|
||||
// lookupsFile is lookups.json, with each answer on a line of its own.
|
||||
type lookupsFile struct {
|
||||
Version int `json:"version"`
|
||||
Lookups []lookup.Answer `json:"lookups"`
|
||||
Version int `json:"version"`
|
||||
Lookups []geojs.Answer `json:"lookups"`
|
||||
}
|
||||
|
||||
// abuseIPDBChecksSpentFile is abuseipdb-checks-spent.json, indented for an
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
"sneak.berlin/go/smallwebwaf/internal/alerts"
|
||||
"sneak.berlin/go/smallwebwaf/internal/anomaly"
|
||||
"sneak.berlin/go/smallwebwaf/internal/bans"
|
||||
"sneak.berlin/go/smallwebwaf/internal/lookup"
|
||||
"sneak.berlin/go/smallwebwaf/internal/geojs"
|
||||
"sneak.berlin/go/smallwebwaf/internal/metrics"
|
||||
"sneak.berlin/go/smallwebwaf/internal/ratelimit"
|
||||
"sneak.berlin/go/smallwebwaf/internal/reputation"
|
||||
@@ -1700,7 +1700,7 @@ func TestEditOfEachFileTakenIn(t *testing.T) {
|
||||
t,
|
||||
lookupsJSON,
|
||||
params.GeoJS.Snapshot(),
|
||||
[]lookup.Answer{
|
||||
[]geojs.Answer{
|
||||
{Client: client, Country: "FR", Answered: midnight()},
|
||||
},
|
||||
)
|
||||
@@ -2415,9 +2415,7 @@ func newParams(dir string) state.Params {
|
||||
MaxBans: 5000,
|
||||
}),
|
||||
Limiter: ratelimit.New(ratelimit.Limits{}, 20000),
|
||||
GeoJS: lookup.New(lookup.Params{
|
||||
Now: midnight, ProcessLog: discard, Metrics: m,
|
||||
}),
|
||||
GeoJS: geojs.New(geojs.Params{Now: midnight}),
|
||||
Lists: reputation.New(reputation.Params{
|
||||
BlocklistURLs: []string{
|
||||
blocklistURL,
|
||||
@@ -2494,7 +2492,7 @@ func fill(params state.Params) {
|
||||
})
|
||||
params.Limiter.AddLookup(client, now.Add(-time.Hour), asn, asName, "DE")
|
||||
|
||||
params.GeoJS.Load([]lookup.Answer{
|
||||
params.GeoJS.Load([]geojs.Answer{
|
||||
{
|
||||
Client: client, ASN: asn, ASName: asName, Country: "DE",
|
||||
Answered: now.Add(-time.Hour), Used: now,
|
||||
|
||||
Reference in new issue
Block a user