pub struct ServerConfig {
pub host: String,
pub port: u16,
pub cors_origins: Vec<String>,
pub trust_xff: bool,
pub rate_limit_interval_secs: u64,
pub rate_limit_burst: u32,
}Fields§
§host: String§port: u16§cors_origins: Vec<String>Origins permitted to make cross-origin requests against the
VTA’s REST surface. Empty (default) disables the CORS layer
entirely — a fresh-install VTA refuses cross-origin requests
the way the legacy behaviour did. Production deployments
typically leave this empty (programmatic clients send the
bearer token directly and don’t need browser-side CORS); the
demo at examples/vta-auth-demo/ sets it to
["http://localhost:8000"] so an operator can drive the
auth flow from a browser running on a different localhost
port.
Each entry is matched exactly against the request’s Origin
header. Wildcards are not accepted — bearer credentials must
not flow to arbitrary origins.
trust_xff: boolWhether to trust X-Forwarded-For / Forwarded headers
for client-IP attribution in the per-IP rate limiter.
Default false — the rate limiter keys on the socket
peer-IP (PeerIpKeyExtractor). This is the safe default
for direct-binding deployments where an attacker can spoof
X-Forwarded-For to evade rate limiting.
Set true only when the VTA runs behind a trust-boundary
reverse proxy (Nginx, Envoy, ALB) that overwrites or
strips these headers from external requests — the rate
limiter switches to SmartIpKeyExtractor and walks the
X-Forwarded-For chain. Misconfiguring this (trust_xff = true with no proxy, or a misconfigured proxy that doesn’t
strip the header) is a silent rate-limit bypass.
Closes L2 from the May 2026 security review.
rate_limit_interval_secs: u64Token replenishment interval for the unauth rate limiter, in seconds
per token — not requests per second. One new token every
rate_limit_interval_secs, so lower is more permissive. Default: 5.
With the default rate_limit_burst = 10: 10 rapid requests, then one
every 5 s. Local dev that fires a bootstrap flow in a burst wants
rate_limit_interval_secs = 1 and a larger rate_limit_burst.
Zero is clamped to 1 at router build (routes::apply_unauth_governor);
the limiter cannot be turned off from config.
rate_limit_burst: u32Burst capacity for the unauth rate limiter — how many requests can arrive back-to-back before throttling starts. Default: 10. Zero is clamped to 1.
Trait Implementations§
Source§impl Clone for ServerConfig
impl Clone for ServerConfig
Source§fn clone(&self) -> ServerConfig
fn clone(&self) -> ServerConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more