mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-09-12 01:39:10 +02:00
Implement turn server settings
this fills out the infos in /_matrix/client/r0/voip/turnServer with values specified in the server config
This commit is contained in:
parent
24a835647c
commit
109892b4b7
3 changed files with 35 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
||||||
use crate::ConduitResult;
|
use crate::{database::DatabaseGuard, ConduitResult};
|
||||||
use ruma::api::client::r0::voip::get_turn_server_info;
|
use ruma::api::client::r0::voip::get_turn_server_info;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
@ -9,13 +9,13 @@ use rocket::get;
|
||||||
///
|
///
|
||||||
/// TODO: Returns information about the recommended turn server.
|
/// TODO: Returns information about the recommended turn server.
|
||||||
#[cfg_attr(feature = "conduit_bin", get("/_matrix/client/r0/voip/turnServer"))]
|
#[cfg_attr(feature = "conduit_bin", get("/_matrix/client/r0/voip/turnServer"))]
|
||||||
#[tracing::instrument]
|
#[tracing::instrument(skip(db))]
|
||||||
pub async fn turn_server_route() -> ConduitResult<get_turn_server_info::Response> {
|
pub async fn turn_server_route(db: DatabaseGuard) -> ConduitResult<get_turn_server_info::Response> {
|
||||||
Ok(get_turn_server_info::Response {
|
Ok(get_turn_server_info::Response {
|
||||||
username: "".to_owned(),
|
username: db.globals.turn_username().clone(),
|
||||||
password: "".to_owned(),
|
password: db.globals.turn_password().clone(),
|
||||||
uris: Vec::new(),
|
uris: db.globals.turn_uris().to_vec(),
|
||||||
ttl: Duration::from_secs(60 * 60 * 24),
|
ttl: Duration::from_secs(db.globals.turn_ttl()),
|
||||||
}
|
}
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,14 @@ pub struct Config {
|
||||||
trusted_servers: Vec<Box<ServerName>>,
|
trusted_servers: Vec<Box<ServerName>>,
|
||||||
#[serde(default = "default_log")]
|
#[serde(default = "default_log")]
|
||||||
pub log: String,
|
pub log: String,
|
||||||
|
#[serde(default)]
|
||||||
|
turn_username: String,
|
||||||
|
#[serde(default)]
|
||||||
|
turn_password: String,
|
||||||
|
#[serde(default = "Vec::new")]
|
||||||
|
turn_uris: Vec<String>,
|
||||||
|
#[serde(default = "default_turn_ttl")]
|
||||||
|
turn_ttl: u64,
|
||||||
|
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
catchall: BTreeMap<String, IgnoredAny>,
|
catchall: BTreeMap<String, IgnoredAny>,
|
||||||
|
@ -131,6 +139,10 @@ fn default_log() -> String {
|
||||||
"info,state_res=warn,rocket=off,_=off,sled=off".to_owned()
|
"info,state_res=warn,rocket=off,_=off,sled=off".to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn default_turn_ttl() -> u64 {
|
||||||
|
60 * 60 * 24
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "sled")]
|
#[cfg(feature = "sled")]
|
||||||
pub type Engine = abstraction::sled::Engine;
|
pub type Engine = abstraction::sled::Engine;
|
||||||
|
|
||||||
|
|
|
@ -226,6 +226,22 @@ impl Globals {
|
||||||
self.jwt_decoding_key.as_ref()
|
self.jwt_decoding_key.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn turn_password(&self) -> &String {
|
||||||
|
&self.config.turn_password
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn turn_ttl(&self) -> u64 {
|
||||||
|
self.config.turn_ttl
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn turn_uris(&self) -> &[String] {
|
||||||
|
&self.config.turn_uris
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn turn_username(&self) -> &String {
|
||||||
|
&self.config.turn_username
|
||||||
|
}
|
||||||
|
|
||||||
/// TODO: the key valid until timestamp is only honored in room version > 4
|
/// TODO: the key valid until timestamp is only honored in room version > 4
|
||||||
/// Remove the outdated keys and insert the new ones.
|
/// Remove the outdated keys and insert the new ones.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in a new issue