From 8ddb7c70c0fa0de20fd89a35c0e5deff9952b12a Mon Sep 17 00:00:00 2001 From: Niklas Wojtkowiak Date: Mon, 23 Feb 2026 02:47:11 -0500 Subject: [PATCH] feat(api): implement MSC4143 RTC transports discovery endpoint Add dedicated \`GET /_matrix/client/v1/rtc/transports\` and \`GET /_matrix/client/unstable/org.matrix.msc4143/rtc/transports\` endpoints for MatrixRTC focus discovery (MSC4143), replacing the deprecated well-known approach. Move RTC foci configuration from \`[global.well_known]\` into a new \`[global.matrix_rtc]\` config section with a \`foci\` field. Remove \`rtc_foci\` from the \`.well-known/matrix/client\` response. Update LiveKit setup documentation accordingly. Closes #1431 --- conduwuit-example.toml | 28 ++++++++++++++--------- docs/calls/livekit.mdx | 36 ++++-------------------------- src/api/client/well_known.rs | 15 ++++++++++++- src/api/router.rs | 8 +++++++ src/core/config/mod.rs | 43 ++++++++++++++++++++++-------------- 5 files changed, 70 insertions(+), 60 deletions(-) diff --git a/conduwuit-example.toml b/conduwuit-example.toml index 722ed6f9..58c0d95f 100644 --- a/conduwuit-example.toml +++ b/conduwuit-example.toml @@ -1844,17 +1844,6 @@ # #support_mxid = -# A list of MatrixRTC foci URLs which will be served as part of the -# MSC4143 client endpoint at /.well-known/matrix/client. If you're -# setting up livekit, you'd want something like: -# rtc_focus_server_urls = [ -# { type = "livekit", livekit_service_url = "https://livekit.example.com" }, -# ] -# -# To disable, set this to be an empty vector (`[]`). -# -#rtc_focus_server_urls = [] - [global.blurhashing] # blurhashing x component, 4 is recommended by https://blurha.sh/ @@ -1873,6 +1862,23 @@ # #blurhash_max_raw_size = 33554432 +[global.matrix_rtc] + +# A list of MatrixRTC foci (transports) which will be served via the +# MSC4143 RTC transports endpoint at +# `/_matrix/client/v1/rtc/transports`. If you're setting up livekit, +# you'd want something like: +# ```toml +# [global.matrix_rtc] +# foci = [ +# { type = "livekit", livekit_service_url = "https://livekit.example.com" }, +# ] +# ``` +# +# To disable, set this to an empty list (`[]`). +# +#foci = [] + [global.ldap] # Whether to enable LDAP login. diff --git a/docs/calls/livekit.mdx b/docs/calls/livekit.mdx index 854e6fd1..ddcd000f 100644 --- a/docs/calls/livekit.mdx +++ b/docs/calls/livekit.mdx @@ -78,47 +78,19 @@ You will need to allow ports `7881/tcp` and `50100:50200/udp` through your firew ### 3. Telling clients where to find LiveKit -To tell clients where to find LiveKit, you need to add the address of your `lk-jwt-service` to your client .well-known file. To do so, in the config section `global.well-known`, add (or modify) the option `rtc_focus_server_urls`. +To tell clients where to find LiveKit, you need to add the address of your `lk-jwt-service` to the `[global.matrix_rtc]` config section using the `foci` option. -The variable should be a list of servers serving as MatrixRTC endpoints to serve in the well-known file to the client. +The variable should be a list of servers serving as MatrixRTC endpoints. Clients discover these via the `/_matrix/client/v1/rtc/transports` endpoint (MSC4143). ```toml -rtc_focus_server_urls = [ +[global.matrix_rtc] +foci = [ { type = "livekit", livekit_service_url = "https://livekit.example.com" }, ] ``` Remember to replace the URL with the address you are deploying your instance of lk-jwt-service to. -#### Serving .well-known manually - -If you don't let Continuwuity serve your `.well-known` files, you need to add the following lines to your `.well-known/matrix/client` file, remembering to replace the URL with your own `lk-jwt-service` deployment: - -```json - "org.matrix.msc4143.rtc_foci": [ - { - "type": "livekit", - "livekit_service_url": "https://livekit.example.com" - } - ] -``` - -The final file should look something like this: - -```json -{ - "m.homeserver": { - "base_url":"https://matrix.example.com" - }, - "org.matrix.msc4143.rtc_foci": [ - { - "type": "livekit", - "livekit_service_url": "https://livekit.example.com" - } - ] -} -``` - ### 4. Configure your Reverse Proxy Reverse proxies can be configured in many different ways - so we can't provide a step by step for this. diff --git a/src/api/client/well_known.rs b/src/api/client/well_known.rs index 95bf7c05..adc9b89c 100644 --- a/src/api/client/well_known.rs +++ b/src/api/client/well_known.rs @@ -27,10 +27,23 @@ pub(crate) async fn well_known_client( identity_server: None, sliding_sync_proxy: Some(SlidingSyncProxyInfo { url: client_url }), tile_server: None, - rtc_foci: services.config.well_known.rtc_focus_server_urls.clone(), + rtc_foci: vec![], }) } +/// # `GET /_matrix/client/v1/rtc/transports` +/// # `GET /_matrix/client/unstable/org.matrix.msc4143/rtc/transports` +/// +/// Returns the list of MatrixRTC foci (transports) configured for this +/// homeserver, implementing MSC4143. +pub(crate) async fn get_rtc_transports( + State(services): State, +) -> Result { + Ok(Json(serde_json::json!({ + "rtc_foci": services.config.matrix_rtc.foci, + }))) +} + /// # `GET /.well-known/matrix/support` /// /// Server support contact and support page of a homeserver's domain. diff --git a/src/api/router.rs b/src/api/router.rs index 0e358e8c..ed872b2f 100644 --- a/src/api/router.rs +++ b/src/api/router.rs @@ -184,6 +184,14 @@ pub fn build(router: Router, server: &Server) -> Router { .ruma_route(&client::put_suspended_status) .ruma_route(&client::well_known_support) .ruma_route(&client::well_known_client) + .route( + "/_matrix/client/v1/rtc/transports", + get(client::get_rtc_transports), + ) + .route( + "/_matrix/client/unstable/org.matrix.msc4143/rtc/transports", + get(client::get_rtc_transports), + ) .route("/_conduwuit/server_version", get(client::conduwuit_server_version)) .route("/_continuwuity/server_version", get(client::conduwuit_server_version)) .ruma_route(&client::room_initial_sync_route) diff --git a/src/core/config/mod.rs b/src/core/config/mod.rs index 272873ef..acde104d 100644 --- a/src/core/config/mod.rs +++ b/src/core/config/mod.rs @@ -2080,6 +2080,12 @@ pub struct Config { /// display: nested #[serde(default)] pub blurhashing: BlurhashConfig, + + /// Configuration for MatrixRTC (MSC4143) transport discovery. + /// display: nested + #[serde(default)] + pub matrix_rtc: MatrixRtcConfig, + #[serde(flatten)] #[allow(clippy::zero_sized_map_values)] // this is a catchall, the map shouldn't be zero at runtime @@ -2144,19 +2150,6 @@ pub struct WellKnownConfig { /// If no email or mxid is specified, all of the server's admins will be /// listed. pub support_mxid: Option, - - /// A list of MatrixRTC foci URLs which will be served as part of the - /// MSC4143 client endpoint at /.well-known/matrix/client. If you're - /// setting up livekit, you'd want something like: - /// rtc_focus_server_urls = [ - /// { type = "livekit", livekit_service_url = "https://livekit.example.com" }, - /// ] - /// - /// To disable, set this to be an empty vector (`[]`). - /// - /// default: [] - #[serde(default = "default_rtc_focus_urls")] - pub rtc_focus_server_urls: Vec, } #[derive(Clone, Copy, Debug, Deserialize, Default)] @@ -2184,6 +2177,27 @@ pub struct BlurhashConfig { pub blurhash_max_raw_size: u64, } +#[derive(Clone, Debug, Deserialize, Default)] +#[config_example_generator(filename = "conduwuit-example.toml", section = "global.matrix_rtc")] +pub struct MatrixRtcConfig { + /// A list of MatrixRTC foci (transports) which will be served via the + /// MSC4143 RTC transports endpoint at + /// `/_matrix/client/v1/rtc/transports`. If you're setting up livekit, + /// you'd want something like: + /// ```toml + /// [global.matrix_rtc] + /// foci = [ + /// { type = "livekit", livekit_service_url = "https://livekit.example.com" }, + /// ] + /// ``` + /// + /// To disable, set this to an empty list (`[]`). + /// + /// default: [] + #[serde(default)] + pub foci: Vec, +} + #[derive(Clone, Debug, Default, Deserialize)] #[config_example_generator(filename = "conduwuit-example.toml", section = "global.ldap")] pub struct LdapConfig { @@ -2660,9 +2674,6 @@ fn default_rocksdb_stats_level() -> u8 { 1 } #[inline] pub fn default_default_room_version() -> RoomVersionId { RoomVersionId::V11 } -#[must_use] -pub fn default_rtc_focus_urls() -> Vec { vec![] } - fn default_ip_range_denylist() -> Vec { vec![ "127.0.0.0/8".to_owned(),