1 Commits
Author SHA1 Message Date
sneak 6acde5c3bc Rename internal/proxy to internal/servewaf (closes #173)
check / check (push) Successful in 3m57s
The package passes nothing to an app since rproxy took that over, so it
is named after the command it serves. The rproxy tests call their
stand-in for servewaf standIn, since a local servewaf would hide the
package. No change of behaviour.

Model: opus-5-5
2026-11-06 18:00:32 +00:00
7 changed files with 13 additions and 11 deletions

No files matched your search

+1 -1
View File
@@ -524,7 +524,7 @@ func TestServeWAFAnswersWithinTheTimeLimitWhileEveryOutsideSourceHangs(t *testin
server, out, _ := newServeWAFWith(t, func(params servewaf.Params) *servewaf.Server { server, out, _ := newServeWAFWith(t, func(params servewaf.Params) *servewaf.Server {
params.AbuseIPDBURL = silentAbuseIPDBURL params.AbuseIPDBURL = silentAbuseIPDBURL
return servewaf.New(params) return servewaf.NewServeWAF(params)
}, held, time.Now, map[string]string{ }, held, time.Now, map[string]string{
deniedCountries: "KP", wafMode: block, deniedCountries: "KP", wafMode: block,
dnsblZones: dnsblZone, dnsblResolver: resolver.LocalAddr().String(), dnsblZones: dnsblZone, dnsblResolver: resolver.LocalAddr().String(),
+1 -1
View File
@@ -379,7 +379,7 @@ func TestRequestWaitsAsLongAsTheLookupTimeoutSays(t *testing.T) {
// clock of the test's own: the wait lasts exactly as long as it should, // clock of the test's own: the wait lasts exactly as long as it should,
// however slowly the test process runs. Nothing in it may wait on the // however slowly the test process runs. Nothing in it may wait on the
// network, which would keep that clock from moving on: the request is // network, which would keep that clock from moving on: the request is
// handed to servewaf's handler, and GeoJS is one that never answers. // handed to the proxy's handler, and GeoJS is one that never answers.
synctest.Test(t, func(t *testing.T) { synctest.Test(t, func(t *testing.T) {
// Not the default. The exclusive list needs the answer, and the app // Not the default. The exclusive list needs the answer, and the app
// is never reached. // is never reached.
+6 -4
View File
@@ -1,6 +1,8 @@
// Package servewaf is the server the servewaf command runs. It answers rproxy's // Package servewaf is the server the servewaf command runs. It answers each of
// questions, takes rproxy's reports and answers its own endpoints, and writes a // rproxy's questions with what to do with the request, and takes rproxy's
// log line for each. // report once the visitor's answer has ended, writing the request's log line.
// It also answers servewaf's own endpoints: the health check, the metrics, the
// bans and the clients.
package servewaf package servewaf
import ( import (
@@ -43,7 +45,7 @@ const BansPath = "/_smallwebwaf/bans"
// client's address after it, with SWWAF_ADMIN_TOKEN. // client's address after it, with SWWAF_ADMIN_TOKEN.
const ClientsPath = "/_smallwebwaf/clients/" const ClientsPath = "/_smallwebwaf/clients/"
// Params are what New needs. // Params are what NewServeWAF needs.
type Params struct { type Params struct {
Config *config.Config Config *config.Config
// RequestLog receives two JSON lines per question, one at its decision and // RequestLog receives two JSON lines per question, one at its decision and
+1 -1
View File
@@ -404,7 +404,7 @@ func newServeWAF(
) (*servewaf.Server, *output, *alerts.Queue) { ) (*servewaf.Server, *output, *alerts.Queue) {
t.Helper() t.Helper()
return newServeWAFWith(t, servewaf.New, geojsURL, now, env) return newServeWAFWith(t, servewaf.NewServeWAF, geojsURL, now, env)
} }
// newServeWAFWith is newServeWAF for the server build makes. // newServeWAFWith is newServeWAF for the server build makes.
+1 -1
View File
@@ -617,7 +617,7 @@ const (
// AbuseIPDB. // AbuseIPDB.
const abuseipdb = reputation.AbuseIPDBSource const abuseipdb = reputation.AbuseIPDBSource
// abuseIPDBURL is where newServeWAF has clients checked with AbuseIPDB: at // abuseIPDBURL is where newProxy has clients checked with AbuseIPDB: at
// abuseIPDBStandIn, which TestMain registers with Go's default transport, // abuseIPDBStandIn, which TestMain registers with Go's default transport,
// through which AbuseIPDB is asked. // through which AbuseIPDB is asked.
const abuseIPDBURL = "abuseipdb://stand-in/api/v2/check" const abuseIPDBURL = "abuseipdb://stand-in/api/v2/check"
+2 -2
View File
@@ -103,13 +103,13 @@ type Report struct {
DurationUpstreamTotal float64 `json:"duration_upstream_total"` DurationUpstreamTotal float64 `json:"duration_upstream_total"`
} }
// New returns the server `smallwebwaf servewaf` runs. It answers // NewServeWAF returns the server `smallwebwaf servewaf` runs. It answers
// rproxy's questions, takes rproxy's reports and answers its own endpoints. It // rproxy's questions, takes rproxy's reports and answers its own endpoints. It
// passes nothing to an app. rproxy applies the size and time limits to the // passes nothing to an app. rproxy applies the size and time limits to the
// visitor. Go's default limit on a request's line and headers, 1 MiB, stays: it // visitor. Go's default limit on a request's line and headers, 1 MiB, stays: it
// is far above rproxy's, and a question refused for its size would have rproxy // is far above rproxy's, and a question refused for its size would have rproxy
// let the request through. // let the request through.
func New(params Params) *Server { func NewServeWAF(params Params) *Server {
h := newHandler(params) h := newHandler(params)
return &Server{ return &Server{
+1 -1
View File
@@ -207,7 +207,7 @@ func newServer(
} }
} }
server := servewaf.New(servewaf.Params{ server := servewaf.NewServeWAF(servewaf.Params{
Config: cfg, Config: cfg,
RequestLog: stdout, RequestLog: stdout,
ProcessLog: processLog, ProcessLog: processLog,