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
@@ -1,3 +1,6 @@
|
||||
// Package lookup looks up each client's AS number and country in the lookup
|
||||
// database, the IPinfo Lite file SWW_WAF_LOOKUP_DB_PATH names. Its answers
|
||||
// take the form of GeoJS's, so that waf handles both alike.
|
||||
package lookup
|
||||
|
||||
import (
|
||||
@@ -14,6 +17,7 @@ import (
|
||||
"github.com/oschwald/maxminddb-golang/v2"
|
||||
|
||||
"sneak.berlin/go/smallwebwaf/internal/alerts"
|
||||
"sneak.berlin/go/smallwebwaf/internal/geojs"
|
||||
)
|
||||
|
||||
// quietTime is how long the lookup database must go without a change
|
||||
@@ -77,7 +81,7 @@ func OpenFile(params FileParams) (*File, error) {
|
||||
// each "" when the database does not give it, as for an address missing
|
||||
// from it. The database is asked about the client's first address, as
|
||||
// GeoJS is.
|
||||
func (f *File) LookUp(client netip.Prefix) Answer {
|
||||
func (f *File) LookUp(client netip.Prefix) geojs.Answer {
|
||||
f.mu.Lock()
|
||||
reader := f.reader
|
||||
f.mu.Unlock()
|
||||
@@ -91,7 +95,7 @@ func (f *File) LookUp(client netip.Prefix) Answer {
|
||||
found = record{}
|
||||
}
|
||||
|
||||
return Answer{
|
||||
return geojs.Answer{
|
||||
Client: client,
|
||||
ASN: found.ASN,
|
||||
ASName: found.ASName,
|
||||
|
||||
Reference in new issue
Block a user