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 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 moreAuto Trait Implementations§
impl Freeze for RelayConfig
impl RefUnwindSafe for RelayConfig
impl Send for RelayConfig
impl Sync for RelayConfig
impl Unpin for RelayConfig
impl UnsafeUnpin for RelayConfig
impl UnwindSafe for RelayConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.