Skip to main content

Crate pingap_core

Crate pingap_core 

Source

Re-exports§

pub use ja4::Ja4Fingerprint;
pub use ja4::is_grease;

Modules§

ja4
JA4 TLS client fingerprints, computed from the raw ClientHello the client sent.

Structs§

BackgroundTaskService
A unified background service runner that can handle one or more named tasks.
BodyPace
A limit on how fast a response body is sent: so many bytes a second, once the first after of them are out.
CacheInfo
All cache-related configuration and statistics for a request.
CacheKeyVariant
Components of the cache key that stand for something this request said - the coding it accepts, the image formats it takes - and that another request for the same url has others in the place of.
CompressionStat
Statistics about response compression operations.
ConnectionInfo
Information about a single client connection.
Ctx
Represents the state of a request/response cycle, tracking various metrics and properties including connection details, caching information, and upstream server interactions.
DigestDetail
Helper struct to store connection timing and TLS details
Features
Optional features like tracing, plugins, and response modifications.
Guard
A Guard is returned when an Inflight key is incremented via Inflight::incr.
HttpChunkResponse
Represents a chunked HTTP response for streaming large bodies of data.
HttpResponse
Represents a complete HTTP response, including status, headers, and a body. This struct is used for responses where the entire body is known upfront.
HttpResponseBuilder
A builder for creating HttpResponse instances fluently using the builder pattern.
Identity
Inflight
An Inflight type tracks the frequency of actions that are actively occurring. When the value is dropped from scope, the count will automatically decrease.
InflightGuard
One request in flight on a backend, for as long as this is kept: the count goes up when it is made and down when it is dropped, whichever way the request ends.
MissingPlugin
Takes the place of a plugin that a location names but that is not loaded: the name is misspelled, or the plugin failed to build. It fails every request of that location.
NotificationData
NtfyTarget
Where a notification for ntfy goes.
ProxyProtocolConnectOptions
What pingora’s own connector takes from the peer for the socket it opens. A connector that stands in for it is given the address and nothing else, so these come with it.
ProxyProtocolConnector
Connects to a backend and writes a PROXY protocol header as the first bytes of the connection.
Rate
A stable rate estimator that reports the rate of events per period of interval time.
RateLimitQuota
What a limit has left for the client of this request, as the X-RateLimit-* response headers tell it.
RequestState
State related to the current request being processed.
Timing
All timing-related metrics for the request lifecycle.
TinyUfo
TinyUfo cache
TlsClientCert
What is told about the certificate of a client: enough to say who it is to an upstream, a plugin or the access log.
TtlLruLimit
UpstreamInfo
Information about the upstream (backend) server.

Enums§

CacheQueryRule
Which parameters of the query a cache key is made of.
CtxLogField
A Ctx value the access log can print. The {:name} in a log format parses into one of these once, when the format is read, so writing a log line dispatches on an enum instead of comparing the name against every key on every request.
Error
ModifiedMode
NotificationLevel
Variants are declared from least to most severe so the derived Ord ranks them: a merged batch reports the highest level in it.
PlainBody
The responses whose body a plugin reads, see Ctx::keep_response_body_plain.
PluginStep
ProxyProtocolVersion
The form of the header.
RequestPluginResult
A more expressive return type for handle_request. It clearly states the plugin’s decision.
ResponseBodyPluginResult
ResponsePluginResult
Represents the action a plugin takes on a response.

Constants§

ACCESS_LOG_PRESETS
The names access_log accepts in place of a format. Here, and not with the formats themselves in pingap-logger, so that the config validation knows a preset from a word that is none.
DEFAULT_IDENTITY_NAME
What a deployment is called when its configuration does not say.
HOST_NAME_TAG
NOTIFICATION_MAX_RETRIES
The most a notification that could not be delivered is sent again. Each wait is twice the one before, from a second: ten of them are a quarter of an hour, by which time it is news no longer.
NOTIFICATION_TYPE_NTFY
The webhook_type of a notification that is published to ntfy.
PROXY_PROTOCOL_VERSIONS
The names a configuration has for the versions, in lower case.

Statics§

HTTP_HEADER_CONTENT_HTML
HTTP_HEADER_CONTENT_JSON
HTTP_HEADER_CONTENT_TEXT
HTTP_HEADER_NAME_X_REQUEST_ID
HTTP_HEADER_NO_CACHE
HTTP_HEADER_NO_STORE
HTTP_HEADER_TRANSFER_CHUNKED

Traits§

BackgroundTask
A unified trait for any task that can be run in the background.
HandleRequestBody
What a plugin does with the body of the request as it is passed on to the upstream: looks at it (a digest to check) or keeps a copy of it (a mirror). It does not change it.
LocationInstance
Trait for location instance
ModifyResponseBody
Trait for modifying the response body.
Notification
Trait for sending notifications
Plugin
Core trait that defines the interface all plugins must implement.
PluginProvider
Plugin provider trait
UpstreamInstance
Trait for upstream instance, used to handle the upstream instance lifecycle.

Functions§

cache_key_slot
The value of a header as one component of the cache key. The components are joined with :, so one inside a value is written %3A (and % as %25): Origin: https://a.com with nothing after it and Origin: https followed by //a.com: were one key, and whoever sent the second chose the response the first was given.
canonical_path
normalize_path in a form that can be sent on: the same path, with what a uri cannot carry as it is - a space, a ? that was %3F, a byte that is not ASCII - percent-encoded again.
client_used_https
Whether the client reached the site over https, as far as that can be vouched for: what a trusted proxy says of it, and otherwise whether this connection is one.
constant_time_eq
Compares two byte slices in constant time relative to their length, avoiding the early exit of == that can leak (via timing) how many leading bytes matched. Use it for verifying secrets, MACs and signatures. The slice lengths are not treated as secret and are compared up front.
convert_header
Converts a single string in “name: value” format into an HttpHeader tuple.
convert_header_value
Processes a HeaderValue that may contain a special dynamic variable (e.g., $host). It replaces the variable with its corresponding runtime value.
convert_headers
Converts a slice of strings into a Vec of HttpHeaders.
decode_query_value
The value of a query parameter as the client meant it, with its percent-encoding decoded. + stays a plus: that it stands for a space is a rule of html forms, not of urls. A value that does not decode to text is returned as it came.
decorate_plugin_response
Lets the plugins that ask for it set their headers on a response a plugin is about to write itself.
ensure_client_ip
Ensures ctx.conn.client_ip is populated and returns a borrowed reference.
ensure_verified_client_ip
The address to check a request by when the check grants something to the few, such as the allow list of the cache’s PURGE.
format_duration
Format the duration in human readable format, checking smaller units first. e.g., ms, s, m, h.
get_cache_key
Generates the cache key of a request.
get_client_ip
Gets the client’s IP address.
get_cookie_value
Parses the “Cookie” header to find the value of a specific cookie.
get_digest_detail
Extracts timing and TLS information from connection digest. Used for metrics and logging connection details.
get_host
Gets the request host by checking the URI first, then falling back to the “Host” header.
get_hostname
Returns the system hostname.
get_identity
Who this process is: what set_identity was given, pingap without labels before that.
get_query_value
Gets the value of a specific query parameter from the request URI.
get_remote_addr
Gets the remote address (IP and port) from the session.
get_req_header_value
A convenient helper to get a header value as a &str from a RequestHeader.
get_request_host
The host of the request as it was sent, less its port: what get_host gives before it drops the root label.
get_super_ts
Returns the number of seconds elapsed since SUPER_TIMESTAMP Returns 0 if the current time is before SUPER_TIMESTAMP
has_dot_segments
Whether path has a . or .. segment, read the way normalize_path reads it: %2e%2e, ..;x, and the ones that only show once %2F or \ is taken for a separator (a%2F..%2Fb).
has_trusted_proxies
Whether basic.trusted_proxies is set.
is_ntfy_notification
Whether webhook_type names ntfy.
is_trusted_proxy
Whether ip is one of basic.trusted_proxies: an address whose word about a client is taken, before there is a request to ask it of (the PROXY protocol header of a connection). Never without a list.
is_upstream_status_error
Whether e is an error of new_upstream_status_error.
merge_cookie_headers
Puts the cookies of a request into one Cookie field.
new_internal_error
Creates a new internal error
new_proxy_protocol_header
The header a connection starts with.
new_tcp_keepalive
The keepalive options of a listener or an upstream, None when none of the four settings is given.
new_upstream_status_error
The error a plugin stops a response of the upstream with, for the proxy to answer status itself - with the error page of the location - in place of what the upstream sent (error_page with intercept).
normalize_path
The path of a request in the form it is matched by: percent-encoding decoded, path parameters left out, a backslash taken for a slash, . and .. segments resolved, repeated slashes merged.
now_ms
Returns the number of milliseconds since the epoch
now_sec
Returns the number of seconds since the epoch
parse_identity_name
What a deployment may be called (basic.name): one line of at most 64 bytes. It is put ahead of the title of a message and into the lines of an access log.
parse_labels
The labels of a deployment, as the configuration has them (basic.labels): each key:value. The key is made of letters, digits, _ and -, which is what every place that names one can write: a template, a placeholder of the access log, a tag.
parse_notification_headers
The headers of the request a notification is sent with, as the configuration has them (webhook_headers): each Name: value.
parse_notification_level
The level below which notifications are not sent, as the configuration names it (webhook_min_level): info, warn or error, and info where it names none.
parse_notification_retries
How often a notification that could not be delivered is sent again, as the configuration has it (webhook_retries): not at all where it says nothing.
parse_ntfy_url
The server and the topic of a notification for ntfy, as the configuration has them (webhook): the url of the topic, https://ntfy.sh/mytopic. A user and a password in it, and what follows a ?, stay with the server.
peer_is_trusted_proxy
Whether the connection of the request comes from one of the trusted proxies. Never without a list of them: there is then nobody whose word about a client could be taken.
protect_from_connection_header
Takes names out of what the Connection header of a request nominates, for the headers the proxy itself has put on the request.
remove_query_from_header
Removes a specific query parameter from the request header’s URI.
resolve_static_header_value
Resolves a header value that cannot change for the life of the process - $hostname and $<ENV_VAR> - so it can be stored as a plain value when the configuration is loaded instead of being looked up on every request (std::env::var takes a process-wide lock and allocates each time). Values that depend on the request ($host, $http_*, :key, …) and plain values come back unchanged, as does a $NAME whose variable is not set, so the request path treats it exactly as before.
set_identity
Notes who this process is. Once, when it starts: what is told with it is put together from then on, and a second call changes nothing.
set_path_and_query
Replaces the path and query of the request, and nothing else.
set_trusted_proxies
Sets the trusted downstream proxy addresses (individual IPs or CIDR ranges).
strip_root_label
example.com. is example.com with the root label written out, and names the same host. Matched as it came, it missed every location configured for the host and fell through to the catch-all, past the plugins that guard the host, while the upstream served it as that host.

Type Aliases§

HttpHeader
A type alias for a tuple representing an HTTP header.
NamedPlugin
A plugin paired with the name it was registered under in the location config.
NotificationSender
Type alias for a boxed Notification trait object that can be shared between threads
Plugins