Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6acde5c3bc |
No files matched your search
@@ -524,7 +524,7 @@ func TestServeWAFAnswersWithinTheTimeLimitWhileEveryOutsideSourceHangs(t *testin
|
||||
server, out, _ := newServeWAFWith(t, func(params servewaf.Params) *servewaf.Server {
|
||||
params.AbuseIPDBURL = silentAbuseIPDBURL
|
||||
|
||||
return servewaf.New(params)
|
||||
return servewaf.NewServeWAF(params)
|
||||
}, held, time.Now, map[string]string{
|
||||
deniedCountries: "KP", wafMode: block,
|
||||
dnsblZones: dnsblZone, dnsblResolver: resolver.LocalAddr().String(),
|
||||
|
||||
@@ -379,7 +379,7 @@ func TestRequestWaitsAsLongAsTheLookupTimeoutSays(t *testing.T) {
|
||||
// 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
|
||||
// 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) {
|
||||
// Not the default. The exclusive list needs the answer, and the app
|
||||
// is never reached.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Package servewaf is the server the servewaf command runs. It answers rproxy's
|
||||
// questions, takes rproxy's reports and answers its own endpoints, and writes a
|
||||
// log line for each.
|
||||
// Package servewaf is the server the servewaf command runs. It answers each of
|
||||
// rproxy's questions with what to do with the request, and takes rproxy's
|
||||
// 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
|
||||
|
||||
import (
|
||||
@@ -43,7 +45,7 @@ const BansPath = "/_smallwebwaf/bans"
|
||||
// client's address after it, with SWWAF_ADMIN_TOKEN.
|
||||
const ClientsPath = "/_smallwebwaf/clients/"
|
||||
|
||||
// Params are what New needs.
|
||||
// Params are what NewServeWAF needs.
|
||||
type Params struct {
|
||||
Config *config.Config
|
||||
// RequestLog receives two JSON lines per question, one at its decision and
|
||||
|
||||
@@ -404,7 +404,7 @@ func newServeWAF(
|
||||
) (*servewaf.Server, *output, *alerts.Queue) {
|
||||
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.
|
||||
|
||||
@@ -617,7 +617,7 @@ const (
|
||||
// AbuseIPDB.
|
||||
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,
|
||||
// through which AbuseIPDB is asked.
|
||||
const abuseIPDBURL = "abuseipdb://stand-in/api/v2/check"
|
||||
|
||||
@@ -103,13 +103,13 @@ type Report struct {
|
||||
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
|
||||
// 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
|
||||
// is far above rproxy's, and a question refused for its size would have rproxy
|
||||
// let the request through.
|
||||
func New(params Params) *Server {
|
||||
func NewServeWAF(params Params) *Server {
|
||||
h := newHandler(params)
|
||||
|
||||
return &Server{
|
||||
|
||||
@@ -207,7 +207,7 @@ func newServer(
|
||||
}
|
||||
}
|
||||
|
||||
server := servewaf.New(servewaf.Params{
|
||||
server := servewaf.NewServeWAF(servewaf.Params{
|
||||
Config: cfg,
|
||||
RequestLog: stdout,
|
||||
ProcessLog: processLog,
|
||||
|
||||
Reference in new issue
Block a user