pub struct RelayConfig {
pub bind: SocketAddr,
pub enroll_token: String,
pub rate_limit: RateLimitConfig,
pub public_base: Option<String>,
}Expand description
Relay server settings.
Fields§
§bind: SocketAddrAddress to listen on.
enroll_token: StringSecret a device must present to attach.
rate_limit: RateLimitConfigPer-IP request limiting for this relay.
The relay is the only place this can work for proxied traffic: a device replays requests to its own loopback listener, so its limiter sees 127.0.0.1 for every caller and cannot tell them apart. Here the real client address is still visible.
public_base: Option<String>Public base URL of this relay, when the operator states it explicitly.
Left unset, the relay derives it from each connection’s Host (and
X-Forwarded-*) headers, so a relay behind TLS termination still tells
devices an address that actually works.
Implementations§
Source§impl RelayConfig
impl RelayConfig
Sourcepub fn new(bind: SocketAddr, enroll_token: impl Into<String>) -> Self
pub fn new(bind: SocketAddr, enroll_token: impl Into<String>) -> Self
Create a configuration with the given bind address and token.
Sourcepub fn without_rate_limit(self) -> Self
pub fn without_rate_limit(self) -> Self
Turn per-IP request limiting off.
Sourcepub fn with_public_base(self, base: impl Into<String>) -> Self
pub fn with_public_base(self, base: impl Into<String>) -> Self
Set the public base URL advertised to devices.
Sourcepub fn resolved_public_base(&self) -> Option<String>
pub fn resolved_public_base(&self) -> Option<String>
The operator-configured base with this relay’s listen port filled in when the base named no port.
A base written without a port (https://relay.example.com) means the
scheme default to a browser, but an operator who bound 8443 and named no
proxy meant this relay — so the listen port is the least-surprising
fill, and every advertised URL then reaches something. An explicit port is
intent and is left untouched, which is how a reverse proxy on 443 keeps a
port-less base. observed bases are never touched here: they already name
a reachable authority.
Sourcepub fn public_base_or(&self, observed: Option<String>) -> String
pub fn public_base_or(&self, observed: Option<String>) -> String
The base URL to advertise, preferring what the operator configured.
observed is what the connection itself says this relay is reachable at.
Falling back to the bind address is a last resort — it is right only when
nothing is in front of the relay.
Trait Implementations§
Source§impl Clone for RelayConfig
impl Clone for RelayConfig
Source§fn clone(&self) -> RelayConfig
fn clone(&self) -> RelayConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more