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 more