Documentation
¶
Overview ¶
Package generator holds what every proxy's generator reads the same way: the input, the files a generator returns, the refusals of the values it cannot write, the header line, and the rules that read the model alike for every proxy. It is not part of model, because Input names origins.File and rpc.Route, and origins and rpc import model.
Index ¶
Constants ¶
const ( InternalHeader = "x-envoy-internal" ExpectedTimeoutHeader = "x-envoy-expected-rq-timeout-ms" )
InternalHeader and ExpectedTimeoutHeader are two headers the Envoy output's check request carries, InternalHeader as true and ExpectedTimeoutHeader as auth.timeout in milliseconds (measured on Envoy 1.40.2: true and 1500 for a timeout of 1500ms). A generator that writes the check sends both too, so a check service reads the same names from every proxy. A client's own copies are removed with the rest of RemovedByEnvoy.
const ConnectionTokens = `(?:close|keep-alive|upgrade|http2-settings|te)`
ConnectionTokens are the Connection tokens Envoy keeps a request whole with, as a regular expression's group; it removes each header another token names, or refuses the request (source/common/http/utility.cc, sanitizeConnectionHeader), and it refuses ten tokens or more (MostConnectionTokens). nginx and HAProxy cannot remove a header a request names, so each refuses any other token, which no service then receives.
const EscapedInPath = "\"<>^`{|}"
EscapedInPath are the bytes of a path Envoy escapes, in upper case hex, before it picks a route, beside every byte above 0x7F, which it escapes too (measured on Envoy 1.40.2). Each generator writes them into a character class of its own syntax.
const GRPCUnknown = 2
GRPCUnknown is gRPC's Unknown, the grpc-status Envoy 1.40.2 answers a gRPC request with for an HTTP status GRPCStatus does not list, such as the 500 of a call the check's accepted headers take past its header count (measured).
const Header = "# Generated by proxyfile. Do not edit: change the proxyfile beside it and run proxyfile render; " +
"proxyfile check fails on a hand edit.\n"
Header is line 1 of every generated file. It names no input and no version, so the bytes depend on the model alone.
const MostConnectionTokens = 9
MostConnectionTokens is the most Connection tokens Envoy 1.40.2 serves a request with: it answered ten 400 and served nine (measured with te ten times, on one line and on ten). It counts every element of the list that is not empty, one of white space alone too: it answered te and nine elements of a space or a tab 400, and served te and twenty empty elements.
const UncheckedMark = "x-envoy-auth-failure-mode-allowed"
UncheckedMark is the header a request carries to the service when the check did not answer and auth.when_unavailable is allow, so the service can tell it went unchecked. It is the name Envoy's ext_authz filter sets, as true, kept for every proxy so that a service reads one name; a client's own copy is removed before anything reads the request.
Variables ¶
var DroppedByEnvoy = []string{"keep-alive"}
DroppedByEnvoy are the headers of a check's answer the Envoy output never sets on the request it passes on, whatever auth.accept names, in full or by a prefix: a check's 200 that carried keep-alive gave the service none (measured on Envoy 1.40.2 over HTTP/1.1 and HTTP/2), so a generator that writes the check sets none of them either.
var EnvoyMethods = []string{"ACL", "BIND", "CHECKOUT", "CONNECT", "COPY", "DELETE", "GET", "HEAD", "LINK", "LOCK", "MERGE",
"MKACTIVITY", "MKCALENDAR", "MKCOL", "MOVE", "MSEARCH", "NOTIFY", "OPTIONS", "PATCH", "POST", "PROPFIND", "PROPPATCH",
"PURGE", "PUT", "QUERY", "REBIND", "REPORT", "SEARCH", "SOURCE", "SUBSCRIBE", "TRACE", "UNBIND", "UNLINK", "UNLOCK",
"UNSUBSCRIBE"}
EnvoyMethods are the methods Envoy's HTTP/1 parser takes (kValidMethods in source/common/http/http1/balsa_parser.cc of Envoy 1.40.2); it answers any other 400 (measured with FOO), and over HTTP/2 it takes any method.
var FramingHeaders = []string{"host", "content-length", "transfer-encoding", "connection", "keep-alive", "te", "trailer",
"upgrade", "expect", "proxy-connection"}
FramingHeaders are the client's request headers never copied into the check's request, whatever auth.send names: each frames a request or speaks of its connection, and the check's request is a request of its own, which the proxy frames itself (measured on Envoy 1.40.2 beside HAProxy 3.2.26 and 3.4.7).
var GRPCStatus = map[int]int{400: 13, 401: 16, 403: 7, 404: 12, 429: 14, 502: 14, 503: 14, 504: 14}
GRPCStatus is the grpc-status Envoy 1.40.2 answers a gRPC request it denies with, by the HTTP status of the denial; any status it does not list is GRPCUnknown (Grpc::Utility::httpToGrpcStatus, source/common/grpc/status.cc). The Envoy output answers such a request 200, with this status and the check's body as grpc-message, where a request that is not gRPC gets the denial's own status (measured on Envoy 1.40.2).
var HopHeaders = []string{"content-length", "transfer-encoding", "connection", "keep-alive", "upgrade", "proxy-connection"}
HopHeaders are the headers of the check's answer never passed to the client with a denial: each speaks of the check's own connection or of how its answer was framed, and the proxy frames its own answer to the client. Envoy passes te, trailer and a header the check's Connection names, so they are not listed (measured on Envoy 1.40.2 beside HAProxy 3.2.26 and 3.4.7).
var JoinedByEnvoy = []string{
"accept",
"accept-encoding",
"access-control-request-headers",
"access-control-request-method",
"access-control-request-private-network",
"authentication",
"authorization",
"cache-control",
"cdn-loop",
"content-encoding",
"content-type",
"expect",
"grpc-accept-encoding",
"grpc-timeout",
"if-match",
"if-modified-since",
"if-none-match",
"if-range",
"if-unmodified-since",
"origin",
"pragma",
"proxy-status",
"referer",
"upgrade",
"user-agent",
"via",
"x-client-trace-id",
"x-envoy-attempt-count",
"x-envoy-decorator-operation",
"x-envoy-downstream-service-cluster",
"x-envoy-downstream-service-node",
"x-envoy-external-address",
"x-envoy-is-timeout-retry",
"x-envoy-original-host",
"x-envoy-original-path",
"x-forwarded-for",
"x-forwarded-host",
"x-forwarded-port",
"x-forwarded-proto",
"x-request-id",
}
JoinedByEnvoy are the request headers whose lines Envoy 1.40.2 joins into one line before anything reads them or the service receives them: the values that are not empty, in the order sent, joined with a comma, or one empty line when every line is empty. They are the headers of its request header map (the list Envoy logs at start after "request header map") that it neither removes (RemovedByEnvoy) nor reads as the request's framing or connection, each measured by sending it twice; the lines of any other header, such as Cookie or X-Custom, reach the service as sent, through Envoy as through nginx and HAProxy.
var QuestionHeaders = []model.Header{{Name: "x-gateway-action"}, {Name: "x-gateway-reports"}}
QuestionHeaders are the headers a method's question travels in (Question), which the proxy sends to the check: a client's copies are removed first (RemovedFromClients), and the Envoy output removes its own after the check, so no service receives them.
var RemovedByEnvoy = []string{ "proxy-connection", ExpectedTimeoutHeader, "x-envoy-force-trace", "x-envoy-hedge-on-per-try-timeout", InternalHeader, "x-envoy-ip-tags", "x-envoy-max-retries", "x-envoy-original-url", "x-envoy-retriable-header-names", "x-envoy-retriable-status-codes", "x-envoy-retry-grpc-on", "x-envoy-retry-on", "x-envoy-upstream-alt-stat-name", "x-envoy-upstream-rq-per-try-timeout-ms", "x-envoy-upstream-rq-timeout-alt-response", "x-envoy-upstream-rq-timeout-ms", "x-envoy-upstream-stream-duration-ms", "x-forwarded-client-cert", }
RemovedByEnvoy are the request headers the Envoy output removes before the service, measured on Envoy 1.40.2 by sending each of the 41 x-envoy- headers its headers.h names, with and without a private X-Forwarded-For: these 16 steer an Envoy between the gateway and the service (retries, timeouts, tracing, an internal request) and reach no service whatever X-Forwarded-For says. Proxy-Connection and X-Forwarded-Client-Cert are removed too. nginx and HAProxy pass every client header on unless the file removes it, so each generator removes these. Two are written by their constants, because the check is sent them too.
var RemovedByEnvoyFacingClients = []string{
"x-envoy-decorator-operation",
"x-envoy-downstream-service-cluster",
"x-envoy-downstream-service-node",
"x-envoy-original-host",
"x-envoy-original-path",
}
RemovedByEnvoyFacingClients are the request headers the Envoy output removes too with client_address = connection, where it takes each client for one it faces, and passes on with forwarded: those only a proxy in front may send (measured on Envoy 1.40.2 with every x-envoy- header its headers.h names).
Functions ¶
func BucketID ¶
BucketID names the bucket of one entry of routes: rpc for the rpc entry, the route's name otherwise. It is never the name of a route the proxy writes, which several rendered routes can share (an rpc entry's routes and a plain route may carry the same name), while the read rules keep each route's name unique and never rpc.
func LimitOf ¶
LimitOf is the limit of one entry of routes: the rpc entry's or the route's own, nil without one.
func RemovedFromClients ¶
RemovedFromClients is the early header removal's list, before the proxy's own unchecked mark: remove_from_clients in the order written, then, with auth.ask, the question headers and each accept name, then, with auth.jwt, each claims header, each that no entry before it covers. Only the gateway, the check and the token set those headers, so a client's copy is removed whether or not remove_from_clients lists it. A covered header adds nothing, so a file whose remove_from_clients covers them all gets no entry from here.
Types ¶
type Bucket ¶
Bucket is one token bucket of a route's rate limit: MaxTokens is requests + burst, and TokensPerFill requests, which the proxy adds over each FillInterval, the period.
type File ¶
File is one file a generator returns. Name "" is the configuration, written at -o; any other Name is a file the configuration loads, written under that fixed name in the folder of -o. That Name is a name alone, with no folder: render refuses any other as a bug, so no file is written outside the folder of -o.
type Input ¶
type Input struct {
Gateway *model.Gateway
Origins *origins.File
RPC []rpc.Route // sorted by path; nil without an rpc entry
}
Input is everything the generated file is made from.
type Question ¶
Question is the RPC question of one method, which the proxy sends the check with a call of it: Action in x-gateway-action and Reports, joined by commas, in x-gateway-reports.
func Questions ¶
Questions is the question of each RPC method that has an action or reports, in the order of in.RPC, and nil when the check is not asked: without auth.ask, or with auth.enabled false, no check is sent, so no question is either. A method with neither gets no entry, as the Envoy output writes no question for it.
type Refusals ¶
type Refusals struct {
// contains filtered or unexported fields
}
Refusals keeps the refusals of the values a generator cannot write, each once by its key and position: a value the file writes at several places, such as a prefix in its route map and in its rewrite, or a host in one expression for each environment, is one refusal. Each generator decides what it refuses and in which words; the zero value is ready to use.
func (*Refusals) Err ¶
Err returns a Refused that holds every refusal kept, in the file's order, or nil when there is none.
type Refused ¶
Refused is the error of a generator that refuses a value of the input as it writes it, by the key that holds the value, as a target's declaration refuses a key: a value whose written form only the generator knows, such as one longer than the proxy reads once written. render reports its problems as the refusals they are, not as a bug in proxyfile.