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