Documentation
¶
Overview ¶
Package request defines the canonical HTTP request that every Inkwall adapter produces and the inspection pipeline consumes. Adapters translate proxy-native messages (ext_proc, SPOE, forward-auth, net/http, ...) into a Request, so detection code never depends on which proxy asked.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Geo ¶
type Geo struct {
// Looked is set once the policy set looked the country up: the bundle
// names a country table. Unset, geo is skipped.
Looked bool
// Country and Result are what the lookup found; ResultNoTable when the
// bundle names a table the engine doesn't hold.
Country geo.Country
Result geo.Result
}
Geo is a request's country lookup.
type Request ¶
type Request struct {
// ID correlates the request across proxy, engine and events. Empty means
// the engine generates one.
ID string
// Proto is the protocol version, e.g. "HTTP/1.1" or "HTTP/2.0".
Proto string
// Method is the HTTP method.
Method string
// Scheme is "http" or "https" as seen by the proxy.
Scheme string
// Host is the request authority (Host header or :authority).
Host string
// RawURI is the path and query exactly as received, before any
// normalization. Rules apply their own transformations.
RawURI string
// Headers holds request headers. The Host header is carried in Host.
Headers http.Header
// ClientIP is the end client's address, resolved through trusted proxies.
ClientIP netip.Addr
// Geo is ClientIP's country, looked up once per request by the policy
// set when a policy that matched the request has geo blocking
// (design 0011 §5.1).
Geo Geo
// PeerIP is the address of the direct TCP peer.
PeerIP netip.Addr
// Body holds the inspected prefix of the request body, at most the
// configured inspection limit. It is nil when the body is not inspected.
Body []byte
// BodyTruncated reports that the body was longer than Body.
BodyTruncated bool
// RateLimits holds the rate limit outcomes the pipeline charged in
// BodyLimit, before the body was read, for its Check (pkg/pipeline):
// a request is charged once.
RateLimits any
// GRPC reports that the pipeline found the request to be a gRPC call:
// a POST with a gRPC content type whose body is gRPC messages. Its
// body is binary protobuf, which text rules can't read: the pipeline
// passes it to the rules without its body, and the rules allow its
// content type.
GRPC bool
// GRPCText is the text the pipeline found in a gRPC call's messages,
// which the rules see as form arguments (ARGS_POST), named by the
// path of field numbers ("2.1").
GRPCText []Arg
// WebSocketText is the text of a WebSocket message the engine's proxy
// inspects, which the rules see as form arguments (ARGS_POST): a JSON
// message's values by path ("json.user.name"), any other text as
// "message".
WebSocketText []Arg
}
Request is an adapter-independent view of one HTTP request.
type Response ¶ added in v0.4.0
type Response struct {
// Status is the response's HTTP status code.
Status int
// Proto is the protocol version, as in Request.
Proto string
// Headers holds the response headers, without pseudo-headers.
Headers http.Header
// Body holds the inspected prefix of the response body, decoded when
// it came gzip- or deflate-encoded: at most the configured limit. It
// is nil when the body is not inspected.
Body []byte
// BodyTruncated reports that the body was longer than Body: only its
// prefix was inspected.
BodyTruncated bool
// BodyUninspected reports that the body should have been inspected
// but couldn't be: an encoding the engine can't decode, or a body the
// proxy didn't send. Body is then nil.
BodyUninspected bool
}
Response is an adapter-independent view of the upstream's response to a Request, for the policies that inspect responses.