dataplane

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0 modules, 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 dataplane is the agent's client for the OpenResty control API (lua/edgeweir/control.lua), served by nginx on a local unix socket.

The agent converts the validated plan into a JSON site table and replaces it atomically with PUT /v1/sites; the Lua side never sees protobuf.

Index

Constants

This section is empty.

Variables

View Source
var BlockReasons = []string{"ip_banned", "ip_blocked", "rule", "rate_limit", "crs", "cc", "challenge", "auth", "referer",
	"user_agent", "region", "cors", "websocket_origin", "client_cert", "maintenance", "ai_crawler", "pay_per_crawl", "extension", "api_security"}

BlockReasons are the block reasons of AccessLog.block_reason and MinuteStats.block_reasons (ADR-0041 §3, the console's BLOCK_REASONS).

View Source
var HeaderTimeBoundsMS = []uint64{10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000}

HeaderTimeBoundsMS are the upper bounds of OriginCount.HeaderTimeBuckets but the last (edgeweir.topstats.HEADER_TIME_BOUNDS).

Functions

func CDNID

func CDNID(nodeID string) string

CDNID returns the CDN-Loop identifier of a node (RFC 8586 pseudonym): "edgeweir-" and the first 16 hex characters of sha256(node id). It does not reveal the node id but is stable across restarts and renewals.

func Text added in v1.0.0

func Text(s string, n int) string

Text strips control characters (and invalid UTF-8) from s and cuts it to at most n bytes without splitting a character.

Types

type APIError

type APIError struct {
	Status  int
	Message string
}

APIError is a non-2xx answer of the control API.

func (*APIError) Error

func (e *APIError) Error() string

type ASNCount added in v1.0.0

type ASNCount struct {
	Requests uint64 `json:"requests"`
	Name     string `json:"name"`
}

ASNCount is a network's requests in a minute (approximate) and its name.

type ActiveHealth

type ActiveHealth struct {
	TTL  uint32         `json:"ttl"`
	Down []ActiveOrigin `json:"down"`
}

ActiveHealth is the body of PUT /v1/origins/active: the full set of origins the agent's active health checks mark down. The marks expire after TTL seconds, so they never outlive an agent that stopped pushing.

type ActiveHealthStatus

type ActiveHealthStatus struct {
	Down int `json:"down"`
}

ActiveHealthStatus is the answer of PUT /v1/origins/active: the number of marks installed.

type ActiveOrigin

type ActiveOrigin struct {
	SiteID   string `json:"site_id"`
	OriginID string `json:"origin_id"`
}

ActiveOrigin is an origin of a site, marked down by the active check.

type AutoBan

type AutoBan struct {
	SiteID        string  `json:"site_id"`
	IP            string  `json:"ip"`
	PrefixLen     int     `json:"prefix_len"`
	CreatedAt     float64 `json:"created_at"`
	ExpiresAt     float64 `json:"expires_at"`
	Reason        string  `json:"reason"`
	Metric        string  `json:"metric"`
	Observed      float64 `json:"observed"`
	Threshold     float64 `json:"threshold"`
	WindowSeconds uint32  `json:"window_seconds"`
	RuleID        string  `json:"rule_id"`
}

AutoBan is a ban the node created itself, from POST /v1/bans/auto/drain: an IPv4 address (PrefixLen 32) or an IPv6 /64 (IP is the network), or, for a ban a rule made (RuleID set; reasons waf_rule and rate_limit), any network of 16-32 bits (IPv4) or 48-64 bits (IPv6).

type Ban

type Ban struct {
	ID   string `json:"id"`
	CIDR string `json:"cidr"`
	// Scope is "platform" or "site".
	Scope  string `json:"scope"`
	SiteID string `json:"site_id,omitempty"`
	// Kind is "m" (manual), "c" (automatic) or "g" (a greylist entry); not
	// needed for removals.
	Kind string `json:"kind,omitempty"`
	// ExpiresAt is the expiry in Unix seconds (millisecond precision).
	ExpiresAt float64 `json:"expires_at,omitempty"`
	// Grey marks a greylist entry, also in removals (it lives apart from
	// the bans of the same prefix).
	Grey bool `json:"grey,omitempty"`
	// Greylist entries: action "challenge" with challenge (cookie302, js,
	// pow, captcha) or "rate_limit" with requests per window seconds.
	Action    string `json:"action,omitempty"`
	Challenge string `json:"challenge,omitempty"`
	Requests  uint32 `json:"requests,omitempty"`
	Window    uint32 `json:"window,omitempty"`
}

Ban is one console ban as the data plane holds it (lua/edgeweir/bans.lua).

type BanDelta

type BanDelta struct {
	Base     uint64 `json:"base,string"`
	Sequence uint64 `json:"sequence,string"`
	Upsert   []Ban  `json:"upsert"`
	Remove   []Ban  `json:"remove"`
}

BanDelta is the body of POST /v1/bans. The data plane applies it only while it holds sequence Base (409 otherwise).

type BanEntry

type BanEntry struct {
	ID string `json:"id"`
	// Kind is "m" (console, manual), "c" (console, automatic) or "a" (the
	// node's own).
	Kind      string  `json:"kind"`
	CIDR      string  `json:"cidr"`
	Scope     string  `json:"scope"`
	SiteID    string  `json:"site_id,omitempty"`
	ExpiresAt float64 `json:"expires_at"`
}

BanEntry is one ban as GET /v1/bans?list=1 lists it (at most 1000).

type BanStatus

type BanStatus struct {
	Sequence uint64 `json:"sequence,string"`
	// Entries counts every ban held, the node's own included.
	Entries  int `json:"entries"`
	Capacity int `json:"capacity"`
	// Unapplied counts the manual bans that do not fit; UnappliedIDs lists
	// at most 100 of them.
	Unapplied    int      `json:"unapplied"`
	UnappliedIDs []string `json:"unapplied_ids"`
	// AutoEvicted counts automatic bans dropped to make room since nginx
	// started.
	AutoEvicted    uint64 `json:"auto_evicted"`
	PendingReports int    `json:"pending_reports"`
}

BanStatus is the response of GET, PUT and POST /v1/bans. After an nginx restart the sequence is 0 and the set is empty.

func (*BanStatus) UnmarshalJSON

func (s *BanStatus) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts {} for an empty unapplied_ids list.

type BanTable

type BanTable struct {
	Sequence uint64 `json:"sequence,string"`
	Bans     []Ban  `json:"bans"`
}

BanTable is the body of PUT /v1/bans: the whole console set, in the order the data plane should keep it when room runs out.

type Captcha

type Captcha struct {
	Answer string `json:"answer"`
	PNG    string `json:"png"`
}

Captcha is one image of the captcha pool; PNG is base64.

type CaptchaPool

type CaptchaPool struct {
	ID     string    `json:"id"`
	Images []Captcha `json:"images"`
}

CaptchaPool is the body of PUT /v1/challenge/captchas.

type ChallengeKey

type ChallengeKey struct {
	ID     string `json:"id"`
	Secret string `json:"secret"`
}

ChallengeKey is a challenge pass key; Secret is base64.

type ChallengeKeys

type ChallengeKeys struct {
	ID      string         `json:"id"`
	Current string         `json:"current"`
	Keys    []ChallengeKey `json:"keys"`
}

ChallengeKeys is the body of PUT /v1/challenge/keys: the keys that verify passes (next, current, previous) and the one that signs. ID identifies the set (GET /v1/challenge reports it back).

type ChallengeStatus

type ChallengeStatus struct {
	KeysID     string       `json:"keys_id"`
	Current    string       `json:"current"`
	Keys       List[string] `json:"keys"`
	Captchas   int          `json:"captchas"`
	CaptchasID string       `json:"captchas_id"`
	// NonceOverflow counts tokens accepted while the nonce store was full.
	NonceOverflow uint64 `json:"nonce_overflow"`
}

ChallengeStatus is the response of GET /v1/challenge and of the PUTs. After an nginx restart everything is empty.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to the control socket.

func NewClient

func NewClient(socket string) *Client

NewClient returns a client for the control API at socket.

func (*Client) AddBans

func (c *Client) AddBans(ctx context.Context, d *BanDelta) (*BanStatus, error)

AddBans applies a delta; a data plane that does not hold d.Base answers 409 (an *APIError).

func (*Client) AddPurge

func (c *Client) AddPurge(ctx context.Context, t *PurgeTable) (*PurgeStatus, error)

AddPurge merges markers into the data plane's set.

func (*Client) BanStatus

func (c *Client) BanStatus(ctx context.Context) (*BanStatus, error)

BanStatus returns the data plane's ban set status.

func (*Client) ChallengeStatus

func (c *Client) ChallengeStatus(ctx context.Context) (*ChallengeStatus, error)

ChallengeStatus returns the data plane's keys and captcha pool status.

func (*Client) DrainAutoBans

func (c *Client) DrainAutoBans(ctx context.Context) ([]AutoBan, error)

DrainAutoBans returns and deletes up to 1000 queued own bans.

func (*Client) DrainL4Stats

func (c *Client) DrainL4Stats(ctx context.Context, all bool) ([]L4MinuteStats, error)

DrainL4Stats returns and deletes the completed per-minute counters of the layer-4 applications; with all, the current minute's too.

func (*Client) DrainLogs

func (c *Client) DrainLogs(ctx context.Context) ([]*nodev1.AccessLog, error)

func (*Client) DrainSecurity

func (c *Client) DrainSecurity(ctx context.Context) ([]SecurityEvent, error)

DrainSecurity returns and deletes up to 1000 queued CC events.

func (*Client) DrainStats

func (c *Client) DrainStats(ctx context.Context, all bool) ([]MinuteStats, error)

DrainStats returns and deletes the completed per-minute counters; with all, the current minute's too (nginx is about to stop and would lose them).

func (*Client) Extensions added in v1.7.0

func (c *Client) Extensions(ctx context.Context) (map[string]ExtensionRuntime, error)

Extensions returns the extensions' runtime state by id.

func (*Client) Health

func (c *Client) Health(ctx context.Context) error

Health checks that the control API answers.

func (*Client) L4Status

func (c *Client) L4Status(ctx context.Context) (*L4Status, error)

L4Status returns the stream subsystem's table status.

func (*Client) ListBans

func (c *Client) ListBans(ctx context.Context) (*BanStatus, []BanEntry, error)

ListBans returns the status and up to 1000 bans held.

func (*Client) OriginHealth

func (c *Client) OriginHealth(ctx context.Context) ([]OriginHealth, error)

OriginHealth returns the origins with recorded failures.

func (*Client) PutActiveHealth

func (c *Client) PutActiveHealth(ctx context.Context, doc *ActiveHealth) (*ActiveHealthStatus, error)

PutActiveHealth replaces the set of origins the active health checks mark down.

func (*Client) PutBans

func (c *Client) PutBans(ctx context.Context, t *BanTable) (*BanStatus, error)

PutBans replaces the console bans (the node's own bans stay).

func (*Client) PutCaptchas

func (c *Client) PutCaptchas(ctx context.Context, p *CaptchaPool) (*ChallengeStatus, error)

PutCaptchas replaces the captcha pool.

func (*Client) PutChallengeKeys

func (c *Client) PutChallengeKeys(ctx context.Context, k *ChallengeKeys) (*ChallengeStatus, error)

PutChallengeKeys replaces the challenge keys.

func (*Client) PutExtensionNodeStatus added in v1.7.0

func (c *Client) PutExtensionNodeStatus(ctx context.Context, s *ExtensionNodeStatus) error

PutExtensionNodeStatus stores the host metrics ew.node.status() returns.

func (*Client) PutExtensionRuntime added in v1.7.0

func (c *Client) PutExtensionRuntime(ctx context.Context, doc json.RawMessage) error

PutExtensionRuntime stores the extensions' secrets and their sidecars' readiness (extension version 1.1).

func (*Client) PutL4

func (c *Client) PutL4(ctx context.Context, t *L4Table) (*L4Status, error)

PutL4 replaces the layer-4 table.

func (*Client) PutPurge

func (c *Client) PutPurge(ctx context.Context, t *PurgeTable) (*PurgeStatus, error)

PutPurge replaces the purge marker set.

func (*Client) PutSites

func (c *Client) PutSites(ctx context.Context, t *SiteTable) (*Status, error)

PutSites replaces the site table atomically.

func (*Client) ReleaseOwnBans

func (c *Client) ReleaseOwnBans(ctx context.Context, list []OwnBanRelease) (int, error)

ReleaseOwnBans deletes the node's own bans the console lifted and returns how many the data plane held.

func (*Client) SecurityStatus

func (c *Client) SecurityStatus(ctx context.Context) (*SecurityStatus, error)

SecurityStatus returns the CC levels of the sites with CC.

func (*Client) Socket

func (c *Client) Socket() string

Socket returns the control socket path.

func (*Client) Status

func (c *Client) Status(ctx context.Context) (*Status, error)

Status returns the data plane's site table status.

func (*Client) Tap added in v1.0.0

func (c *Client) Tap(ctx context.Context, after uint64, site string) (*TapPage, error)

Tap reads the live view after seq (0: the first call, which only returns the current number), only the requests of site when it is not empty. Each call keeps the data plane recording for five more seconds.

type CountryCount added in v1.0.0

type CountryCount struct {
	Requests  uint64 `json:"requests"`
	BytesSent uint64 `json:"bytes_sent"`
}

CountryCount is a country's requests and bytes sent in a minute.

type CrawlerCount added in v1.7.0

type CrawlerCount struct {
	Crawler       string `json:"crawler"`
	Verification  string `json:"verification"`
	Requests      uint64 `json:"requests"`
	Status2xx     uint64 `json:"status_2xx"`
	Status3xx     uint64 `json:"status_3xx"`
	Status4xx     uint64 `json:"status_4xx"`
	Status5xx     uint64 `json:"status_5xx"`
	Blocked       uint64 `json:"blocked"`
	Bytes         uint64 `json:"bytes"`
	Charged       uint64 `json:"charged"`
	ChargedMicros uint64 `json:"charged_micros"`
	Robots        uint64 `json:"robots"`
	Allowed       uint64 `json:"allowed"`
}

CrawlerCount is a minute of one crawler's requests with one verification result (nodev1.CrawlerCounter).

type CrawlerPathCount added in v1.7.0

type CrawlerPathCount struct {
	Crawler  string `json:"crawler"`
	Path     string `json:"path"`
	Requests uint64 `json:"requests"`
	Bytes    uint64 `json:"bytes"`
}

CrawlerPathCount is a minute of one crawler's requests for one path.

type ExtensionNode added in v1.7.0

type ExtensionNode struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	ClusterID string `json:"cluster_id"`
	Version   string `json:"version"`
}

ExtensionNode is the node identity extensions read (ew.node.id, name, cluster_id, version).

type ExtensionNodeStatus added in v1.7.0

type ExtensionNodeStatus struct {
	At                int64   `json:"at"`
	CPUPercent        float64 `json:"cpu_percent"`
	Load1             float64 `json:"load1"`
	Load5             float64 `json:"load5"`
	Load15            float64 `json:"load15"`
	MemoryUsedBytes   uint64  `json:"memory_used_bytes"`
	MemoryTotalBytes  uint64  `json:"memory_total_bytes"`
	EgressBps         uint64  `json:"egress_bps"`
	ActiveConnections uint64  `json:"active_connections"`
}

ExtensionNodeStatus is the node's last reported host metrics for ew.node.status() (Lua API 2).

type ExtensionRuntime added in v1.7.0

type ExtensionRuntime struct {
	SHA256 string `json:"sha256"`
	Error  string `json:"error"`
	Faults uint64 `json:"faults"`
	Trips  uint64 `json:"trips"`
}

ExtensionRuntime is one extension's state in the workers (GET /v1/extensions): the loaded package, a load error and the fault and trip counters summed over the workers.

type ExtensionTable added in v1.7.0

type ExtensionTable struct {
	Disabled bool                 `json:"disabled"`
	List     []configir.Extension `json:"list"`
	// ConfID prevents new node workers from initializing with the old hot table.
	ConfID      string            `json:"conf_id,omitempty"`
	NodeSecrets map[string]uint32 `json:"node_secrets,omitempty"`
	// Node is this node's identity for ew.node (Lua API 2).
	Node *ExtensionNode `json:"node,omitempty"`
}

ExtensionTable is the site table's part for node extensions.

type L4Down

type L4Down struct {
	AppID     string  `json:"app_id"`
	OriginID  string  `json:"origin_id"`
	DownUntil float64 `json:"down_until"`
}

L4Down is an origin of an application that takes no connections until DownUntil (Unix seconds).

type L4IPList

type L4IPList struct {
	ID      string   `json:"id"`
	Entries []string `json:"entries"`
}

L4IPList is an IP list an application refers to.

type L4MinuteStats

type L4MinuteStats struct {
	Minute         int64  `json:"minute"`
	AppID          string `json:"app_id"`
	Connections    uint64 `json:"connections"`
	Refused        uint64 `json:"refused"`
	PeakConcurrent uint64 `json:"peak_concurrent"`
	BytesReceived  uint64 `json:"bytes_received"`
	BytesSent      uint64 `json:"bytes_sent"`
}

L4MinuteStats counts one application in one minute (POST /v1/l4/stats/drain): connections or UDP sessions accepted and refused, the highest concurrent count seen, bytes from and to clients (counted while connections run).

type L4Status

type L4Status struct {
	Version     int64   `json:"version"`
	Revision    uint64  `json:"revision,string"`
	ContentHash string  `json:"content_hash"`
	Apps        int     `json:"apps"`
	PushedAt    float64 `json:"pushed_at"`
	// Down lists the origins the passive check holds down.
	Down []L4Down `json:"down,omitempty"`
}

L4Status is the answer of GET and PUT /v1/l4. Version is 0 until the first push after nginx (re)started.

func (*L4Status) InSync

func (s *L4Status) InSync(t *L4Table) bool

InSync reports whether the stream subsystem serves exactly table t.

type L4Table

type L4Table struct {
	Revision    uint64           `json:"revision,string"`
	ContentHash string           `json:"content_hash"`
	Apps        []configir.L4App `json:"apps"`
	IPLists     []L4IPList       `json:"ip_lists"`
	// OriginAllowedCIDRs lets origins use these special-purpose addresses
	// (DNS answers are checked against them in Lua).
	OriginAllowedCIDRs []string `json:"origin_allowed_cidrs"`
}

L4Table is the body of PUT /v1/l4: the layer-4 applications without what nginx.conf already fixes per port, and the IP lists they use. The control API forwards it to the stream subsystem (lua/edgeweir/l4.lua), whose shared dicts the http side cannot reach.

func L4FromPlan

func L4FromPlan(p *configir.Plan) *L4Table

L4FromPlan converts the plan's layer-4 applications (nil without any: nginx.conf then has no stream subsystem to push to).

type List

type List[T any] []T

List is a JSON array that also accepts {} and null: lua-cjson encodes an empty table as {}.

func (*List[T]) UnmarshalJSON

func (l *List[T]) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type MinuteStats

type MinuteStats struct {
	Minute        int64             `json:"minute"`
	SiteID        string            `json:"site_id"`
	Requests      uint64            `json:"requests"`
	BytesSent     uint64            `json:"bytes_sent"`
	BytesReceived uint64            `json:"bytes_received"`
	CacheHits     uint64            `json:"cache_hits"`
	CacheMisses   uint64            `json:"cache_misses"`
	StatusCodes   map[string]uint64 `json:"status_codes"`
	TopURLs       map[string]uint64 `json:"top_urls"`
	TopIPs        map[string]uint64 `json:"top_ips"`
	// WAFRules counts the CRS rules that matched, by rule id (the heaviest
	// 20 of the minute).
	WAFRules map[string]uint64 `json:"waf_rules"`
	// LoggedRules counts the matches of rules with the log action, by rule
	// id (the heaviest 20 of the minute).
	LoggedRules map[string]uint64 `json:"logged_rules"`
	// AuthFailures counts the requests access authentication refused
	// (feature access-auth-v1).
	AuthFailures uint64 `json:"auth_failures"`
	// ImageBytesSaved is what WebP / AVIF variants saved against their
	// originals on complete 200 answers to GETs (feature image-convert-v1).
	ImageBytesSaved uint64 `json:"image_bytes_saved"`
	// MarkdownResponses counts complete 200 answers to GETs served as
	// Markdown converted from HTML (feature markdown-v1).
	MarkdownResponses uint64 `json:"markdown_responses"`
	// TierFetches and TierServed count the tiered cache's fetches from upper
	// tiers and the requests served to lower tiers, by cache status
	// (feature tiered-cache-v1).
	TierFetches map[string]uint64 `json:"tier_fetches"`
	TierServed  map[string]uint64 `json:"tier_served"`
	// ExtCounters are node extensions' counters and faults by
	// "ext.<id>.<name>" (feature extensions-v1).
	ExtCounters map[string]uint64 `json:"ext_counters"`
	// The bounded dimensions (feature stats-dims-v1, ADR-0041): requests
	// and bytes sent per country ("" unknown, at most 250), the heaviest 50
	// networks (by AS number, with names) and referring hosts, requests per
	// user agent class, HTTP and TLS version and block reason, challenges
	// issued and passed.
	Countries        map[string]CountryCount `json:"countries"`
	ASNs             map[string]ASNCount     `json:"asns"`
	Referers         map[string]uint64       `json:"referers"`
	Browsers         map[string]uint64       `json:"browsers"`
	OperatingSystems map[string]uint64       `json:"operating_systems"`
	Devices          map[string]uint64       `json:"devices"`
	HTTPVersions     map[string]uint64       `json:"http_versions"`
	TLSVersions      map[string]uint64       `json:"tls_versions"`
	BlockReasons     map[string]uint64       `json:"block_reasons"`
	ChallengesIssued uint64                  `json:"challenges_issued"`
	ChallengesPassed uint64                  `json:"challenges_passed"`
	// ChallengeOutcomes counts challenges by "<kind>:<outcome>" (feature
	// challenge-v3).
	ChallengeOutcomes map[string]uint64 `json:"challenge_outcomes"`
	// Origins counts the fetches from each origin, by origin id (feature
	// origin-stats-v1, ADR-0052; at most 64).
	Origins map[string]OriginCount `json:"origins"`
	// Crawlers counts the requests that claimed an AI crawler, per crawler
	// and verification; CrawlerPaths the paths they requested most
	// (feature ai-crawlers-v1, ADR-0070).
	Crawlers     []CrawlerCount     `json:"crawlers"`
	CrawlerPaths []CrawlerPathCount `json:"crawler_paths"`
}

MinuteStats is one per-site, per-minute bucket from POST /v1/stats/drain.

type OriginCount added in v1.4.0

type OriginCount struct {
	Requests          uint64   `json:"requests"`
	ConnectFailures   uint64   `json:"connect_failures"`
	Timeouts          uint64   `json:"timeouts"`
	TLSFailures       uint64   `json:"tls_failures"`
	InvalidResponses  uint64   `json:"invalid_responses"`
	ServerErrors      uint64   `json:"server_errors"`
	HeaderTimeBuckets []uint64 `json:"header_time_buckets"`
	HeaderTimeMSSum   uint64   `json:"header_time_ms_sum"`
}

OriginCount is a minute of an origin's fetches: attempts, failed attempts by class, attempts answered with a 5xx, and the answered attempts' times to the response header (HeaderTimeBuckets: upper bounds HeaderTimeBoundsMS and above; HeaderTimeMSSum: their sum in ms).

type OriginHealth

type OriginHealth struct {
	SiteID        string  `json:"site_id"`
	OriginID      string  `json:"origin_id"`
	Healthy       bool    `json:"healthy"`
	Failures      uint32  `json:"failures"`
	LastFailureAt float64 `json:"last_failure_at"`
	DownUntil     float64 `json:"down_until"`
	LastError     string  `json:"last_error"`
	// LastErrorCode and LastErrorParams describe the last error for the
	// console (see lua/edgeweir/health.lua); empty for unknown errors.
	LastErrorCode   string            `json:"last_error_code"`
	LastErrorParams map[string]string `json:"last_error_params,omitempty"`
}

OriginHealth is one entry of GET /v1/origins/health (origins with recorded failures; times are Unix seconds, 0 when unset).

type OwnBanRelease

type OwnBanRelease struct {
	SiteID string `json:"site_id"`
	// CIDR is what the own ban holds: an IPv4 address ("/32") or an IPv6
	// /64 ("/128" for own bans of older nodes), or the network of a ban a
	// rule made (IPv4 /16-/32, IPv6 /48-/64).
	CIDR string `json:"cidr"`
	// ExpiresAt is the console's expiry in Unix seconds (millisecond precision).
	ExpiresAt float64 `json:"expires_at"`
}

OwnBanRelease names an own ban the console lifted, for POST /v1/bans/release: the data plane deletes the node's own ban of the site and address unless it expires later than ExpiresAt.

type PurgeMarker

type PurgeMarker struct {
	SiteID string `json:"site_id"`
	// Type is "url", "prefix", "site" or "tag".
	Type  string `json:"type"`
	Host  string `json:"host,omitempty"`
	Path  string `json:"path,omitempty"`
	Query string `json:"query,omitempty"`
	// Tag is the Cache-Tag of a "tag" marker: 1-128 bytes of printable
	// ASCII without commas and without leading or trailing spaces
	// (compared in lowercase).
	Tag string `json:"tag,omitempty"`
	// Epoch is the purge time in milliseconds; it becomes part of the keys.
	Epoch int64 `json:"epoch"`
}

PurgeMarker invalidates cached objects of a site (see lua/edgeweir/purge.lua).

type PurgeStatus

type PurgeStatus struct {
	ID      string `json:"id"`
	Entries int    `json:"entries"`
	Markers int    `json:"markers"`
	// Collapsed lists the sites (of a PUT) whose markers did not fit and
	// were replaced by one site-level marker each.
	Collapsed []string `json:"collapsed,omitempty"`
}

PurgeStatus is the data plane's marker set. An empty ID after an nginx restart means the markers must be pushed again.

type PurgeTable

type PurgeTable struct {
	ID      string        `json:"id"`
	Markers []PurgeMarker `json:"markers"`
}

PurgeTable is the body of PUT and POST /v1/purge. ID identifies the full marker set after the call.

type SecurityEvent

type SecurityEvent struct {
	ID     string  `json:"id"`
	SiteID string  `json:"site_id"`
	Time   float64 `json:"time"`
	// Kind is site_level, path_level or ip_banned.
	Kind          string         `json:"kind"`
	Level         string         `json:"level"`
	PreviousLevel string         `json:"previous_level"`
	Path          string         `json:"path"`
	Address       string         `json:"address"`
	Metric        string         `json:"metric"`
	Observed      float64        `json:"observed"`
	Threshold     float64        `json:"threshold"`
	TopIPs        List[TopCount] `json:"top_ips"`
	TopPaths      List[TopCount] `json:"top_paths"`
}

SecurityEvent is a CC mitigation event from POST /v1/security/drain.

type SecurityPath

type SecurityPath struct {
	Path  string `json:"path"`
	Level string `json:"level"`
}

SecurityPath is an escalated path of a site.

type SecuritySite

type SecuritySite struct {
	SiteID string `json:"site_id"`
	// Level is normal, cookie302, js, pow or captcha.
	Level          string             `json:"level"`
	EscalatedPaths int                `json:"escalated_paths"`
	Paths          List[SecurityPath] `json:"paths"`
	// SiteQPS and ErrorPercent are the rates of the last evaluation.
	SiteQPS      float64 `json:"site_qps"`
	ErrorPercent float64 `json:"error_percent"`
}

SecuritySite is the CC state of a site with CC on this node.

type SecurityStatus

type SecurityStatus struct {
	Sites         List[SecuritySite] `json:"sites"`
	PendingEvents int                `json:"pending_events"`
	DroppedEvents uint64             `json:"dropped_events"`
}

SecurityStatus is the response of GET /v1/security.

type SiteTable

type SiteTable struct {
	Revision    uint64          `json:"revision,string"`
	ContentHash string          `json:"content_hash"`
	Sites       []configir.Site `json:"sites"`
	// OriginAllowedCIDRs lets origins use these special-purpose addresses
	// (literals and DNS answers are checked against them in Lua).
	OriginAllowedCIDRs []string `json:"origin_allowed_cidrs"`
	// CDNID is this node's CDN-Loop identifier (RFC 8586); empty before
	// the node is enrolled.
	CDNID          string                   `json:"cdn_id,omitempty"`
	HTTPChallenges []configir.HTTPChallenge `json:"http_challenges,omitempty"`
	IPLists        []*nodev1.IpList         `json:"ip_lists,omitempty"`
	PlatformRules  []*nodev1.EdgeRule       `json:"platform_rules,omitempty"`
	// PlatformProtection is the platform-wide Under Attack.
	PlatformProtection *configir.PlatformProtection `json:"platform_protection,omitempty"`
	// TagTTL is the lifetime of Cache-Tag index entries in seconds: the
	// longest inactive time of the cache zones (an object can stay cached
	// that long after its last request).
	TagTTL uint32 `json:"tag_ttl,omitempty"`
	// PlatformErrorPages are the platform's pages for unknown and offline
	// hosts; OfflineHosts the domains of disabled sites.
	PlatformErrorPages *configir.PlatformErrorPages `json:"platform_error_pages,omitempty"`
	OfflineHosts       []configir.OfflineHost       `json:"offline_hosts,omitempty"`
	// HealthCertificate is the node's self-signed certificate for SNI
	// health.edgeweir.invalid and handshakes without SNI (probe-health-v1).
	HealthCertificate *configir.Certificate `json:"health_certificate,omitempty"`
	// ClientAddress is the cluster's client address setting; the data
	// plane uses its trusted proxies (never banned, not counted by CC).
	ClientAddress *configir.ClientAddress `json:"client_address,omitempty"`
	// UnknownHosts is the cluster's handling of unknown hosts and node IP
	// access, and scan protection (unknown-host-v1).
	UnknownHosts *configir.UnknownHosts `json:"unknown_hosts,omitempty"`
	// AICrawlers is the AI crawler catalogue (ADR-0070).
	AICrawlers []configir.AICrawler `json:"ai_crawlers,omitempty"`
	// TierClients are the node ids the tier listener serves as lower tiers
	// (tiered-cache-v1).
	TierClients []string `json:"tier_clients,omitempty"`
	// Extensions are the node extensions (extensions-v1): the kill switch
	// and, in hook order, each extension's settings and whether its package
	// loaded (state "loaded"); the sites name theirs.
	Extensions *ExtensionTable `json:"extensions,omitempty"`
}

SiteTable is the body of PUT /v1/sites.

func FromPlan

func FromPlan(p *configir.Plan) *SiteTable

FromPlan converts a plan into the site table pushed to Lua.

type Status

type Status struct {
	Version       int64       `json:"version"`
	Revision      uint64      `json:"revision,string"`
	ContentHash   string      `json:"content_hash"`
	SiteCount     int         `json:"site_count"`
	PushedAt      float64     `json:"pushed_at"`
	CDNID         string      `json:"cdn_id"`
	Purge         PurgeStatus `json:"purge"`
	NginxVersion  int64       `json:"nginx_version,omitempty"`
	NgxLuaVersion int64       `json:"ngx_lua_version,omitempty"`
	WorkerPID     int         `json:"worker_pid,omitempty"`
	// ConfID is the id of the nginx.conf the answering worker runs (see
	// render.ConfID).
	ConfID string `json:"conf_id,omitempty"`
	// ConnectionsActive is nginx's $connections_active (stub_status) without
	// the status request itself: client connections, and the edge layer's
	// connections to the origin layer's unix sockets.
	ConnectionsActive uint64 `json:"connections_active,omitempty"`
}

Status is the response of GET /v1/status. Version is 0 until the first push after nginx (re)started: the shared dicts are empty then.

func (*Status) InSync

func (s *Status) InSync(t *SiteTable) bool

InSync reports whether the data plane serves exactly table t.

type TapEntry added in v1.0.0

type TapEntry struct {
	Time        float64 `json:"time"`
	SiteID      string  `json:"site_id"`
	ClientIP    string  `json:"client_ip"`
	Method      string  `json:"method"`
	Host        string  `json:"host"`
	Path        string  `json:"path"`
	Status      uint32  `json:"status"`
	BytesSent   uint64  `json:"bytes_sent"`
	DurationMS  uint32  `json:"duration_ms"`
	CacheStatus string  `json:"cache_status,omitempty"`
	RequestID   string  `json:"request_id,omitempty"`
	// contains filtered or unexported fields
}

TapEntry is a request of the live view (GET /v1/logs/tap, ADR-0041 §6): the fields of a sampled access log line without the site's optional ones; SiteID is "" for requests of no site.

type TapPage added in v1.0.0

type TapPage struct {
	Seq     uint64     `json:"seq"`
	Entries []TapEntry `json:"entries"`
	Missed  uint64     `json:"missed"`
	Dropped uint64     `json:"dropped"`
}

TapPage is one answer of the live view: the entries after the sequence number asked for, the last number read (to ask after next time), how many numbers were missed (expired) and the data plane's total of requests it dropped over its rate since nginx started (they take no number: a viewer counts the growth between two pages as missed).

type TopCount

type TopCount struct {
	Value string  `json:"value"`
	Count float64 `json:"count"`
}

TopCount is one of the heaviest addresses or paths of an event.

Jump to

Keyboard shortcuts

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