webrtc_turn/server/
config.rs1use crate::auth::*;
2use crate::errors::*;
3use crate::relay::*;
4
5use util::{Conn, Error};
6
7use tokio::time::Duration;
8
9use std::sync::Arc;
10
11pub struct ConnConfig {
13 pub conn: Arc<dyn Conn + Send + Sync>,
14
15 pub relay_addr_generator: Box<dyn RelayAddressGenerator + Send + Sync>,
18}
19
20impl ConnConfig {
21 pub fn validate(&self) -> Result<(), Error> {
22 self.relay_addr_generator.validate()
23 }
24}
25
26pub struct ServerConfig {
28 pub conn_configs: Vec<ConnConfig>,
31
32 pub realm: String,
34
35 pub auth_handler: Arc<Box<dyn AuthHandler + Send + Sync>>,
37
38 pub channel_bind_timeout: Duration,
40}
41
42impl ServerConfig {
43 pub fn validate(&self) -> Result<(), Error> {
44 if self.conn_configs.is_empty() {
45 return Err(ERR_NO_AVAILABLE_CONNS.to_owned());
46 }
47
48 for cc in &self.conn_configs {
49 cc.validate()?;
50 }
51 Ok(())
52 }
53}