Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b734c1aff5 |
@@ -74,6 +74,11 @@ 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,
|
||||||
|
/// If enabled, Conduit will serve /.wellknown/matrix files that point to the configured server_name.
|
||||||
|
/// This should make it easier, if you only host Conduit on the same domain as the server_name.
|
||||||
|
/// E.g. setting server_name: "matrix.example.com" -> other servers are directed to "https://matrix.example.com:443"
|
||||||
|
#[serde(default = "false_fn")]
|
||||||
|
pub serve_wellknown: bool,
|
||||||
|
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
catchall: BTreeMap<String, IgnoredAny>,
|
catchall: BTreeMap<String, IgnoredAny>,
|
||||||
|
|||||||
@@ -226,6 +226,10 @@ impl Globals {
|
|||||||
self.jwt_decoding_key.as_ref()
|
self.jwt_decoding_key.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn serve_wellknown(&self) -> bool {
|
||||||
|
self.config.serve_wellknown
|
||||||
|
}
|
||||||
|
|
||||||
/// 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.
|
||||||
///
|
///
|
||||||
|
|||||||
+12
-2
@@ -10,6 +10,7 @@
|
|||||||
pub mod appservice_server;
|
pub mod appservice_server;
|
||||||
pub mod client_server;
|
pub mod client_server;
|
||||||
pub mod server_server;
|
pub mod server_server;
|
||||||
|
pub mod well_known;
|
||||||
|
|
||||||
mod database;
|
mod database;
|
||||||
mod error;
|
mod error;
|
||||||
@@ -40,8 +41,17 @@ use tokio::sync::RwLock;
|
|||||||
use tracing_subscriber::{prelude::*, EnvFilter};
|
use tracing_subscriber::{prelude::*, EnvFilter};
|
||||||
|
|
||||||
fn setup_rocket(config: Figment, data: Arc<RwLock<Database>>) -> rocket::Rocket<rocket::Build> {
|
fn setup_rocket(config: Figment, data: Arc<RwLock<Database>>) -> rocket::Rocket<rocket::Build> {
|
||||||
rocket::custom(config)
|
let rocket_builder = rocket::custom(config).manage(data);
|
||||||
.manage(data)
|
|
||||||
|
// If configured, serve .well-known/matrix files
|
||||||
|
if data.lock().globals.serve_wellknown() {
|
||||||
|
rocket_builder.mount(
|
||||||
|
"/",
|
||||||
|
routes![well_known::well_known_server, well_known::well_known_client,],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
rocket_builder
|
||||||
.mount(
|
.mount(
|
||||||
"/",
|
"/",
|
||||||
routes![
|
routes![
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#[cfg(feature = "conduit_bin")]
|
||||||
|
use rocket::get;
|
||||||
|
use rocket::response::content;
|
||||||
|
use crate::database::DatabaseGuard;
|
||||||
|
//use serde::Serialize;
|
||||||
|
|
||||||
|
//#[derive(Serialize)]
|
||||||
|
//pub struct WellKnownServerInfo {
|
||||||
|
// m_server: String,
|
||||||
|
//}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "conduit_bin", get("/.well-known/matrix/server"))]
|
||||||
|
#[tracing::instrument(skip(db))]
|
||||||
|
pub fn well_known_server(db: DatabaseGuard) -> content::Json<String> {
|
||||||
|
// Pull the server_name from config
|
||||||
|
let server_name = db.globals.server_name().clone();
|
||||||
|
content::Json(format!("{{\"m.server\": \"{}:443\"}}", server_name))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "conduit_bin", get("/.well-known/matrix/client"))]
|
||||||
|
#[tracing::instrument(skip(db))]
|
||||||
|
pub fn well_known_client(db: DatabaseGuard) -> content::Json<String> {
|
||||||
|
// Pull the server_name from config
|
||||||
|
let server_name = db.globals.server_name().clone();
|
||||||
|
content::Json(format!("{{\"m.homeserver\": {{ \"base_url\": \"https://{}\"}}}}", server_name))
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user