clia_turn/server/
config.rs1use std::sync::Arc;
2
3use tokio::sync::mpsc;
4use tokio::time::Duration;
5use util::Conn;
6
7use crate::allocation::*;
8use crate::auth::*;
9use crate::error::*;
10use crate::relay::*;
11
12pub struct ConnConfig {
14 pub conn: Arc<dyn Conn + Send + Sync>,
15
16 pub relay_addr_generator: Box<dyn RelayAddressGenerator + Send + Sync>,
19}
20
21impl ConnConfig {
22 pub fn validate(&self) -> Result<()> {
23 self.relay_addr_generator.validate()
24 }
25}
26
27pub struct ServerConfig {
29 pub conn_configs: Vec<ConnConfig>,
32
33 pub realm: String,
35
36 pub auth_handler: Arc<dyn AuthHandler + Send + Sync>,
39
40 pub channel_bind_timeout: Duration,
42
43 pub alloc_close_notify: Option<mpsc::Sender<AllocationInfo>>,
45}
46
47impl ServerConfig {
48 pub fn validate(&self) -> Result<()> {
49 if self.conn_configs.is_empty() {
50 return Err(Error::ErrNoAvailableConns);
51 }
52
53 for cc in &self.conn_configs {
54 cc.validate()?;
55 }
56 Ok(())
57 }
58}