haproxyprobe

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package haproxyprobe is the probe the operator sends through HAProxy to tell whether a route runs the engine's SPOE filter (0002 §6.4): a GET with Header carrying a random nonce and a MAC of the nonce, the host and the path under the bundle's probe key. The path is one the route serves: PathSuffix under a Prefix path, so the probe reaches no real page of the app when the filter isn't there. The SPOE adapter checks the MAC and answers with another MAC under the key, which the route's HAProxy rules return with Status: only an engine that has the key, behind a route that runs the filter, can answer.

Where the proxy discards the engine's answer (Envoy's ext_proc in observability mode, a Detect-mode route through Istio), the engine keeps a Receipt of each probe it verified instead, and reports its recent ones to the operator (#475): another MAC under the key, which the operator expects for the probe's nonce, host and URI, and which neither the request nor an answer shows.

The response leg (#595) proves that a route's responses reach the engine too: the same probe, its URI marked with LegParam (under the MAC), which the engine lets through to the app instead of answering, and answers (or keeps a receipt of) in its response phase, with MACs of their own purpose.

Index

Constants

View Source
const (
	// PathSuffix is the probe's path under a Prefix path, before the
	// nonce: /.well-known/inkwall-probe/<nonce> for the prefix "/".
	PathSuffix = ".well-known/inkwall-probe/"
	// Header carries the request's nonce and MAC ("<nonce>.<mac>"), and the
	// answer's MAC.
	Header = "X-Inkwall-Probe"
	// Status is HAProxy's answer to a probe the engine answered.
	Status = 299
	// KeySize is the size of a probe key.
	KeySize = 32

	// ReceiptSize is the length of a receipt: 32 hex digits, an
	// HMAC-SHA256 cut to 128 bits.
	ReceiptSize = 32
	// MaxReceipts bounds the receipts an engine keeps, and reports: the
	// newest.
	MaxReceipts = 16
	// ReceiptAge is how long an engine keeps a receipt.
	ReceiptAge = time.Minute

	// LegParam is the query parameter that marks a probe's response leg
	// (LegParam=ResponseLeg, last in the query): the engine lets it
	// through, and answers its response.
	LegParam = "inkwall-probe-leg"
	// ResponseLegValue is LegParam's value on the response leg.
	ResponseLegValue = "response"
)

Variables

This section is empty.

Functions

func Check

func Check(key []byte, uri, host, header string) (answer string, ok bool)

Check is the engine's side: for a request to uri (path and query) with the Host host and the given Header value, it returns the answer to send back, and whether the request is a probe made with key.

func ExpectedReceipt added in v0.6.0

func ExpectedReceipt(key []byte, nonce, host, uri string) string

ExpectedReceipt is the operator's side: the receipt of the probe with nonce to host and uri; "" without a key.

func ExpectedResponseReceipt added in v0.6.0

func ExpectedResponseReceipt(key []byte, nonce, host, uri string) string

ExpectedResponseReceipt is the operator's side: the receipt of the response leg with nonce to host and uri; "" without a key.

func IsResponseURI added in v0.6.0

func IsResponseURI(uri string) bool

IsResponseURI reports whether uri is a response leg's (ResponseURI).

func NewNonce

func NewNonce() (string, error)

NewNonce returns a random nonce: 32 base64url characters.

func PrefixPath

func PrefixPath(prefix, nonce string) string

PrefixPath is the probe's path under the Prefix path prefix.

func Receipt added in v0.6.0

func Receipt(key []byte, uri, host, header string) (receipt string, ok bool)

Receipt is the engine's side where its answer is discarded: for a request as Check takes it, the receipt to keep, and whether the request is a probe made with key.

func Request

func Request(key []byte, nonce, host, uri string) string

Request returns the Header of a probe with nonce to host and uri (path and query).

func ResponseLeg added in v0.6.0

func ResponseLeg(key []byte, uri, host, header string) (answer, receipt string, ok bool)

ResponseLeg is the engine's side of the response leg: for a request as Check takes it, whether it is a response-leg probe made with key, and the answer to give in the response phase (where the proxy waits for it) or the receipt to keep there (where the proxy discards answers).

func ResponseURI added in v0.6.0

func ResponseURI(uri string) string

ResponseURI is the response leg's URI for the request leg's uri.

func ValidReceipt added in v0.6.0

func ValidReceipt(r string) bool

ValidReceipt reports whether r has a receipt's form: ReceiptSize lowercase hex digits.

func Verify

func Verify(key []byte, nonce, host, uri, answer string) bool

Verify is the operator's side: whether answer is the engine's answer to the probe with nonce to host and uri.

func VerifyResponse added in v0.6.0

func VerifyResponse(key []byte, nonce, host, uri, answer string) bool

VerifyResponse is the operator's side: whether answer is the engine's answer to the response leg with nonce to host and uri, given in its response phase.

Types

type Receipts added in v0.6.0

type Receipts struct {
	// Now is the clock; nil: time.Now.
	Now func() time.Time
	// contains filtered or unexported fields
}

Receipts are the receipts an engine keeps: at most MaxReceipts, the newest, none older than ReceiptAge, each once. The zero value is ready; a nil one keeps none.

func (*Receipts) Add added in v0.6.0

func (r *Receipts) Add(receipt string)

Add keeps a receipt; a malformed one is ignored.

func (*Receipts) Recent added in v0.6.0

func (r *Receipts) Recent() []string

Recent returns the receipts kept, oldest first.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL