pub struct ServerConfig {
pub host: String,
pub port: u16,
pub security: SecurityConfig,
pub graceful_shutdown: bool,
pub generated_key: Option<UnboundedSender<String>>,
}Expand description
Server configuration.
Fields§
§host: StringHost address to bind to.
port: u16Port to listen on.
security: SecurityConfigSecurity configuration.
graceful_shutdown: boolEnable graceful shutdown on SIGTERM/SIGINT.
generated_key: Option<UnboundedSender<String>>Where to report an API key this server generated for itself.
serve_on generates one when authentication is on and no key was
registered. It used to write that key to the log, which handed an
embedding consumer a plaintext secret in whatever its logs go to. It now
sends the key here instead: the library reports the fact, the caller
decides where it goes — the arrangement
[crate::relay::client::RelayClientConfig]’s enrolled already uses.
None leaves the key unreported, and serve_on warns when it lands
there — a key nobody can read authenticates nobody. Register a key with
SecurityConfig::with_api_key if you have one; set this if you want
the generated one.
The send happens before the listener starts accepting, and the channel
is unbounded, so the key waits in it: spawn serve_on and receive
afterwards. Nothing needs to be draining it first.
Implementations§
Source§impl ServerConfig
impl ServerConfig
pub fn new(host: impl Into<String>, port: u16) -> Self
pub fn bind_address(&self) -> String
Sourcepub fn with_security(self, security: SecurityConfig) -> Self
pub fn with_security(self, security: SecurityConfig) -> Self
Enable security with the given configuration.
Sourcepub fn without_graceful_shutdown(self) -> Self
pub fn without_graceful_shutdown(self) -> Self
Disable graceful shutdown.
Sourcepub fn report_generated_key_to(self, tx: UnboundedSender<String>) -> Self
pub fn report_generated_key_to(self, tx: UnboundedSender<String>) -> Self
Report a key this server generates for itself on tx.
See ServerConfig::generated_key for when that happens and what
leaving it unset costs.
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 moreSource§impl Debug for ServerConfig
impl Debug for ServerConfig
Auto Trait Implementations§
impl Freeze for ServerConfig
impl RefUnwindSafe for ServerConfig
impl Send for ServerConfig
impl Sync for ServerConfig
impl Unpin for ServerConfig
impl UnsafeUnpin for ServerConfig
impl UnwindSafe for ServerConfig
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.