Compare commits

...
Author SHA1 Message Date
Ginger d312cbd7f9 feat: Enable unauthenticated rendezvous by default 2026-11-13 18:01:10 +00:00
Ginger 10cc025dca fix: Properly save rendezvous sequence token 2026-11-13 18:01:10 +00:00
Ginger c308b29afa chore: Add doc comments 2026-11-13 18:01:10 +00:00
Ginger 04fd44b94b chore: News fragment 2026-11-13 18:01:10 +00:00
Ginger aa85d3b470 fix: Be more lenient with allowed characters in device ID scopes 2026-11-13 18:01:10 +00:00
Ginger 0c266c28f6 feat: Add support for MSC4388 2026-11-13 18:01:10 +00:00
Erwan Leboucher 77e8a6b41b fix(membership): Return the local join error when there are no remote servers to try 2026-11-13 16:57:29 +01:00
Erwan Leboucher 4ebcf299e2 fix: Refetch OIDC signing keys on unknown key id 2026-11-13 06:22:35 +00:00
Erwan Leboucher c72156cb04 fix: Keep one account data entry per type when updates race
Signed-off-by: Erwan Leboucher <erwanleboucher@gmail.com>
2026-11-13 06:21:54 +00:00
ginger b5594c3061 fix: I am god's most intelligent catgirl 2026-11-13 03:35:10 +00:00
ginger ae0a2d1797 Return 404 instead of 403 for summaries of missing rooms 2026-11-13 03:32:50 +00:00
theS1LV3R 5d0dc8b137 chore: Update variable name, improve doc comment 2026-11-12 14:26:17 +00:00
theS1LV3R 4d271a5621 chore: stupid fucking rustrover 2026-11-12 14:26:17 +00:00
theS1LV3R 23a51bcf96 fix: Set initial backoff time to 90 days immediately
As per the MSC:
> This MSC recommends homeservers should wait a minimum of 24 hours
> and should wait no longer than 90 days, balancing the need to respect
> the server's intent to be offline whilst allowing for potential future
> changes in server operation or domain ownership.

And as per nex:
> Technically the MSC said it should be up to 90 days, but they'll never
> make me parse cache-control!
2026-11-12 14:26:17 +00:00
theS1LV3R 326348ec1a chore: Changelog 2026-11-12 14:26:17 +00:00
theS1LV3R 4f63edac33 feat: Support marking servers as unhealthy+stale during resolution
For when the server resolution process returns an error or Gone
2026-11-12 14:26:17 +00:00
theS1LV3R 79a2cbc7be chore: Enable unstable-msc4188 in resolvematrix 2026-11-12 14:26:17 +00:00
Renovate Bot c8d87b3a0d chore(deps): update dependency cargo-bins/cargo-binstall to v1.27.0 2026-11-12 14:24:16 +00:00
Renovate Bot 49171ec1ed chore(deps): update node-patch-updates to v2.1.2 2026-11-12 05:03:29 +00:00
Erwan Leboucher ea3beb628a chore: regenerate env 2026-11-11 23:34:51 +01:00
Erwan Leboucher 8603ae21cc fix: Address redacted content review nitpicks 2026-11-11 21:52:50 +00:00
Erwan Leboucher f154ecb542 feat: Expire retained unredacted content and address review 2026-11-11 21:52:50 +00:00
Erwan Leboucher 98fe280de4 feat: Allow room moderators to view redacted event content (MSC2815) 2026-11-11 21:52:50 +00:00
Erwan Leboucher 2c605151eb fix: Don't apply get_missing_events limit to earliest_events 2026-11-11 21:51:52 +00:00
timedout 4bd09a6d88 fix: Find some zen
Non-successful media responses get the `application/json` treatment, and the content-type is lowercased for case-insensitive matching, per RFC something or other I forgot already
2026-11-11 21:42:37 +00:00
timedout cb37a9cf0b feat: Assert content type on federation responses 2026-11-11 21:42:37 +00:00
Erwan Leboucher aefededfc8 test: Skip system CA roots in state_at_incoming test services 2026-11-11 21:31:39 +00:00
Erwan Leboucher 9be45212f1 fix: Don't require resolv.conf when dns_servers is configured 2026-11-11 21:31:39 +00:00
theS1LV3R fca19a983d chore: Update resolvematrix to 1.4.1
Also includes other updates cuz thats what cargo does
2026-11-11 18:26:25 +01:00
Renovate Bot 4ebf44412c chore(deps): update ghcr.io/renovatebot/renovate docker tag to v44.227.4 2026-11-11 14:31:22 +00:00
Renovate Bot cacf6ff912 chore(deps): update rust crate syn to v3.0.10 2026-11-11 14:30:59 +00:00
Henry-Hiles aef031c9d7 fix(sync): Give each sliding sync response its own pos 2026-11-11 14:28:43 +00:00
Henry-Hiles 7b927196a2 chore: Use up-to-date Ruma
Some changes to sticky events were needed for this also.
2026-11-11 14:28:43 +00:00
Renovate Bot 93173313ea chore(deps): update pre-commit hook crate-ci/typos to v1.52.2 2026-11-11 05:08:21 +00:00
Jade Ellis 38fb7897bb chore: Release 2026-11-10 23:23:41 +00:00
stratself ba0ea752a9 docs(generic): Recommend the MTRNord tester 2026-11-10 23:12:53 +00:00
stratself c7c54f880a docs(arch): Link to AUR/archlinuxcn instructions 2026-11-10 23:12:53 +00:00
stratself c65eb6de91 docs(push): Update some things (see commit comments)
* Make "gateway discovery" test from both client and server
* Add docker caveat to locally-hosted push components
* Edit a name to match author
2026-11-10 23:12:53 +00:00
stratself 596f269a90 docs(performance): Update trusted servers tuning info 2026-11-10 23:12:53 +00:00
stratself 49ebbcc63e fix(docs): Don't say "check Maintenance for Maintenance" 2026-11-10 23:12:53 +00:00
stratself 7241150204 docs(arch-linux): Add some wordings
Ideally want the installation commands here, but will leave for a future
commit
2026-11-10 23:12:53 +00:00
stratself c66a863bb2 docs(kubernetes): Small wording improvements and postinstall section 2026-11-10 23:12:53 +00:00
stratself 6dbe40238d docs(nixos): Beautify nix a bit
* Add well-known config example to nixfile
* Add postinstall redirect section
2026-11-10 23:12:53 +00:00
stratself 77bc7476f3 docs(auth): Reword registration defaults 2026-11-10 23:12:53 +00:00
stratself 94270e732c docs(livekit): Address review comments, add note for EC's dev mode 2026-11-10 23:00:08 +00:00
stratself 0bc55cb590 docs(livekit): Use "MatrixRTC" phrasing in lieu of "Element Call"
The calling protocol matters not the client product
2026-11-10 23:00:08 +00:00
stratself 0375643ade docs(livekit): Add stun_servers to TURN instructions too 2026-11-10 23:00:08 +00:00
stratself c67f08a208 docs(livekit): Add appendix sectionon creating livekit tokens via livekit-cli 2026-11-10 23:00:08 +00:00
stratself fb3113ea69 docs(livekit): Add appendix section on calling modes 2026-11-10 23:00:08 +00:00
stratself 6f6fba4310 docs(livekit): Pin token exchange flow link to jwt-svc 0.6.0 2026-11-10 23:00:08 +00:00
stratself 9ace03c107 docs(livekit): Add more relevant MSCs 2026-11-10 23:00:08 +00:00
stratself 304bf69c32 docs(livekit): Add LiveKit advertised IP addresses restrictions 2026-11-10 23:00:08 +00:00
stratself 2173577bac docs(livekit): Update Element Call UI errors 2026-11-10 23:00:08 +00:00
stratself bbf3bd1294 docs(calls): Small fixup of wordings
* Use indirect links and fix them
* Make Livekit's TURN configuration optional
2026-11-10 23:00:08 +00:00
stratself dd11fc5a25 docs(livekit): Remove workaround for non-federating servers
Fixed by #2326
2026-11-10 23:00:08 +00:00
stratself f1798c004a docs(calls): Redirect to support room 2026-11-10 23:00:08 +00:00
Erwan Leboucher b570420b9f fix: preserve predecessors sharing a state-before ID
Signed-off-by: Erwan Leboucher <erwanleboucher@gmail.com>
2026-11-10 23:56:33 +01:00
69 changed files with 1632 additions and 425 deletions

No files matched your search

+1 -1
View File
@@ -43,7 +43,7 @@ jobs:
name: Renovate
runs-on: ubuntu-latest
container:
image: ghcr.io/renovatebot/renovate:44.210.1@sha256:45cc73346c44a9afe037f2d19766f2b545b59b2ed31b937b5b09017d2958e45f
image: ghcr.io/renovatebot/renovate:44.227.4@sha256:e09d40686f73d43b2c1e4667cb47d3c1d24a6ac730b74ce7aced9c84f68594f1
options: --tmpfs /tmp:exec
steps:
- name: Checkout
+1 -1
View File
@@ -24,7 +24,7 @@ repos:
- id: check-added-large-files
- repo: https://github.com/crate-ci/typos
rev: v1.51.1
rev: v1.52.2
hooks:
- id: typos
- id: typos
+70
View File
@@ -1,3 +1,73 @@
# Continuwuity v26.11.0-alpha.1 (2026-11-10)
## Features
- Added opt-in OpenTelemetry metrics, exported over OTLP or scraped by Prometheus from `/_continuwuity/metrics`, and a Grafana dashboard. Contributed by @eleboucher. (prometheus-metrics)
- Add support for using custom DNS servers instead of using /etc/resolv.conf. Contributed by @s1lv3r. ([#2056](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2056))
- Continuwuity now supports configuring additional trusted audience values for deployments using OIDC with an IDP that sends them. Contributed by @ginger ([#2226](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2226))
- "!admin users list" now hides deactivated users by default, but can display them with the optional "--show-deactivated" flag. "--hide-suspended" and "--hide-locked" have been added as well, which stop suspended and locked users from being displayed respectively. Contributed by @Clubs. ([#2292](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2292))
- Added support for [MSC4494: Membership-based invite blocking](https://github.com/matrix-org/matrix-spec-proposals/pull/4494) ([#2297](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2297))
- Appservices now receive typing indicators and read receipts. Contributed by @Jade ([#2327](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2327))
- Added support for [MSC4363](https://github.com/matrix-org/matrix-spec-proposals/pull/4363) (OAuth step-up authentication). Contributed by @ginger.
- Added support for [MSC4484](https://github.com/matrix-org/matrix-spec-proposals/pull/4484). Clients which use the built-in Matrix server administration APIs will need to ask for the appropriate scope when signing in with OAuth. Contributed by @ginger.
- Implemented unstable support for [MSC4560] (Stripped state requests over federation). Contributed by @ginger.
[MSC4560]: https://github.com/matrix-org/matrix-spec-proposals/pull/4560
- Profile banners are now treated as images when imported from OIDC claims, like avatars already were.
- The first-run version of the web UI now includes a link to the registration page. Contributed by @ginger
## Bugfixes
- Invitees are now added as room creators when creating a v12+ trusted private chat. Contributed by @ginger. ([#2162](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2162))
- Fixed push gateway URLs containing the configured notification path outside of their suffix. Contributed by @eleboucher. ([#2261](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2261))
- "!admin users change-email" now verifies a user exists before attempting to change their email. Contributed by @Clubs. ([#2298](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2298))
- Fixed URL preview image MIME types and rejected failed downloads. Contributed by @eleboucher. ([#2308](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2308))
- Correctly set RocksDB column options, including enabling block caches. Contributed by @Jade ([#2345](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2345))
- Fix some possible deadlocks/freezes and reduce lock contention (improving performance). Contributed by @Jade ([#2351](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2351))
- Once again fixed how room extremities are handled, fixing a problem that made continuwuity gradually make rooms needlessly complex, which also caused more frequent state resets. ([#2356](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2356))
- The OAuth identity reset page is no longer linked from the account management UI to reduce confusion. Contributed by @ginger. ([#2383](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2383))
- Fixed a worker panic when knocking on a room over federation. Contributed by @eleboucher. ([#2387](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2387))
- Perform more validation on events received during atomic gapfill from remote servers, fixing a panic if bad data was persisted by another server and later lazily fetched by us. ([#2400](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2400))
- Redirect URIs in OAuth clients' metadata are now properly validated to be on a subdomain of the OAuth issuer URL domain. Contributed by @ginger. ([#2421](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2421))
- Fix v12 rooms created by the same user in the same millisecond ending up as the same room. Contributed by @eleboucher. ([#2424](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2424))
- Client-server API endpoints are now properly ratelimited for unauthenticated requests. Contributed by @ginger. ([#2444](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2444))
- Setting a profile key longer than 255 bytes now returns 400 `M_KEY_TOO_LARGE` as required by the spec, instead of 413 `M_TOO_LARGE`. ([#2451](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2451))
- Setting `m.fully_read` via the account data endpoints now returns 405 `M_BAD_JSON` as required by the spec, instead of 400. ([#2451](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2451))
- Appservices masquerading as a device that does not exist now receive 400 `M_UNKNOWN_DEVICE` as required by the spec, instead of 403 `M_FORBIDDEN`. ([#2451](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2451))
- Setting profile data that would make the profile exceed 64 KiB now returns 400 `M_PROFILE_TOO_LARGE` as required by the spec, instead of a 500 error. ([#2451](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2451))
- The `m.forget_forced_upon_leave` capability now reflects the `forget_forced_upon_leave` config option instead of always being advertised as enabled. ([#2452](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2452))
- Fixed push notifications for membership events setting `user_is_target` based on the sender rather than the user being notified. ([#2454](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2454))
- Ensure HTTP clients actually follow the `dns_servers` config option. Contributed by @silversys ([#2460](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2460))
- Reworked event relations to follow the spec more closely. Pagination of `/relations` now returns the correct pages and `next_batch` tokens, recursive relations are returned in the right order without duplicates, and bundled `m.reference` aggregations now include every reference. Contributed by @Henry-Hiles (QuadRadical). ([#2465](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2465))
- Read receipts are now more spec compliant, will work better in threads and are less likely to end up causing loops with other software. Contributed by @Jade ([#2481](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2481))
- Fix gap filling skipping outlier events that are missing their previous events. Contributed by @eleboucher.
- Fix incoming federation events losing state changes when predecessors share the same state-before snapshot. Contributed by @eleboucher.
- Fix new devices sometimes never reaching other users' device lists. Contributed by @eleboucher.
- Fix state resolution applying events out of order, which could undo room joins. Contributed by @eleboucher.
- Fix to-device messages, including room keys, sometimes being lost before delivery. Contributed by @eleboucher.
- For deployments using OIDC with `profile_key_import_mode` set to `on_login`, users' avatars will no longer be clobbered if they didn't change their avatar since their last login.
- Room summary visibility checks are no longer incorrectly applied for remote rooms. Contributed by @ginger.
- The userinfo endpoint is now accessible even if federation is disabled, allowing LiveKit to be used on servers with federation disabled without using the server name whitelist.
- `!admin token issue` can no longer issue registration tokens when `allow_registration` is false. Contributed by @Clubs.
## Improved Documentation
- Add the Authentication section to document available auth methods for Continuwuity. The "delegated authentication" guide has also been migrated to here. Contributed by @stratself. ([#2234](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2234))
- Add a guide for push notifications, detailing how it works, push gateway specifics, troubleshooting common issues, and pointing to external guides for UnifiedPush backends. Contributed by @stratself ([#2244](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2244))
- The deploying page now includes vital general information about installing Continuwuity: release tracks, update steps, and post-installation recommendations. Contributed by @stratself ([#2252](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2252))
- Add some missing instructions on configuring Continuwuity on the RPM page. Users are encouraged to use the [generic deploying docs](https://continuwuity.org/deploying/generic) for the bulk of guidance anyhow. Contributed by @stratself ([#2275](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2275))
- Better, more succinct [introduction page](https://continuwuity.org/introduction.html). Contributed by @stratself ([#2279](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2279))
- Add a section on [troubleshooting Docker issues](https://continuwuity.org/troubleshooting#docker-issues). Contributed by @stratself. ([#2324](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2324))
- Instructions for Authelia added to the [OIDC guide](https://continuwuity.org/authentication/oidc.html). Contributed by @fhoekstra ([#2341](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2341))
- Docker compose examples now use bind mounts by default, instead of Docker volumes, as they are easier to work with esp. for backup/restore. Contributed by @stratself. ([#2353](https://forgejo.ellis.link/continuwuation/continuwuity/pulls/2353))
- The documentation now refers to the Continuwuity Docker service as `continuwuity` instead of `homeserver`.
## Misc
- Updated internal Sentry integration setup to the new pattern required by the SDK. #2423
- Upgraded rocksdb from 11.1.1 to 11.12.0 and jemalloc to 5.4.0.
# Continuwuity v26.9.1 (2026-09-28)
## Features
Generated
+52 -50
View File
@@ -193,7 +193,7 @@ dependencies = [
"rustc-hash",
"serde",
"serde_derive",
"syn 3.0.9",
"syn 3.0.10",
]
[[package]]
@@ -255,7 +255,7 @@ checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.9",
"syn 3.0.10",
]
[[package]]
@@ -497,7 +497,7 @@ dependencies = [
"regex",
"rustc-hash",
"shlex",
"syn 3.0.9",
"syn 3.0.10",
]
[[package]]
@@ -785,7 +785,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote",
"syn 3.0.9",
"syn 3.0.10",
]
[[package]]
@@ -865,7 +865,7 @@ dependencies = [
[[package]]
name = "conduwuit"
version = "26.9.1"
version = "26.11.0-alpha.1"
dependencies = [
"clap",
"conduwuit_build_metadata",
@@ -897,7 +897,7 @@ dependencies = [
[[package]]
name = "conduwuit_admin"
version = "26.9.1"
version = "26.11.0-alpha.1"
dependencies = [
"clap",
"conduwuit_api",
@@ -921,7 +921,7 @@ dependencies = [
[[package]]
name = "conduwuit_api"
version = "26.9.1"
version = "26.11.0-alpha.1"
dependencies = [
"axum",
"base64 0.23.1",
@@ -953,7 +953,7 @@ dependencies = [
[[package]]
name = "conduwuit_build_metadata"
version = "26.9.1"
version = "26.11.0-alpha.1"
dependencies = [
"built",
"cargo_metadata",
@@ -961,7 +961,7 @@ dependencies = [
[[package]]
name = "conduwuit_core"
version = "26.9.1"
version = "26.11.0-alpha.1"
dependencies = [
"argon2",
"arrayvec",
@@ -1031,7 +1031,7 @@ dependencies = [
[[package]]
name = "conduwuit_database"
version = "26.9.1"
version = "26.11.0-alpha.1"
dependencies = [
"async-channel",
"conduwuit_core",
@@ -1051,17 +1051,17 @@ dependencies = [
[[package]]
name = "conduwuit_macros"
version = "26.9.1"
version = "26.11.0-alpha.1"
dependencies = [
"itertools 0.15.0",
"proc-macro2",
"quote",
"syn 3.0.9",
"syn 3.0.10",
]
[[package]]
name = "conduwuit_router"
version = "26.9.1"
version = "26.11.0-alpha.1"
dependencies = [
"axum",
"axum-server",
@@ -1094,7 +1094,7 @@ dependencies = [
[[package]]
name = "conduwuit_service"
version = "26.9.1"
version = "26.11.0-alpha.1"
dependencies = [
"askama",
"assign",
@@ -1122,6 +1122,7 @@ dependencies = [
"lru-cache",
"nonzero_ext",
"openidconnect",
"opentelemetry",
"p256 0.14.0",
"rand 0.10.3",
"regex",
@@ -1130,6 +1131,7 @@ dependencies = [
"resolvematrix",
"ruma",
"ruminuwuity",
"rustls",
"rustyline-async",
"sd-notify",
"serde",
@@ -1148,7 +1150,7 @@ dependencies = [
[[package]]
name = "conduwuit_web"
version = "26.9.1"
version = "26.11.0-alpha.1"
dependencies = [
"askama",
"async-trait",
@@ -1377,7 +1379,7 @@ dependencies = [
"proc-macro2",
"quote",
"strict",
"syn 3.0.9",
"syn 3.0.10",
]
[[package]]
@@ -1619,7 +1621,7 @@ dependencies = [
"proc-macro2",
"quote",
"strsim",
"syn 3.0.9",
"syn 3.0.10",
]
[[package]]
@@ -1641,7 +1643,7 @@ checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785"
dependencies = [
"darling_core 0.24.1",
"quote",
"syn 3.0.9",
"syn 3.0.10",
]
[[package]]
@@ -1761,7 +1763,7 @@ checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.9",
"syn 3.0.10",
]
[[package]]
@@ -2167,7 +2169,7 @@ checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.9",
"syn 3.0.10",
]
[[package]]
@@ -3172,7 +3174,7 @@ dependencies = [
"proc-macro2",
"quote",
"regex",
"syn 3.0.9",
"syn 3.0.10",
]
[[package]]
@@ -4476,7 +4478,7 @@ dependencies = [
"proc-macro-error-attr3",
"proc-macro2",
"quote",
"syn 3.0.9",
"syn 3.0.10",
]
[[package]]
@@ -4773,7 +4775,7 @@ checksum = "92ecd8964f8453721699a1ed72037b0db49ce2f5a5138486ee89bed6f67cdf3a"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.9",
"syn 3.0.10",
]
[[package]]
@@ -4895,9 +4897,9 @@ checksum = "1e061d1b48cb8d38042de4ae0a7a6401009d6143dc80d2e2d6f31f0bdd6470c7"
[[package]]
name = "resolvematrix"
version = "1.4.0"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e7767f4eb1d58880d6b33135a6c098cc8fbccecb259a833b44448c0de144dac"
checksum = "565260441c783e26272b2d879525e80e97552e851fffa723cb0cfe0a3c46df92"
dependencies = [
"hickory-resolver",
"num-traits",
@@ -4967,7 +4969,7 @@ dependencies = [
[[package]]
name = "ruma"
version = "0.17.2"
source = "git+https://github.com/ruma/ruma.git?rev=0ed7fba34213f18a628a56f527c6cc795cd7eef5#0ed7fba34213f18a628a56f527c6cc795cd7eef5"
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
dependencies = [
"assign",
"js_int",
@@ -4986,7 +4988,7 @@ dependencies = [
[[package]]
name = "ruma-appservice-api"
version = "0.17.1"
source = "git+https://github.com/ruma/ruma.git?rev=0ed7fba34213f18a628a56f527c6cc795cd7eef5#0ed7fba34213f18a628a56f527c6cc795cd7eef5"
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
dependencies = [
"http",
"js_int",
@@ -4999,7 +5001,7 @@ dependencies = [
[[package]]
name = "ruma-client-api"
version = "0.25.2"
source = "git+https://github.com/ruma/ruma.git?rev=0ed7fba34213f18a628a56f527c6cc795cd7eef5#0ed7fba34213f18a628a56f527c6cc795cd7eef5"
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
dependencies = [
"as_variant",
"assign",
@@ -5021,7 +5023,7 @@ dependencies = [
[[package]]
name = "ruma-common"
version = "0.20.2"
source = "git+https://github.com/ruma/ruma.git?rev=0ed7fba34213f18a628a56f527c6cc795cd7eef5#0ed7fba34213f18a628a56f527c6cc795cd7eef5"
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
dependencies = [
"as_variant",
"base64 0.23.1",
@@ -5054,7 +5056,7 @@ dependencies = [
[[package]]
name = "ruma-events"
version = "0.35.2"
source = "git+https://github.com/ruma/ruma.git?rev=0ed7fba34213f18a628a56f527c6cc795cd7eef5#0ed7fba34213f18a628a56f527c6cc795cd7eef5"
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
dependencies = [
"as_variant",
"indexmap 2.14.2",
@@ -5075,7 +5077,7 @@ dependencies = [
[[package]]
name = "ruma-federation-api"
version = "0.16.1"
source = "git+https://github.com/ruma/ruma.git?rev=0ed7fba34213f18a628a56f527c6cc795cd7eef5#0ed7fba34213f18a628a56f527c6cc795cd7eef5"
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
dependencies = [
"bytes",
"http",
@@ -5097,7 +5099,7 @@ dependencies = [
[[package]]
name = "ruma-identifiers-validation"
version = "0.14.0"
source = "git+https://github.com/ruma/ruma.git?rev=0ed7fba34213f18a628a56f527c6cc795cd7eef5#0ed7fba34213f18a628a56f527c6cc795cd7eef5"
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
dependencies = [
"js_int",
"thiserror 2.0.21",
@@ -5106,7 +5108,7 @@ dependencies = [
[[package]]
name = "ruma-macros"
version = "0.20.2"
source = "git+https://github.com/ruma/ruma.git?rev=0ed7fba34213f18a628a56f527c6cc795cd7eef5#0ed7fba34213f18a628a56f527c6cc795cd7eef5"
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
dependencies = [
"as_variant",
"cfg-if",
@@ -5115,14 +5117,14 @@ dependencies = [
"quote",
"ruma-identifiers-validation",
"serde",
"syn 3.0.9",
"syn 3.0.10",
"toml 1.2.1+spec-1.1.0",
]
[[package]]
name = "ruma-push-gateway-api"
version = "0.16.0"
source = "git+https://github.com/ruma/ruma.git?rev=0ed7fba34213f18a628a56f527c6cc795cd7eef5#0ed7fba34213f18a628a56f527c6cc795cd7eef5"
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
dependencies = [
"js_int",
"ruma-common",
@@ -5134,7 +5136,7 @@ dependencies = [
[[package]]
name = "ruma-signatures"
version = "0.22.1"
source = "git+https://github.com/ruma/ruma.git?rev=0ed7fba34213f18a628a56f527c6cc795cd7eef5#0ed7fba34213f18a628a56f527c6cc795cd7eef5"
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
dependencies = [
"base64 0.23.1",
"ed25519-dalek",
@@ -5151,7 +5153,7 @@ dependencies = [
[[package]]
name = "ruma-state-res"
version = "0.18.0"
source = "git+https://github.com/ruma/ruma.git?rev=0ed7fba34213f18a628a56f527c6cc795cd7eef5#0ed7fba34213f18a628a56f527c6cc795cd7eef5"
source = "git+https://github.com/ruma/ruma.git?rev=472a23ef86bc0bb40a22d856fc0af539eb9d71b7#472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
dependencies = [
"js_int",
"ruma-common",
@@ -5165,7 +5167,7 @@ dependencies = [
[[package]]
name = "ruminuwuity"
version = "26.9.1"
version = "26.11.0-alpha.1"
dependencies = [
"assign",
"http",
@@ -5660,7 +5662,7 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.9",
"syn 3.0.10",
]
[[package]]
@@ -5779,7 +5781,7 @@ dependencies = [
"darling 0.24.1",
"proc-macro2",
"quote",
"syn 3.0.9",
"syn 3.0.10",
]
[[package]]
@@ -6075,9 +6077,9 @@ dependencies = [
[[package]]
name = "syn"
version = "3.0.9"
version = "3.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
dependencies = [
"proc-macro2",
"quote",
@@ -6101,7 +6103,7 @@ checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.9",
"syn 3.0.10",
]
[[package]]
@@ -6203,7 +6205,7 @@ checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.9",
"syn 3.0.10",
]
[[package]]
@@ -6313,7 +6315,7 @@ checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.9",
"syn 3.0.10",
]
[[package]]
@@ -7001,7 +7003,7 @@ dependencies = [
"bumpalo",
"proc-macro2",
"quote",
"syn 3.0.9",
"syn 3.0.10",
"wasm-bindgen-shared",
]
@@ -7349,7 +7351,7 @@ dependencies = [
[[package]]
name = "xtask"
version = "26.9.1"
version = "26.11.0-alpha.1"
dependencies = [
"askama",
"cargo_metadata",
@@ -7382,7 +7384,7 @@ checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.9",
"syn 3.0.10",
"synstructure",
]
@@ -7423,7 +7425,7 @@ checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.9",
"syn 3.0.10",
"synstructure",
]
@@ -7463,7 +7465,7 @@ checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.9",
"syn 3.0.10",
]
[[package]]
+5 -3
View File
@@ -12,7 +12,7 @@ license = "Apache-2.0"
# See also `rust-toolchain.toml`
readme = "README.md"
repository = "https://forgejo.ellis.link/continuwuation/continuwuity"
version = "26.9.1"
version = "26.11.0-alpha.1"
[workspace.metadata.crane]
name = "conduwuit"
@@ -357,7 +357,7 @@ version = "1.1.1"
# Used for matrix spec type definitions and helpers
[workspace.dependencies.ruma]
git = "https://github.com/ruma/ruma.git"
rev = "0ed7fba34213f18a628a56f527c6cc795cd7eef5"
rev = "472a23ef86bc0bb40a22d856fc0af539eb9d71b7"
features = [
"appservice-api-c",
"client-api",
@@ -392,6 +392,7 @@ features = [
"unstable-msc4406",
"unstable-msc4439",
"unstable-msc4354",
"unstable-msc4388",
"unstable-msc4480",
"unstable-msc4466",
"unstable-msc4494",
@@ -600,7 +601,8 @@ features = ["std"]
version = "0.3.0"
[workspace.dependencies.resolvematrix]
version = "1.4.0"
version = "1.4.1"
features = ["unstable-msc4188"]
[workspace.dependencies.serde_urlencoded]
version = "0.7.1"
+1
View File
@@ -0,0 +1 @@
Check content-type header on federation responses, ignoring any that don't match (spec compliance)
@@ -0,0 +1 @@
Fix account data updates sent at the same time leaving old copies behind, which every initial sync then returned. Existing copies are removed on startup. Contributed by @eleboucher.
@@ -0,0 +1 @@
Joining a local room the user is not allowed to join now returns `403 M_FORBIDDEN` instead of `500 M_UNKNOWN` when there are no other servers to try.
@@ -0,0 +1 @@
Added support for [MSC2815](https://github.com/matrix-org/matrix-spec-proposals/pull/2815), allowing room moderators to fetch the original content of redacted events, behind the `allow_moderators_to_view_redacted_content` config option. Contributed by @eleboucher.
@@ -0,0 +1 @@
Fix incoming federation events losing state changes when predecessors share the same state-before snapshot. Contributed by @eleboucher.
+1
View File
@@ -0,0 +1 @@
Added support for servers returning 410 gone to indicate they are no longer serving a Matrix server (MSC4188). Contributed by @nex and @silversys
+1
View File
@@ -0,0 +1 @@
Added support for MSC4388, allowing compatible Matrix clients to log in to Continuwuity by scanning a QR code on an already logged-in client. Contributed by @ginger.
+1
View File
@@ -0,0 +1 @@
Fix the DNS resolver failing to start without `/etc/resolv.conf` when `dns_servers` is configured. Contributed by @eleboucher.
+1
View File
@@ -0,0 +1 @@
Fixed OIDC logins failing after the identity provider rotates its signing keys. Contributed by @eleboucher.
@@ -0,0 +1 @@
Fixed `/get_missing_events` rejecting requests with more `earliest_events` than the `limit`. Contributed by @eleboucher.
+40 -4
View File
@@ -812,15 +812,32 @@
# env: CONTINUWUITY_FORGET_FORCED_UPON_LEAVE
#forget_forced_upon_leave = false
# Set this to true to require authentication on the normally
# unauthenticated profile retrieval endpoints (GET)
# "/_matrix/client/v3/profile/{userId}".
# Set this to true to require authentication when looking up user profiles
# through this server.
#
# This can prevent profile scraping.
# By default this is false, allowing tools such as matrix.to to access
# profiles of users on this server and on other servers.
# Setting this to true will block those tools, and may block automated
# crawlers from scraping users' profiles, although it will not block
# other homeservers from accessing users' profiles.
#
# env: CONTINUWUITY_REQUIRE_AUTH_FOR_PROFILE_REQUESTS
#require_auth_for_profile_requests = false
# Set this to true to require authentication to create a rendezvous
# session. Rendezvous sessions are used for QR code login.
#
# For QR code login, the device that shows the QR code is the one that
# creates the rendezvous session. Therefore, this must be false to let
# a logged-out device show a QR code.
#
# By default this is false, allowing logged-out desktop devices (which may
# not have a camera) to show a QR code. Setting this to true will
# require logged-out devices to scan the QR code instead.
#
# env: CONTINUWUITY_REQUIRE_AUTH_FOR_RENDEZVOUS
#require_auth_for_rendezvous = true
# Set this to true to allow your server's public room directory to be
# federated. Set this to false to protect against /publicRooms spiders,
# but will forbid external users from viewing your server's public room
@@ -1664,6 +1681,25 @@
# env: CONTINUWUITY_ALLOW_STICKY_EVENTS
#allow_sticky_events = false
# Allow room moderators to view redacted event content ([MSC2815]).
#
# Redacted content is readable by users at or above the room's `redact`
# power level, and by server admins, until it expires.
#
# MSC2815: https://github.com/matrix-org/matrix-spec-proposals/pull/2815
#
# env: CONTINUWUITY_ALLOW_MODERATORS_TO_VIEW_REDACTED_CONTENT
#allow_moderators_to_view_redacted_content = false
# How long to retain the content of redacted events, in seconds. Expired
# content is deleted by a periodic purge and is no longer served.
#
# Only has an effect when allow_moderators_to_view_redacted_content is
# enabled.
#
# env: CONTINUWUITY_UNREDACTED_CONTENT_MAX_AGE_SECS
#unredacted_content_max_age_secs = 7776000 (90 days)
# Maximum time federation user can indicate typing.
#
# env: CONTINUWUITY_TYPING_FEDERATION_TIMEOUT_S
+1 -1
View File
@@ -50,7 +50,7 @@ EOF
# Developer tool versions
# renovate: datasource=github-releases depName=cargo-bins/cargo-binstall
ENV BINSTALL_VERSION=1.26.2
ENV BINSTALL_VERSION=1.27.0
# renovate: datasource=github-releases depName=psastras/sbom-rs
ENV CARGO_SBOM_VERSION=0.9.1
# renovate: datasource=crate depName=lddtree
+1 -1
View File
@@ -18,7 +18,7 @@ RUN --mount=type=cache,target=/etc/apk/cache apk add \
# Developer tool versions
# renovate: datasource=github-releases depName=cargo-bins/cargo-binstall
ENV BINSTALL_VERSION=1.26.2
ENV BINSTALL_VERSION=1.27.0
# renovate: datasource=github-releases depName=psastras/sbom-rs
ENV CARGO_SBOM_VERSION=0.9.1
# renovate: datasource=crate depName=lddtree
+3 -1
View File
@@ -4,7 +4,7 @@ Continuwuity comes with an internal database for user authentication, which it u
## Registration
Registration is disabled by default. To enable it, set `allow_registration = true` in your config file and use at least one of the registration methods below.
The following registration methods are available for Continuwuity:
| Method | Description | Additional configuration needed |
| ------ | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
@@ -19,6 +19,8 @@ Admin-issued tokens are the recommended registration method. These tokens are we
Other registration methods are meant for **untrusted, public registration**. Care must be taken when allowing these modes of operation.
If you wish to disable registration entirely, set `allow_registration = false` in your config file.
## Email configuration
Continuwuity can be configured to send emails via an SMTP relay of your choice. These are used for verifying user email addresses and sending password reset links to them.
+9 -5
View File
@@ -2,12 +2,16 @@
Matrix supports two types of calls:
- Element Call powered by [MatrixRTC](https://half-shot.github.io/msc-crafter/#msc/4143) and [LiveKit](https://github.com/livekit/livekit)
- Legacy calls, supported by a STUN/TURN server.
- [MatrixRTC][MSC4143] calls, powered by [LiveKit][livekit-server-github] and frontends such as [Element Call][element-call].
- Legacy 1-to-1 calls, supported by a STUN/TURN server.
Both types of calls are supported by different sets of clients, but most clients are moving towards MatrixRTC / Element Call.
[MSC4143]: https://github.com/matrix-org/matrix-spec-proposals/pull/4143
[element-call-github]: https://github.com/element-hq/element-call/
[livekit-server-github]: https://github.com/livekit/livekit
Both types of calls are supported by different sets of clients, but most clients are moving towards MatrixRTC.
For either one to work correctly, you have to do some additional setup:
- For legacy calls to work, you need to set up a TURN/STUN server. [Read the TURN guide for tips on how to set up coturn](./calls/turn.mdx)
- For MatrixRTC / Element Call to work, you have to set up the LiveKit backend. LiveKit also uses TURN/STUN to increase reliability - you can set up its built-in TURN server, or integrate with an existing one. [Read the LiveKit guide](./calls/livekit.mdx)
- For legacy calls to work, you need to set up a TURN/STUN server. [Read the TURN guide for instructions on how to set up coturn](./calls/turn.mdx)
- For MatrixRTC calls to work, you have to set up the LiveKit backend, and optionally configure a TURN server for increased reliability. [Read the LiveKit guide](./calls/livekit.mdx)
+86 -23
View File
@@ -1,13 +1,15 @@
import { Tab, Tabs} from '@rspress/core/theme';
import { Tab, Tabs } from '@rspress/core/theme';
# MatrixRTC/Element Call Setup
# MatrixRTC/LiveKit Setup
This guide assumes that you are using docker compose for deployment.
This guide assumes that you are using `docker compose` for deployment.
:::tip
You can find help setting up MatrixRTC in our dedicated room - [#matrixrtc:continuwuity.org](https://matrix.to/#/%23matrixrtc%3Acontinuwuity.org)
You can find help setting up MatrixRTC in our support room - [`#continuwuity:continuwuity.org`][support-room]
:::
[support-room]: https://matrix.to/#/%23continuwuity:continuwuity.org
## Instructions
### 1. Set up your domain
@@ -58,7 +60,9 @@ services:
- ./livekit.yaml:/etc/livekit.yaml:ro
network_mode: "host" # /!\ LiveKit binds to all addresses by default.
# Make sure port 7880 is blocked by your firewall to prevent access bypassing your reverse proxy
# Alternatively, uncomment the lines below and comment `network_mode: "host"` above to specify port mappings.
# Alternatively, uncomment the lines below and comment out `network_mode: "host"`
# above to use bridge networking and manually specify port mappings.
# ports:
# - "127.0.0.1:7880:7880/tcp"
# - "7881:7881/tcp"
@@ -218,7 +222,9 @@ Start up the services using your usual method - for example `docker compose up -
## Testing
To test that LiveKit is successfully integrated with Continuwuity, you will need to replicate its [Token Exchange Flow](https://github.com/element-hq/lk-jwt-service#%EF%B8%8F-how-it-works--token-exchange-flow). Follow the steps below while checking Docker logs (`docker compose logs --follow`), in order to help [troubleshooting](#troubleshooting) any issues.
To test that LiveKit is successfully integrated with Continuwuity, you will need to replicate its [Token Exchange Flow][token-exchange-flow]. Follow the steps below while checking Docker logs (`docker compose logs --follow`), in order to help [troubleshooting](#troubleshooting) any issues.
[token-exchange-flow]: https://github.com/element-hq/lk-jwt-service/tree/v0.6.0#%EF%B8%8F-how-it-works--token-exchange-flow
First, you will need an access token for your current login session. These can be found in your client's settings or obtained via [this website][starstruck-mxtoken2].
@@ -279,7 +285,7 @@ You can then send this payload to the lk-jwt-service:
curl -X POST -d @payload.json https://livekit.example.com/get_token
```
The lk-jwt-service will, after checking against Continuwuity, answer with a `jwt` token to create a LiveKit media room:
The lk-jwt-service will, after checking against Continuwuity, answer with a `jwt` token to [create a LiveKit media room](#livekit-cli):
```json
{"url":"wss://livekit.example.com","jwt":"a_really_really_long_string"}
@@ -293,13 +299,20 @@ Use this token to test at the [LiveKit Connection Tester][livekit-connection-tes
To debug any issues, you can place a call or redo the Testing instructions, and check the container logs for any specific errors. Use `docker compose logs --follow` to follow these logs in real-time.
Before debugging, ensure the following prerequisites:
- The user has permissions to send call events into the room. See the Appendix section on [call modes](#call-modes) for more details.
- WebRTC is enabled, if using a browser client.
### Common errors in Element Call UI
- `MISSING_MATRIX_RTC_FOCUS`/`MISSING_MATRIX_RTC_TRANSPORT`: LiveKit is missing from Continuwuity's config file
- "Waiting for media" popup always showing for yourself: a LiveKit URL has been configured in Continuwuity, but your client cannot connect to it for some reason
- `OPEN_ID_ERROR`: Your client can reach out to `lk-jwt-service`, but has problems authenticating with it. In this case, check `lk-jwt-service` logs for more details
- `MISSING_MATRIX_RTC_FOCUS`/`MISSING_MATRIX_RTC_TRANSPORT`: the client cannot find a suitable SFU. This is likely due to LiveKit being missing from Continuwuity's config file, and therefore not being exposed properly.
For browser-based clients, you can also inspect connections using DevTools' Networking tab, to see which requests are erroring out.
- `OPEN_ID_ERROR`: Your client can reach out to `lk-jwt-service`, but `lk-jwt-service` has problems authenticating you against Continuwuity. In this case, check `lk-jwt-service` logs for more details. The section below on [Docker loopback networking issues](#docker-loopback-networking-issues) may be of help.
- Calls fail to start with `ServerUnreachable` error: a LiveKit URL has been properly configured and exposed in Continuwuity, but the client cannot connect to it for some reason.
For browser-based clients, you can inspect connections using DevTools' Networking tab, to see which requests are erroring out. You may also want to toggle on Element Call's Developer tab via _Settings > Preferences > Developer mode_ \- various call details and advanced settings can be further tweaked there.
### Docker loopback networking issues
@@ -312,9 +325,9 @@ docker run --rm --net container:lk-jwt-service docker.io/curlimages/curl https:/
To resolve this, follow the steps in [Docker loopback networking issues](../troubleshooting.mdx#docker-loopback-networking-issues) of the Troubleshooting page.
### Incorrect IP address for LiveKit
### Incorrect IP addresses for LiveKit
By default, LiveKit automatically finds its public IP address(es), which can be seen in the "Establishing WebRTC connection" section of the connection test page. If these IPs are incorrect, you may want to hardcode your own IP by doing the following:
By default, LiveKit automatically finds its public IP address(es), which are reflected in the "Establishing WebRTC connection" section of the connection test page. If these IPs are incorrect, you may want to hardcode your own IP by doing the following:
```diff
### in your livekit.yaml ###
@@ -325,20 +338,21 @@ rtc:
+ node_ip: "1.2.3.4"
```
### Workaround for non-federating servers
Run the LiveKit tests again, and the new updated `node_ip` should be included as one of the candidates.
When deploying on servers with federation disabled (`allow_federation = false`), LiveKit will fail as it can't fetch the required [OpenID endpoint](https://spec.matrix.org/v1.17/server-server-api/#get_matrixfederationv1openiduserinfo) via federation paths.
You may further restrict the advertised address to only the `node_ip` with the following configurations:
As a workaround, you can enable federation, but forbid all remote servers via the following config parameters:
```toml
### in your continuwuity.toml file ###
allow_federation = true
forbidden_remote_server_names = [".*"]
```diff
### in your livekit.yaml ###
rtc:
# ... other configs here ...
+ enable_loopback_candidate: false
+ interfaces:
+ includes: []
+ ips:
+ includes: [ "1.2.3.4/32" ]
```
Subscribe to issue [!1440](https://forgejo.ellis.link/continuwuation/continuwuity/issues/1440) for future updates on this matter.
## Related Documentation
Guides:
@@ -359,9 +373,15 @@ Specifications:
- [MSC4143: MatrixRTC \- Real-time communication over Matrix][MSC4143]
- [MSC4195: MatrixRTC Transport using LiveKit Backend][MSC4195]
- [MSC3401: Native Group VoIP Signalling][MSC3401] - state events for legacy calls
- [MSC4075: MatrixRTC invites and notifications][MSC4075] - for ringing users
- [MSC4354: Sticky Events][MSC4354] - for MatrixRTC 2.0 calls
[MSC4143]: https://github.com/matrix-org/matrix-spec-proposals/pull/4143
[MSC4195]: https://github.com/matrix-org/matrix-spec-proposals/pull/4195
[MSC3401]: https://github.com/matrix-org/matrix-spec-proposals/pull/3401
[MSC4075]: https://github.com/matrix-org/matrix-spec-proposals/pull/4075
[MSC4354]: https://github.com/matrix-org/matrix-spec-proposals/pull/4354
Source code:
@@ -381,6 +401,47 @@ Other:
## Appendix
### MatrixRTC calling modes and enabling sticky events {#call-modes}
MatrixRTC currently supports 3 calling modes:
- **Legacy mode** (deprecated): calls are established by sending state events to a room. The call initiator's SFU hosts the entire call for all remote and local participants.
- **Compatibility mode*: same as Legacy mode, but utilizes multiple SFUs between federating servers. Clients publish media streams to their own SFUs, and fetch remote streams from remote SFUs. This is the most commonly used mode nowadays.
- **MatrixRTC 2.0 mode**: also utilizes multiple SFUs, but establishes calls with [sticky events] instead of state events.
To support Legacy and Compatibility mode, ensure that the user is allowed to send the relevant state events. Usually, this means promoting them to a power level of 50 or above. Alternatively, set the power level required to send `org.matrix.msc3401.call.member` events to 0.
To support MatrixRTC 2.0 mode, sticky events has to be enabled on the Matrix server. In Continuwuity, this is as easy as setting `enable_sticky_events = true` in the config file.
### Creating LiveKit tokens via `livekit-cli` {#livekit-cli}
To create room tokens directly without going through `lk-jwt-service`, use the [Livekit CLI tool][livekit-cli].
<Tabs groupId="livekit">
<Tab label="Bare Binary">
First, download the [release tarball][livekit-cli-releases] and extract it. Then:
```sh
./lk --url https://livekit.example.com \
--api-key APIUxUnMnSkuFWV \
--api-secret t93ZVjPeoEdyx7Wbet3kG4L3NGZIZVEFvqe0UuiVc22A \
token create --create --join
```
</Tab>
<Tab label="Docker">
```sh
docker run --rm docker.io/livekit/livekit-cli --url https://livekit.example.com \
--api-key APIUxUnMnSkuFWV \
--api-secret t93ZVjPeoEdyx7Wbet3kG4L3NGZIZVEFvqe0UuiVc22A \
token create --create --join
```
</Tab>
</Tabs>
[livekit-cli]: https://github.com/livekit/livekit-cli
[livekit-cli-releases]: https://github.com/livekit/livekit-cli
### Additional TURN-over-TLS on 443 configuration
Most of the time, LiveKit [**does not need TURN**][sspaeth-matrix-voip-turn] to function. However, there are situations where clients may be unable to use nonstandard ports or UDP connections, such as in highly restrictive networks. In such cases, a TURN-over-TLS server on port 443 could relay traffic for the clients.
@@ -487,6 +548,8 @@ Then configure LiveKit, making sure to replace `COTURN_SECRET` with the one you
### in your livekit.yaml ###
rtc:
# ... other configs here ...
stun_servers:
- coturn.example.com
turn_servers:
- host: coturn.example.com
port: 443
+4 -3
View File
@@ -1,16 +1,17 @@
# Setting up TURN/STUN
[TURN][turn] and [STUN][stun] are used as components in many calling systems. Matrix uses them directly for legacy calls and indirectly for MatrixRTC via Livekit.
[TURN][turn] and [STUN][stun] are used as components in many calling systems. Matrix uses them directly for legacy 1-to-1 calls and indirectly to assist MatrixRTC calls via Livekit.
Continuwuity recommends using [coturn][coturn] as your TURN/STUN server, which is available as a Docker image or a distro package. This guide assumes that you are using docker compose for deployment.
Continuwuity recommends using [coturn][coturn] as your TURN/STUN server, which is available as a Docker image or a distro package. This guide assumes that you are using `docker compose` for deployment.
:::tip
You can find help setting up TURN/STUN in our MatrixRTC room - [#matrixrtc:continuwuity.org](https://matrix.to/#/%23matrixrtc%3Acontinuwuity.org)
You can find help setting up TURN/STUN in our support room - [`#continuwuity:continuwuity.org`][support-room]
:::
[turn]: https://en.wikipedia.org/wiki/Traversal_Using_Relays_around_NAT
[stun]: https://en.wikipedia.org/wiki/STUN
[coturn]: https://github.com/coturn/coturn
[support-room]: https://matrix.to/#/%23continuwuity:continuwuity.org
## Installing coturn
+1 -1
View File
@@ -101,7 +101,7 @@ After Continuwuity is up and running, consider the following:
- See the [**Authentication chapter**](./authentication.mdx) for various ways to access to your homeserver, such as logging in with an external OIDC provider.
- Consult the [**Maintenance**](./maintenance.mdx) page for guidance on maintaining your homeserver.
- Consult the [**Maintenance**](./maintenance.mdx) page for guidance on backups, moderation, and other topics for homeserver management.
- If you want to set up an appservice, take a look at the [**Appservice Guide**](./appservices.mdx).
+8 -2
View File
@@ -2,10 +2,16 @@
Continuwuity is available in the [`archlinuxcn`][archlinuxcn] repository and AUR with the same package name, [`continuwuity`][aur-continuwuity].
The development version is available on the AUR as [`continuwuity-git`][aur-continuwuity-git].
For instructions on adding the archlinuxcn repo to your machine, see the [archlinuxcn README][archlinuxcn-readme] page. For AUR instructions, consult its [entry][aur-archwiki] on the Arch Wiki.
The development version, which tracks latest commits to the main branch, is also available on the AUR as [`continuwuity-git`][aur-continuwuity-git].
[archlinuxcn]: https://www.archlinuxcn.org/
[archlinuxcn-readme]: https://github.com/archlinuxcn/repo#usage
[aur-archwiki]: https://wiki.archlinux.org/title/Arch_User_Repository
[aur-continuwuity]: https://aur.archlinux.org/packages/continuwuity
[aur-continuwuity-git]: https://aur.archlinux.org/packages/continuwuity-git
Simply install the `continuwuity` package. Configure the service in `/etc/conduwuit/conduwuit.toml`, then enable and start the `continuwuity.service`.
Once you're done configuring your repos, simply install the `continuwuity` package with `pacman -S continuwuity`. Consult the [generic deployment instructions](./generic.mdx) for detailed steps, which involves editing `/etc/conduwuit/conduwuit.toml` and setting up a reverse proxy. Finally, enable and start the `continuwuity.service`.
After successfully setting up Continuwuity, navigate to [Post-installation](../deploying.mdx#post-installation) for next steps.
+2 -2
View File
@@ -246,8 +246,8 @@ to the `#admin:example.com` room and be able to [issue admin commands](../refere
To check if your server can communicate with other homeservers,
use an external testing tool:
- [Matrix Connectivity Tester](https://federationtester.mtrnord.blog/)
- [Matrix Federation Tester](https://federationtester.matrix.org/)
- [Matrix Connectivity Tester](https://federationtester.mtrnord.blog/) by MTRNord (recommended, with more tests).
- [Matrix Federation Tester](https://federationtester.matrix.org/) by f0x.
If you can register your account but cannot join federated rooms, check your configuration
and verify that your federation endpoints are opened and forwarded correctly.
+17 -9
View File
@@ -1,11 +1,11 @@
# Continuwuity for Kubernetes
Continuwuity doesn't support horizontal scalability or distributed loading
natively. However, a deployment in Kubernetes is very similar to the docker
setup. This is because Continuwuity can be fully configured using environment
variables. A sample StatefulSet is shared below. The only thing missing is
natively. However, a deployment in Kubernetes is very similar to the [docker setup](./docker.mdx).
This is because Continuwuity can be fully configured using environment
variables. A sample `StatefulSet` is shared below. The only thing missing is
a PVC definition (named `continuwuity-data`) for the volume mounted to
the StatefulSet, an Ingress resources to point your webserver to the
the `StatefulSet`, an Ingress resources to point your webserver to the
Continuwuity Pods, and a Service resource (targeting `app.kubernetes.io/name: continuwuity`)
to glue the Ingress and Pod together.
@@ -103,10 +103,18 @@ spec:
---
Apart from manually configuring the containers,
[a community-maintained Helm Chart is available here to run
conduwuit on Kubernetes](https://gitlab.cronce.io/charts/conduwuit)
## Community maintained Helm Chart
This should be compatible with Continuwuity, but you will need to change the image reference.
Apart from manually configuring the containers, you can consult
a community-maintained Helm Chart for the former `conduwuit` project,
which is available [here][community-helm-chart].
If changes need to be made, please reach out to the maintainer, as this is not maintained or controlled by the Continuwuity maintainers.
[community-helm-chart]: https://gitlab.cronce.io/charts/conduwuit
This should be compatible with Continuwuity, but you will need to switch the image reference.
If changes are needed to be made, please reach out to the maintainer of that repository, as it is not maintained nor controlled by the Continuwuity maintainers.
## Post-installation
After successfully setting up your Continuwuity, navigate to [Post-installation](../deploying.mdx#post-installation) for next steps.
+14 -1
View File
@@ -31,7 +31,14 @@ services.matrix-continuwuity = {
# address and port are handled automatically
# You can add any further configuration here, e.g.
# trusted_servers = [ "matrix.org" ];
# trusted_servers = [ "matrix.org" ];
## (if using well-known delegation)
# well_known = {
# client = "https://matrix.example.com";
# server = "matrix.example.com:443";
# }
};
};
};
@@ -79,3 +86,9 @@ client = "https://matrix.example.com"
You'll need to set up a reverse proxy (like NGINX or Caddy) to expose Continuwuity to the internet. You can configure your reverse proxy using NixOS options (e.g. `services.caddy`).
See the [reverse proxy setup guide](./generic.mdx#setting-up-the-reverse-proxy) for information on correct reverse proxy configuration.
Then, test that your setup works by following these [instructions](./generic.mdx#how-do-i-know-it-works).
## What's next?
Navigate to [Post-installation](../deploying.mdx#post-installation) for next steps.
+15 -19
View File
@@ -82,6 +82,21 @@ Consult these documents for more information on compression tuning and levels:
## Other tweaks
### Tuning your trusted servers
:::important Important: Vet your trusted servers!
Trusted servers are your first point of contact when obtaining public keys from the wider federated network. They could theoretically impersonate other servers and cause significant harm to your deployment. Please thoroughly verify your trusted servers' credibility before adding them to your configuration.
If you need suggestions for trusted servers, ask in the Continuwuity support room.
:::
For performance and reliability, it is recommended to set up 3 to 5 trusted servers for your deployment. Currently, these must all be Synapse servers.
```toml
# Example config, using maintainers' recommended homeservers
trusted_servers = ["codestorm.net","starstruck.systems","unredacted.org","matrix.org"]
```
### Using UNIX sockets
If your homeserver and reverse proxy live on the same machine, you may wish to expose Continuwuity on a UNIX socket instead of a port. This removes TCP overhead between the two programs.
@@ -111,25 +126,6 @@ https://matrix.example.com {
</details>
### Tuning your trusted servers
:::important Important: Vet your trusted servers!
Trusted servers are your first point of contact when obtaining public keys from other servers, and they could theoretically impersonate other servers and cause significant harm to your deployment. Please thoroughly verify your trusted servers' credibility before adding them to your configuration.
If you need suggestions for trusted servers, ask in the Continuwuity main room.
:::
Trusted servers are queried sequentially in the order they are listed. If you have multiple trusted servers configured, put the faster ones first:
```toml
# Example config, using maintainers' recommended homeservers
trusted_servers = ["codestorm.net","starstruck.systems","unredacted.org","matrix.org"]
```
Avoid prioritising `matrix.org` as your primary trusted server, as it tends to be quite slow.
Some users have also reported that increasing `trusted_server_batch_size` helps with faster joins for huge rooms. Start with doubling the default to `2048` until you find a suitable value.
### Enable HTTP/3 on your reverse proxy
Consider enabling the newer **HTTP/3** protocol for inbound connections to Continuwuity. In Caddy HTTP/3 is allowed by default, but you must expose port :443/**udp** on your firewall.
+6 -4
View File
@@ -78,9 +78,9 @@ To debug and test your UnifiedPush installation, use the [UP-Example] app for An
### UnifiedPush and push gateways
The push gateway URL is usually pre-configured by the client app. However, some clients (such as Element X) implement UnifiedPush's [Gateway Discovery] mechanism, and attempt to detect a push gateway _on the same domain as the push provider_, before falling back to a hardcoded one.
Normally, the push gateway URL is pre-configured by the client app. However, some clients (such as Element X) implement UnifiedPush's [Gateway Discovery] mechanism, and attempt to detect a push gateway _on the same domain as the push provider_ to use before falling back to a hardcoded one. Users of these clients can therefore self-host their own push gateway.
Per the [spec][spec-push-gateway-api], these push gateways must be available on the `/_matrix/push/v1/notify` path of said domain. To test that a push gateway is accessible to the homeserver, make a request for it from the homeserver's IP:
Per the [spec][spec-push-gateway-api], these push gateways must be available on the `/_matrix/push/v1/notify` path of said domain. To test that a push gateway is usable, make a request to it from both the homeserver and the client. The returned response should look like the following:
```txt
curl https://push.example.com/_matrix/push/v1/notify
@@ -122,7 +122,7 @@ Community tutorials for selfhosting some of these stacks are listed below. Unles
- Push gateway: [common-proxies]
- Push server: [ejabberd's mod_unified_push]
- Push app: [Conversations] (and forks)
- [Element X push notifications via Conversations][alfredolin-xmpp], by Alfredo Lin.
- [Element X push notifications via Conversations][alfredolin-xmpp], by Alfredolin.
- Push gateway: [common-proxies]
- Push server: [Prosody's mod_unified_push]
- Push app: [Conversations]
@@ -156,6 +156,8 @@ WARN conduwuit_service::pusher: Pusher URL is a forbidden remote address url=htt
To fix this, remove your push gateway or push server's address from `ip_range_denylist`, and restart Continuwuity to apply the changes.
Docker deployments with the push server/gateway on the same host as Continuwuity may run into some further network issues. In this case, consult the [Docker loopback networking issues] section and its workarounds.
### Push notifications not audible/not displaying
This is likely an issue with your account's _push rules_, which determines which events are shown to to the user as notifications. Check these push rules in the client's notifications settings and tweak accordingly. Continuwuity also provides an [`!admin users reset-push-rules`](../reference/admin/users#admin-users-reset-push-rules) command, which restores the rules to the default of notifying for every message.
@@ -175,7 +177,7 @@ If you find spurious log entries like this in your Continuwuity deployment:
WARN push{user_id="@user:example.com" pushkey="very-long-string-of-letters" events=1}:send_push_notice:send_notice:send_request: conduwuit_service::pusher: Could not send request to pusher https//push.example.com: error sending request for url (https://push.example.com/_matrix/push/v1/notify)
```
Then, your server is most likely sending push requests to too many invalid targets. This could be due to one of the following reasons:
Then, your server is sending push requests to too many invalid targets. This could be due to one of the following reasons:
#### Connection issues between the server and the push gateway
+16 -16
View File
@@ -431,9 +431,9 @@
}
},
"node_modules/@rspress/core": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.1.1.tgz",
"integrity": "sha512-GArybZxyifQ/wC8N2SzVyFi5JCJpUXgajITV4if8ylOImjZr8j9Cgy+6o55tXEtq85r6XYYE5fbcEz2nxxCpnA==",
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.1.2.tgz",
"integrity": "sha512-3ghPRkZFwbuO3tr2Rb5cxi6QfSFWOcxoZ5p4pv21lbN5DxAzMduITFlfgBMTArIQbehXrfXw3OUXe1l422b0RA==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -441,7 +441,7 @@
"@mdx-js/react": "^3.1.1",
"@rsbuild/core": "^2.2.14",
"@rsbuild/plugin-react": "~2.1.1",
"@rspress/shared": "2.1.1",
"@rspress/shared": "2.1.2",
"@shikijs/rehype": "^4.2.0",
"@shikijs/transformers": "^4.2.0",
"@types/mdast": "^4.0.4",
@@ -464,8 +464,8 @@
"react-router-dom": "^7.18.5",
"rehype-external-links": "^3.0.0",
"rehype-raw": "^7.0.0",
"remark-cjk-friendly": "^2.3.3",
"remark-cjk-friendly-gfm-strikethrough": "^2.3.2",
"remark-cjk-friendly": "^2.3.4",
"remark-cjk-friendly-gfm-strikethrough": "^2.3.3",
"remark-gfm": "^4.0.1",
"remark-mdx": "^3.1.1",
"remark-parse": "^11.0.0",
@@ -485,9 +485,9 @@
}
},
"node_modules/@rspress/plugin-client-redirects": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.1.1.tgz",
"integrity": "sha512-jrnh0UTczcTAk+xeJH6b2/LFLF2W7UzPYP992GxnW0mWJxPnvKQIk9v051bezD3gDuiGGRv8puFU7PMmwLOaHg==",
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.1.2.tgz",
"integrity": "sha512-kNCC7fffXA277TzTDfKpP+QuCI1X218lJ5JH/2iqYR8PHnLw0Y6ZIwoFmJlE0eKaBdniYyBRGn9zgvT93mCWdg==",
"dev": true,
"license": "MIT",
"engines": {
@@ -498,9 +498,9 @@
}
},
"node_modules/@rspress/plugin-sitemap": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@rspress/plugin-sitemap/-/plugin-sitemap-2.1.1.tgz",
"integrity": "sha512-3Zk+dmitcx5QxiSPi1Wh4exexRnKa09Yyj3710x6UM4sW2cl72SctMZapO7X9ETNrgVt9fW52eQsFzW1y38gSg==",
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/@rspress/plugin-sitemap/-/plugin-sitemap-2.1.2.tgz",
"integrity": "sha512-qF9NDLLJORa7MM8QY/etgMlrXM8hlArNaK5ntiFimqtKRoF1YTJQSKPsAfMq2PvYrpQJyEqsSg6wJ+r+lyjNlw==",
"dev": true,
"license": "MIT",
"engines": {
@@ -511,16 +511,16 @@
}
},
"node_modules/@rspress/shared": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.1.1.tgz",
"integrity": "sha512-U+OEPt/Ze+ryJdLHvpJJv9hxiRp03rknn5pvhh6v0enjib9SuUrsku/cPzneal3EsNyDZB5kncghpH1iwVKxnA==",
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.1.2.tgz",
"integrity": "sha512-W34tT1fdP3PrdbXpZNKqOGZMOw+RYL70Z9vnkbT1HTTbtX4uMIDE+SU7ByihG0S0LYBsT3kPxA2cXj696253Uw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@rsbuild/core": "^2.2.14",
"@shikijs/rehype": "^4.2.0",
"@types/react": "^19.3.0",
"mdast-util-mdx-jsx": "^3.2.0",
"mdast-util-mdx-jsx": "^3.2.1",
"unified": "^11.0.5"
}
},
+4 -4
View File
@@ -3,10 +3,10 @@ use conduwuit::{Err, Result, at};
use futures::StreamExt;
use ruma::{
api::client::dehydrated_device::{
delete_dehydrated_device::unstable as delete_dehydrated_device,
get_dehydrated_device::unstable as get_dehydrated_device,
get_events::unstable as get_events,
put_dehydrated_device::unstable as put_dehydrated_device,
delete_dehydrated_device::msc3814 as delete_dehydrated_device,
get_dehydrated_device::msc3814 as get_dehydrated_device,
get_events::msc3814 as get_events,
put_dehydrated_device::msc3814 as put_dehydrated_device,
},
assign,
};
+2 -2
View File
@@ -30,9 +30,9 @@ pub(crate) async fn get_media_config_route(
State(services): State<crate::State>,
_body: Ruma<get_media_config::v1::Request>,
) -> Result<get_media_config::v1::Response> {
Ok(get_media_config::v1::Response::new(ruma_from_usize(
Ok(get_media_config::v1::Response::new(Some(ruma_from_usize(
services.server.config.max_request_size,
)))
))))
}
/// # `POST /_matrix/media/v3/upload`
+2 -2
View File
@@ -25,9 +25,9 @@ pub(crate) async fn get_media_config_legacy_route(
State(services): State<crate::State>,
_body: Ruma<get_media_config::v3::Request>,
) -> Result<get_media_config::v3::Response> {
Ok(get_media_config::v3::Response::new(ruma_from_usize(
Ok(get_media_config::v3::Response::new(Some(ruma_from_usize(
services.server.config.max_request_size,
)))
))))
}
/// # `GET /_matrix/media/v1/config`
+2
View File
@@ -24,6 +24,7 @@ pub(super) mod push;
pub(super) mod read_marker;
pub(super) mod redact;
pub(super) mod relations;
pub(super) mod rendezvous;
pub(super) mod report;
pub(super) mod room;
pub(super) mod search;
@@ -71,6 +72,7 @@ pub(super) use push::*;
pub(super) use read_marker::*;
pub(super) use redact::*;
pub(super) use relations::*;
pub(super) use rendezvous::*;
pub(super) use report::*;
pub(super) use room::*;
pub(super) use search::*;
+3 -3
View File
@@ -13,8 +13,8 @@ use crate::Ruma;
#[tracing::instrument(skip_all, name = "mutual_rooms", level = "info")]
pub(crate) async fn get_mutual_rooms_unstable_route(
State(services): State<crate::State>,
body: Ruma<get_mutual_rooms::unstable::Request>,
) -> Result<get_mutual_rooms::unstable::Response> {
body: Ruma<get_mutual_rooms::msc2666::Request>,
) -> Result<get_mutual_rooms::msc2666::Response> {
let sender_user = body.identity.expect_sender_user()?;
if sender_user == body.user_id {
@@ -28,7 +28,7 @@ pub(crate) async fn get_mutual_rooms_unstable_route(
.collect()
.await;
Ok(get_mutual_rooms::unstable::Response::new(mutual_rooms))
Ok(get_mutual_rooms::msc2666::Response::new(mutual_rooms))
}
/// # `GET /_matrix/client/v1/mutual_rooms`
+76
View File
@@ -0,0 +1,76 @@
use axum::extract::State;
use conduwuit::{Err, Result};
use http::HeaderMap;
use ruma::api::client::rendezvous::{
create_rendezvous_session, delete_rendezvous_session, discover_rendezvous,
get_rendezvous_session, update_rendezvous_session,
};
use service::Services;
use crate::{Ruma, router::ClientIdentity};
/// `GET /_matrix/client/msc4388/io.element.msc4388/rendezvous`
pub(crate) async fn discover_rendezvous_route(
State(services): State<crate::State>,
body: Ruma<discover_rendezvous::msc4388::Request>,
) -> Result<discover_rendezvous::msc4388::Response> {
Ok(discover_rendezvous::msc4388::Response::new(rendezvous_available(
&services,
body.identity.as_ref(),
)))
}
/// `POST /_matrix/client/msc4388/io.element.msc4388/rendezvous/`
pub(crate) async fn create_rendezvous_session_route(
State(services): State<crate::State>,
body: Ruma<create_rendezvous_session::msc4388::Request>,
) -> Result<create_rendezvous_session::msc4388::Response> {
if !rendezvous_available(&services, body.identity.as_ref()) {
return Err!(Request(Forbidden("You are not authorized to create a rendezvous session")));
}
services.rendezvous.create_session(body.data.clone())
}
/// `PUT /_matrix/client/msc4388/io.element.msc4388/rendezvous/{id}/{txn_id}`
pub(crate) async fn update_rendezvous_session_route(
State(services): State<crate::State>,
body: Ruma<update_rendezvous_session::msc4388::Request>,
) -> Result<update_rendezvous_session::msc4388::Response> {
services.rendezvous.update_session(
&body.id,
body.txn_id.clone(),
body.sequence_token.clone(),
body.data.clone(),
)
}
/// `GET /_matrix/client/msc4388/io.element.msc4388/rendezvous/{id}`
pub(crate) async fn get_rendezvous_session_route(
State(services): State<crate::State>,
headers: HeaderMap,
body: Ruma<get_rendezvous_session::msc4388::Request>,
) -> Result<get_rendezvous_session::msc4388::Response> {
if let Some(mode) = headers.get("Sec-Fetch-Mode")
&& let Ok(mode) = mode.to_str()
&& mode == "navigate"
{
return Err!(Request(Forbidden(
"Rendezvous sessions do not accept browser navigation requests."
)));
}
services.rendezvous.get_session(&body.id)
}
/// `DELETE /_matrix/client/msc4388/io.element.msc4388/rendezvous/{id}`
pub(crate) async fn delete_rendezvous_session_route(
State(services): State<crate::State>,
body: Ruma<delete_rendezvous_session::msc4388::Request>,
) -> Result<delete_rendezvous_session::msc4388::Response> {
services.rendezvous.delete_session(&body.id)
}
fn rendezvous_available(services: &Services, identity: Option<&ClientIdentity>) -> bool {
!services.config.require_auth_for_rendezvous || identity.is_some()
}
+77 -3
View File
@@ -1,14 +1,28 @@
use axum::extract::State;
use conduwuit::{Err, Event, Result, debug_warn, err};
use ruma::api::client::room::get_room_event;
use axum::extract::{Query, State};
use conduwuit::{Err, Error, Event, PduEvent, Result, debug_warn, err};
use futures::TryFutureExt;
use http::StatusCode;
use ruma::{
UserId,
api::{client::room::get_room_event, error::ErrorKind},
};
use serde::Deserialize;
use serde_json::json;
use crate::{Ruma, client::is_ignored_pdu};
#[derive(Deserialize)]
pub(crate) struct Msc2815Params {
#[serde(rename = "fi.mau.msc2815.include_unredacted_content", default)]
include_unredacted_content: Option<bool>,
}
/// # `GET /_matrix/client/r0/rooms/{roomId}/event/{eventId}`
///
/// Gets a single event.
pub(crate) async fn get_room_event_route(
State(ref services): State<crate::State>,
Query(params): Query<Msc2815Params>,
ref body: Ruma<get_room_event::v3::Request>,
) -> Result<get_room_event::v3::Response> {
let sender_user = body.identity.expect_sender_user()?;
@@ -54,6 +68,13 @@ pub(crate) async fn get_room_event_route(
return Err!(Request(Forbidden("You don't have permission to view this event.")));
}
if services.config.allow_moderators_to_view_redacted_content
&& params.include_unredacted_content.unwrap_or(false)
&& event.is_redacted()
{
unredact(services, sender_user, &mut event).await?;
}
if let Err(e) = services
.rooms
.pdu_metadata
@@ -72,3 +93,56 @@ pub(crate) async fn get_room_event_route(
Ok(get_room_event::v3::Response::new(event.into_format()))
}
async fn unredact(services: &crate::State, sender_user: &UserId, event: &mut PduEvent) -> Result {
if !services.users.is_admin(sender_user).await {
let power_levels = services
.rooms
.state_accessor
.get_room_power_levels(&event.room_id_or_hash())
.await;
if power_levels.for_user(sender_user) < power_levels.redact {
return Err!(Request(Forbidden(
"You don't have permission to view redacted content in this room."
)));
}
}
let content = services
.rooms
.timeline
.get_pdu_id(event.event_id())
.and_then(async |pdu_id| {
services
.rooms
.timeline
.get_unredacted_content(&pdu_id)
.await
})
.await;
let Ok(content) = content else {
// CustomErrorKind has private fields; only serde can build one.
let keep_ms = services
.config
.unredacted_content_max_age_secs
.saturating_mul(1000);
let kind = serde_json::from_value::<ErrorKind>(json!({
"errcode": "FI.MAU.MSC2815_UNREDACTED_CONTENT_DELETED",
"fi.mau.msc2815.content_keep_ms": keep_ms,
}))
.expect("errcode is a valid custom error kind");
return Err(Error::Request(
kind,
"The unredacted content of this event is not available.".into(),
StatusCode::NOT_FOUND,
));
};
event.content = content;
Ok(())
}
+4 -4
View File
@@ -15,11 +15,11 @@ use crate::{Ruma, router::ClientIdentity};
#[tracing::instrument(skip_all, name = "stripped_state", level = "info")]
pub(crate) async fn get_stripped_state_route(
State(services): State<crate::State>,
body: Ruma<get_stripped_state::unstable::Request>,
) -> Result<get_stripped_state::unstable::Response> {
body: Ruma<get_stripped_state::msc4560::Request>,
) -> Result<get_stripped_state::msc4560::Response> {
let user_id = body.identity.as_ref().and_then(ClientIdentity::sender_user);
if body.via.len() > get_stripped_state::unstable::MAX_VIAS {
if body.via.len() > get_stripped_state::msc4560::MAX_VIAS {
return Err!(Request(TooLarge("Too many vias, please be less indecisive.")));
}
@@ -59,7 +59,7 @@ pub(crate) async fn get_stripped_state_route(
via,
RoomStrippedState { state, num_joined_members, .. },
)) => Ok(
assign!(get_stripped_state::unstable::Response::new(via), { state, num_joined_members }),
assign!(get_stripped_state::msc4560::Response::new(via), { state, num_joined_members }),
),
| Accessibility::Inaccessible => {
Err!(Request(Forbidden("You may not request this room's stripped state.")))
+1 -1
View File
@@ -39,7 +39,7 @@ pub(crate) async fn get_room_summary(
Err!(Request(Forbidden("You may not preview this room."), FORBIDDEN))
},
| Accessibility::NotFound => {
Err!(Request(Forbidden("This room does not exist."), FORBIDDEN))
Err!(Request(NotFound("This room does not exist.")))
},
}
}
+127 -129
View File
@@ -24,7 +24,7 @@ use conduwuit::{
use conduwuit_service::{
Services,
rooms::read_receipt::pack_receipts,
sync::{SnakeConnectionsKey, into_snake_key},
sync::{SnakeConnectionsKey, StickyDelivered, into_snake_key},
};
use futures::{
FutureExt, StreamExt, TryFutureExt,
@@ -34,7 +34,7 @@ use futures::{
use ruma::{
DeviceId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, RoomId, UInt, UserId,
api::client::sync::sync_events::{
self, DeviceLists, UnreadNotificationsCount, v5::request::ExtensionRoomConfig,
self, DeviceLists, UnreadNotificationsCount, msc4186::request::ExtensionRoomConfig,
},
assign,
directory::RoomTypeFilter,
@@ -63,7 +63,7 @@ use crate::{
client_ip::ClientIp,
};
type SyncInfo<'a> = (&'a UserId, &'a DeviceId, u64, &'a sync_events::v5::Request);
type SyncInfo<'a> = (&'a UserId, &'a DeviceId, u64, &'a sync_events::msc4186::Request);
type TodoRooms = BTreeMap<OwnedRoomId, (BTreeSet<TypeStateKey>, usize, u64)>;
type KnownRooms = BTreeMap<String, BTreeMap<OwnedRoomId, u64>>;
type KnownRoomUpdates = BTreeMap<String, BTreeSet<OwnedRoomId>>;
@@ -86,8 +86,9 @@ fn num_live_events<'a>(
}
struct SyncCollection {
response: sync_events::v5::Response,
response: sync_events::msc4186::Response,
known_room_updates: KnownRoomUpdates,
sticky_delivered: StickyDelivered,
}
/// `POST /_matrix/client/unstable/org.matrix.simplified_msc3575/sync`
@@ -103,8 +104,8 @@ struct SyncCollection {
pub(crate) async fn sync_events_v5_route(
State(ref services): State<crate::State>,
ClientIp(client_ip): ClientIp, // NOTE: Required for updating device metadata
body: Ruma<sync_events::v5::Request>,
) -> Result<sync_events::v5::Response> {
body: Ruma<sync_events::msc4186::Request>,
) -> Result<sync_events::msc4186::Response> {
let sender_user = body.identity.expect_sender_user()?;
let sender_device = body.identity.expect_sender_device()?;
@@ -142,7 +143,7 @@ pub(crate) async fn sync_events_v5_route(
}
// Get sticky parameters from cache
let known_rooms =
let (known_rooms, sticky_delivered) =
services
.sync
.update_snake_sync_request_with_cache(&snake_key, globalsince, &mut body);
@@ -155,6 +156,7 @@ pub(crate) async fn sync_events_v5_route(
&body,
globalsince,
&known_rooms,
&sticky_delivered,
)
.await?;
@@ -173,6 +175,7 @@ pub(crate) async fn sync_events_v5_route(
&body,
globalsince,
&known_rooms,
&sticky_delivered,
)
.await?;
}
@@ -202,13 +205,13 @@ async fn collect_sync_response(
services: &Services,
sender_user: &UserId,
sender_device: &DeviceId,
body: &sync_events::v5::Request,
body: &sync_events::msc4186::Request,
globalsince: u64,
known_rooms: &KnownRooms,
sticky_delivered: &StickyDelivered,
) -> Result<SyncCollection> {
// Bounds every read below and becomes the `pos` returned to the client.
// Zero would be echoed back as a request for an initial sync.
let next_batch = services.globals.current_count()?.max(1);
let next_batch = services.globals.next_count()?;
let all_joined_rooms = services
.rooms
@@ -262,7 +265,6 @@ async fn collect_sync_response(
let pos = next_batch.to_string();
let mut todo_rooms: TodoRooms = BTreeMap::new();
let mut sticky_rooms = BTreeSet::new();
let sync_info: SyncInfo<'_> = (sender_user, sender_device, globalsince, body);
@@ -277,16 +279,16 @@ async fn collect_sync_response(
let (account_data, e2ee, to_device, receipts) =
try_join4(account_data, e2ee, to_device, receipts).await?;
let extensions = assign!(sync_events::v5::response::Extensions::default(), {
let extensions = assign!(sync_events::msc4186::response::Extensions::default(), {
account_data,
e2ee,
to_device,
receipts,
typing: sync_events::v5::response::Typing::default(),
sticky_events: sync_events::v5::response::StickyEvents::default(),
typing: sync_events::msc4186::response::Typing::default(),
sticky_events: sync_events::msc4186::response::StickyEvents::default(),
});
let mut response = assign!(sync_events::v5::Response::new(pos), {
let mut response = assign!(sync_events::msc4186::Response::new(pos), {
txn_id: body.txn_id.clone(),
lists: BTreeMap::new(),
rooms: BTreeMap::new(),
@@ -319,7 +321,6 @@ async fn collect_sync_response(
all_rooms,
&direct_rooms,
&mut todo_rooms,
&mut sticky_rooms,
known_rooms,
&mut response,
)
@@ -329,7 +330,6 @@ async fn collect_sync_response(
"subscriptions".to_owned(),
fetch_subscriptions(services, body, known_rooms, &allowed_rooms, &mut todo_rooms).await,
);
sticky_rooms.extend(body.room_subscriptions.keys().cloned());
let mut timeline_event_ids = BTreeSet::new();
response.rooms = process_rooms(
@@ -346,25 +346,31 @@ async fn collect_sync_response(
)
.await?;
response.extensions.sticky_events = collect_sticky_events(
let (sticky_events, sticky_delivered) = collect_sticky_events(
services,
sender_user,
body,
&sticky_rooms,
next_batch,
sticky_delivered,
&known_room_updates,
&joined_room_ids,
&todo_rooms,
&timeline_event_ids,
)
.await?;
.await;
response.extensions.sticky_events = sticky_events;
response.extensions.typing =
collect_typing_events(services, sender_user, body, &todo_rooms, &known_room_updates)
.await?;
Ok(SyncCollection { response, known_room_updates })
Ok(SyncCollection {
response,
known_room_updates,
sticky_delivered,
})
}
fn response_is_empty(response: &sync_events::v5::Response) -> bool {
fn response_is_empty(response: &sync_events::msc4186::Response) -> bool {
let no_account_data = response.extensions.account_data.global.is_empty()
&& response
.extensions
@@ -395,7 +401,7 @@ async fn commit_sync_collection(
services: &Services,
sender_user: &UserId,
sender_device: &DeviceId,
body: &sync_events::v5::Request,
body: &sync_events::msc4186::Request,
globalsince: u64,
snake_key: &SnakeConnectionsKey,
collection: &SyncCollection,
@@ -408,9 +414,10 @@ async fn commit_sync_collection(
.parse()
.expect("generated sync position"),
collection.known_room_updates.clone(),
collection.sticky_delivered.clone(),
);
if body.extensions.to_device.enabled.unwrap_or(false) {
if body.extensions.to_device.enabled {
services
.users
.remove_to_device_events(sender_user, sender_device, globalsince)
@@ -420,7 +427,7 @@ async fn commit_sync_collection(
async fn fetch_subscriptions(
services: &Services,
body: &sync_events::v5::Request,
body: &sync_events::msc4186::Request,
known_rooms: &KnownRooms,
allowed_rooms: &BTreeSet<OwnedRoomId>,
todo_rooms: &mut TodoRooms,
@@ -480,15 +487,14 @@ async fn fetch_subscriptions(
async fn handle_lists<'a, Rooms, AllRooms>(
services: &Services,
sender_user: &UserId,
body: &sync_events::v5::Request,
body: &sync_events::msc4186::Request,
all_invited_rooms: Rooms,
all_joined_rooms: Rooms,
all_rooms: AllRooms,
direct_rooms: &HashSet<OwnedRoomId>,
todo_rooms: &'a mut TodoRooms,
sticky_rooms: &mut BTreeSet<OwnedRoomId>,
known_rooms: &'a KnownRooms,
response: &'_ mut sync_events::v5::Response,
response: &'_ mut sync_events::msc4186::Response,
) -> KnownRoomUpdates
where
Rooms: Iterator<Item = &'a RoomId> + Clone + Send + 'a,
@@ -579,7 +585,6 @@ where
.await;
sort_rooms_by_activity(&mut active_rooms);
let active_rooms: Vec<_> = active_rooms.into_iter().map(at!(0)).collect();
sticky_rooms.extend(active_rooms.iter().map(|room_id| (*room_id).to_owned()));
let mut new_known_rooms: BTreeSet<OwnedRoomId> = BTreeSet::new();
@@ -631,7 +636,7 @@ where
}
response.lists.insert(
list_id.clone(),
assign!(sync_events::v5::response::List::default(), {
assign!(sync_events::msc4186::response::List::default(), {
count: ruma_from_usize(active_rooms.len()),
}),
);
@@ -749,10 +754,10 @@ async fn process_rooms<'a, Rooms>(
all_invited_rooms: Rooms,
all_knocked_rooms: Rooms,
todo_rooms: &TodoRooms,
response: &mut sync_events::v5::Response,
body: &sync_events::v5::Request,
response: &mut sync_events::msc4186::Response,
body: &sync_events::msc4186::Request,
timeline_event_ids: &mut BTreeSet<OwnedEventId>,
) -> Result<BTreeMap<OwnedRoomId, sync_events::v5::response::Room>>
) -> Result<BTreeMap<OwnedRoomId, sync_events::msc4186::response::Room>>
where
Rooms: Iterator<Item = &'a RoomId> + Clone + Send + 'a,
{
@@ -787,7 +792,7 @@ where
rooms.insert(
room_id.clone(),
assign!(sync_events::v5::response::Room::new(), {
assign!(sync_events::msc4186::response::Room::new(), {
initial: Some(roomsince == &0),
invite_state,
limited: true,
@@ -821,7 +826,7 @@ where
rooms.insert(
room_id.clone(),
assign!(sync_events::v5::response::Room::new(), {
assign!(sync_events::msc4186::response::Room::new(), {
initial: Some(roomsince == &0),
invite_state: Some(knock_state),
limited: true,
@@ -988,7 +993,7 @@ where
.state_accessor
.get_member(room_id, &user_id)
.map_ok(|member_event| {
assign!(sync_events::v5::response::Hero::new(user_id.clone()), {
assign!(sync_events::msc4186::response::Hero::new(user_id.clone()), {
name: member_event.displayname,
avatar: member_event.avatar_url,
})
@@ -1032,7 +1037,7 @@ where
rooms.insert(
room_id.clone(),
assign!(sync_events::v5::response::Room::new(), {
assign!(sync_events::msc4186::response::Room::new(), {
name: services
.rooms
.state_accessor
@@ -1103,64 +1108,61 @@ where
Ok(rooms)
}
#[expect(clippy::too_many_arguments)]
async fn collect_sticky_events(
services: &Services,
sender_user: &UserId,
body: &sync_events::v5::Request,
sticky_rooms: &BTreeSet<OwnedRoomId>,
body: &sync_events::msc4186::Request,
next_batch: u64,
sticky_delivered: &StickyDelivered,
known_room_updates: &KnownRoomUpdates,
joined_room_ids: &BTreeSet<OwnedRoomId>,
todo_rooms: &TodoRooms,
timeline_event_ids: &BTreeSet<OwnedEventId>,
) -> Result<sync_events::v5::response::StickyEvents> {
if !services.config.allow_sticky_events
|| !body.extensions.sticky_events.enabled.unwrap_or(false)
{
return Ok(sync_events::v5::response::StickyEvents::default());
) -> (sync_events::msc4186::response::StickyEvents, StickyDelivered) {
let mut response = sync_events::msc4186::response::StickyEvents::default();
let mut delivered = StickyDelivered::new();
let sticky_events = &body.extensions.sticky_events;
if !services.config.allow_sticky_events || !sticky_events.enabled.unwrap_or(false) {
return (response, delivered);
}
let since = body
.extensions
.sticky_events
.since
.as_deref()
.and_then(|token| token.parse::<u64>().ok())
.unwrap_or(0);
let limit = body
.extensions
.sticky_events
let scope = extension_scope(
sticky_events.lists.as_deref(),
sticky_events.rooms.as_deref(),
body.lists.keys().map(String::as_str),
known_room_updates,
);
let limit = sticky_events
.limit
.map_or(DEFAULT_STICKY_LIMIT, usize_from_ruma)
.clamp(1, DEFAULT_STICKY_LIMIT);
let now = u64::from(MilliSecondsSinceUnixEpoch::now().get());
let oldest_sticky_ts = now.saturating_sub(sticky::MAX_DURATION_MS);
let mut backlog = Vec::new();
let mut stream = Vec::new();
for room_id in sticky_rooms
.iter()
.filter(|room_id| joined_room_ids.contains(*room_id))
{
// a room the client has not seen before needs its whole backlog, which
// a single stream position cannot express
let initial = todo_rooms
.get(room_id)
.is_some_and(|&(_, _, roomsince)| roomsince == 0);
for room_id in scope.intersection(joined_room_ids) {
let since = sticky_delivered.get(room_id).copied();
let mut pending = Vec::new();
let pdus = services.rooms.timeline.pdus_rev(room_id, None).ignore_err();
pin_mut!(pdus);
while let Some((count, pdu)) = pdus.next().await {
// nothing older than this can still be sticky, and on the stream we
// have already delivered everything up to `since`
if u64::from(pdu.origin_server_ts) < oldest_sticky_ts
|| (!initial && count <= PduCount::Normal(since))
{
break;
}
let PduCount::Normal(count) = count else {
continue;
};
if count > next_batch {
continue;
}
// Nothing older than this can still be sticky, and everything up to
// `since` has already been delivered
if u64::from(pdu.origin_server_ts) < oldest_sticky_ts
|| since.is_some_and(|since| count <= since)
{
break;
}
let is_sticky = pdu
.sticky
.as_deref()
@@ -1177,38 +1179,26 @@ async fn collect_sticky_events(
continue;
}
if count > since {
stream.push((count, room_id.clone(), pdu));
} else {
backlog.push((room_id.clone(), pdu));
}
pending.push((count, pdu));
}
}
stream.sort_by_key(|(count, ..)| *count);
let mut response = sync_events::v5::response::StickyEvents::default();
pending.reverse();
let truncated = pending.len() > limit;
let mut last_count = next_batch;
for (count, pdu) in pending.into_iter().take(limit) {
push_sticky_event(services, &mut response, sender_user, room_id.clone(), pdu).await;
last_count = count;
}
// MSC4480 lets us ignore the limit for a newly visible room's backlog
for (room_id, pdu) in backlog {
push_sticky_event(services, &mut response, sender_user, room_id, pdu).await;
delivered.insert(room_id.clone(), if truncated { last_count } else { next_batch });
}
let mut next_batch = None;
for (count, room_id, pdu) in stream.into_iter().take(limit) {
push_sticky_event(services, &mut response, sender_user, room_id, pdu).await;
next_batch = Some(count);
}
if !response.rooms.is_empty() {
response.next_batch = Some(next_batch.unwrap_or(since).to_string());
}
Ok(response)
(response, delivered)
}
async fn push_sticky_event(
services: &Services,
response: &mut sync_events::v5::response::StickyEvents,
response: &mut sync_events::msc4186::response::StickyEvents,
sender_user: &UserId,
room_id: OwnedRoomId,
mut pdu: PduEvent,
@@ -1275,12 +1265,12 @@ async fn collect_required_state(
async fn collect_typing_events(
services: &Services,
sender_user: &UserId,
body: &sync_events::v5::Request,
body: &sync_events::msc4186::Request,
todo_rooms: &TodoRooms,
known_room_updates: &KnownRoomUpdates,
) -> Result<sync_events::v5::response::Typing> {
) -> Result<sync_events::msc4186::response::Typing> {
if !body.extensions.typing.enabled.unwrap_or(false) {
return Ok(sync_events::v5::response::Typing::default());
return Ok(sync_events::msc4186::response::Typing::default());
}
let typing = &body.extensions.typing;
let scope = extension_scope(
@@ -1290,10 +1280,10 @@ async fn collect_typing_events(
known_room_updates,
);
if scope.is_empty() {
return Ok(sync_events::v5::response::Typing::default());
return Ok(sync_events::msc4186::response::Typing::default());
}
let mut typing_response = sync_events::v5::response::Typing::default();
let mut typing_response = sync_events::msc4186::response::Typing::default();
for (room_id, (_, _, roomsince)) in todo_rooms {
if !scope.contains(room_id) {
continue;
@@ -1373,12 +1363,17 @@ fn extension_scope<'a>(
async fn collect_account_data(
services: &Services,
(sender_user, _, globalsince, body): (&UserId, &DeviceId, u64, &sync_events::v5::Request),
) -> sync_events::v5::response::AccountData {
let mut account_data = sync_events::v5::response::AccountData::default();
(sender_user, _, globalsince, body): (
&UserId,
&DeviceId,
u64,
&sync_events::msc4186::Request,
),
) -> sync_events::msc4186::response::AccountData {
let mut account_data = sync_events::msc4186::response::AccountData::default();
if !body.extensions.account_data.enabled.unwrap_or(false) {
return sync_events::v5::response::AccountData::default();
return sync_events::msc4186::response::AccountData::default();
}
account_data.global = services
@@ -1413,15 +1408,15 @@ async fn collect_e2ee<'a, Rooms>(
&UserId,
&DeviceId,
u64,
&sync_events::v5::Request,
&sync_events::msc4186::Request,
),
all_joined_rooms: Rooms,
) -> Result<sync_events::v5::response::E2EE>
) -> Result<sync_events::msc4186::response::E2EE>
where
Rooms: Iterator<Item = &'a RoomId> + Send + 'a,
{
if !body.extensions.e2ee.enabled.unwrap_or(false) {
return Ok(sync_events::v5::response::E2EE::default());
if !body.extensions.e2ee.enabled {
return Ok(sync_events::msc4186::response::E2EE::default());
}
let mut left_encrypted_users = HashSet::new(); // Users that have left any encrypted rooms the sender was in
let mut device_list_changes = HashSet::new();
@@ -1608,7 +1603,7 @@ where
}
}
Ok(assign!(sync_events::v5::response::E2EE::default(), {
Ok(assign!(sync_events::msc4186::response::E2EE::default(), {
device_unused_fallback_key_types: None,
device_one_time_keys_count: services
@@ -1627,12 +1622,12 @@ async fn collect_to_device(
services: &Services,
(sender_user, sender_device, globalsince, body): SyncInfo<'_>,
next_batch: u64,
) -> Option<sync_events::v5::response::ToDevice> {
if !body.extensions.to_device.enabled.unwrap_or(false) {
) -> Option<sync_events::msc4186::response::ToDevice> {
if !body.extensions.to_device.enabled {
return None;
}
Some(assign!(sync_events::v5::response::ToDevice::default(), {
Some(assign!(sync_events::msc4186::response::ToDevice::default(), {
next_batch: next_batch.to_string(),
events: services
.users
@@ -1643,9 +1638,9 @@ async fn collect_to_device(
}))
}
async fn collect_receipts(_services: &Services) -> sync_events::v5::response::Receipts {
async fn collect_receipts(_services: &Services) -> sync_events::msc4186::response::Receipts {
// TODO: get explicitly requested read receipts
sync_events::v5::response::Receipts::default()
sync_events::msc4186::response::Receipts::default()
}
#[cfg(test)]
@@ -1658,23 +1653,25 @@ mod tests {
fn custom_room_type() -> RoomTypeFilter { RoomTypeFilter::from(Some("com.example")) }
fn response() -> sync_events::v5::Response { sync_events::v5::Response::new("1".to_owned()) }
fn response() -> sync_events::msc4186::Response {
sync_events::msc4186::Response::new("1".to_owned())
}
fn typing_scope_request() -> sync_events::v5::Request {
let mut request = sync_events::v5::Request::new();
fn typing_scope_request() -> sync_events::msc4186::Request {
let mut request = sync_events::msc4186::Request::new();
request
.lists
.insert("first".to_owned(), sync_events::v5::request::List::default());
.insert("first".to_owned(), sync_events::msc4186::request::List::default());
request
.lists
.insert("second".to_owned(), sync_events::v5::request::List::default());
.insert("second".to_owned(), sync_events::msc4186::request::List::default());
request.room_subscriptions.insert(
owned_room_id!("!subscription-a:example.com"),
sync_events::v5::request::RoomSubscription::default(),
sync_events::msc4186::request::RoomSubscription::default(),
);
request.room_subscriptions.insert(
owned_room_id!("!subscription-b:example.com"),
sync_events::v5::request::RoomSubscription::default(),
sync_events::msc4186::request::RoomSubscription::default(),
);
request
}
@@ -1768,9 +1765,10 @@ mod tests {
#[test]
fn a_room_with_no_events_is_still_empty() {
let mut response = response();
response
.rooms
.insert(owned_room_id!("!a:example.com"), sync_events::v5::response::Room::default());
response.rooms.insert(
owned_room_id!("!a:example.com"),
sync_events::msc4186::response::Room::default(),
);
assert!(response_is_empty(&response));
}
@@ -1781,7 +1779,7 @@ mod tests {
let mut response = response();
response
.rooms
.insert(room_id.to_owned(), sync_events::v5::response::Room::default());
.insert(room_id.to_owned(), sync_events::msc4186::response::Room::default());
response
.extensions
.receipts
@@ -1846,7 +1844,7 @@ mod tests {
#[test]
fn to_device_without_events_is_empty() {
let mut response = response();
response.extensions.to_device = Some(sync_events::v5::response::ToDevice::default());
response.extensions.to_device = Some(sync_events::msc4186::response::ToDevice::default());
assert!(response_is_empty(&response));
}
+5
View File
@@ -34,6 +34,11 @@ pub(crate) async fn get_supported_versions_route(
unstable_features.insert("org.matrix.msc4354".to_owned(), true);
}
if services.config.allow_moderators_to_view_redacted_content {
// moderators can view redacted content (https://github.com/matrix-org/matrix-spec-proposals/pull/2815)
unstable_features.insert("fi.mau.msc2815".to_owned(), true);
}
Ok(assign!(get_supported_versions::Response::new(versions()), {
unstable_features
}))
+3 -3
View File
@@ -43,9 +43,9 @@ pub(crate) async fn well_known_client(
/// homeserver, implementing MSC4143.
pub(crate) async fn get_rtc_transports(
State(services): State<crate::State>,
_body: Ruma<ruma::api::client::rtc::transports::v1::Request>,
) -> Result<ruma::api::client::rtc::transports::v1::Response> {
Ok(ruma::api::client::rtc::transports::v1::Response::new(
_body: Ruma<ruma::api::client::rtc::transports::msc4143::Request>,
) -> Result<ruma::api::client::rtc::transports::msc4143::Response> {
Ok(ruma::api::client::rtc::transports::msc4143::Response::new(
services.config.matrix_rtc.foci.clone(),
))
}
+5
View File
@@ -194,6 +194,11 @@ pub fn build(router: Router<State>, state: State) -> Router<State> {
.ruma_route(&client::well_known_policy_server)
.ruma_route(&client::get_rtc_transports)
.ruma_route(&client::room_initial_sync_route)
.ruma_route(&client::discover_rendezvous_route)
.ruma_route(&client::create_rendezvous_session_route)
.ruma_route(&client::update_rendezvous_session_route)
.ruma_route(&client::get_rendezvous_session_route)
.ruma_route(&client::delete_rendezvous_session_route)
.ruma_route(&client::get_authorization_server_metadata_route)
.merge(client::oauth::router(state))
.route("/_continuwuity/server_version", get(client::continuwuity_server_version))
-3
View File
@@ -47,9 +47,6 @@ pub(crate) async fn get_missing_events_route(
if body.latest_events.len() > limit {
return Err!(Request(InvalidParam("Too many latest_events")));
}
if body.earliest_events.len() > limit {
return Err!(Request(InvalidParam("Too many earliest_events")));
}
let room_version = services.rooms.state.get_room_version(&body.room_id).await?;
+3 -3
View File
@@ -14,8 +14,8 @@ use crate::Ruma;
/// [MSC4560]: https://github.com/matrix-org/matrix-spec-proposals/pull/4560
pub(crate) async fn get_stripped_state_route(
State(services): State<crate::State>,
body: Ruma<get_stripped_state::unstable::Request>,
) -> Result<get_stripped_state::unstable::Response> {
body: Ruma<get_stripped_state::msc4560::Request>,
) -> Result<get_stripped_state::msc4560::Response> {
if let Some(forbidden_type) = body
.state
.iter()
@@ -42,7 +42,7 @@ pub(crate) async fn get_stripped_state_route(
.await
{
| Accessibility::Accessible(RoomStrippedState { state, num_joined_members, .. }) => Ok(
assign!(get_stripped_state::unstable::Response::default(), { state, num_joined_members }),
assign!(get_stripped_state::msc4560::Response::default(), { state, num_joined_members }),
),
| Accessibility::Inaccessible => {
Err!(Request(Forbidden("You may not access this room's stripped state.")))
+47 -4
View File
@@ -918,14 +918,34 @@ pub struct Config {
#[serde(default)]
pub forget_forced_upon_leave: bool,
/// Set this to true to require authentication on the normally
/// unauthenticated profile retrieval endpoints (GET)
/// "/_matrix/client/v3/profile/{userId}".
/// Set this to true to require authentication when looking up user profiles
/// through this server.
///
/// This can prevent profile scraping.
/// By default this is false, allowing tools such as matrix.to to access
/// profiles of users on this server and on other servers.
/// Setting this to true will block those tools, and may block automated
/// crawlers from scraping users' profiles, although it will not block
/// other homeservers from accessing users' profiles.
///
/// default: false
#[serde(default)]
pub require_auth_for_profile_requests: bool,
/// Set this to true to require authentication to create a rendezvous
/// session. Rendezvous sessions are used for QR code login.
///
/// For QR code login, the device that shows the QR code is the one that
/// creates the rendezvous session. Therefore, this must be false to let
/// a logged-out device show a QR code.
///
/// By default this is false, allowing logged-out desktop devices (which may
/// not have a camera) to show a QR code. Setting this to true will
/// require logged-out devices to scan the QR code instead.
///
/// default: true
#[serde(default)]
pub require_auth_for_rendezvous: bool,
/// Set this to true to allow your server's public room directory to be
/// federated. Set this to false to protect against /publicRooms spiders,
/// but will forbid external users from viewing your server's public room
@@ -1776,6 +1796,27 @@ pub struct Config {
#[serde(default)]
pub allow_sticky_events: bool,
/// Allow room moderators to view redacted event content ([MSC2815]).
///
/// Redacted content is readable by users at or above the room's `redact`
/// power level, and by server admins, until it expires.
///
/// MSC2815: https://github.com/matrix-org/matrix-spec-proposals/pull/2815
///
/// default: false
#[serde(default)]
pub allow_moderators_to_view_redacted_content: bool,
/// How long to retain the content of redacted events, in seconds. Expired
/// content is deleted by a periodic purge and is no longer served.
///
/// Only has an effect when allow_moderators_to_view_redacted_content is
/// enabled.
///
/// default: 7776000 (90 days)
#[serde(default = "default_unredacted_content_max_age_secs")]
pub unredacted_content_max_age_secs: u64,
/// Maximum time federation user can indicate typing.
///
/// default: 30
@@ -3243,6 +3284,8 @@ fn default_remote_join_pdu_queue_capacity() -> usize { 50 }
fn default_transaction_id_cache_max_age_secs() -> u64 { 60 * 60 * 2 }
fn default_unredacted_content_max_age_secs() -> u64 { 60 * 60 * 24 * 90 }
fn default_transaction_id_cache_max_entries() -> usize { 8192 }
fn default_tracing_flame_filter() -> String {
+2 -1
View File
@@ -37,7 +37,8 @@ pub use error::Error;
pub use info::version::*;
pub use matrix::{Event, EventTypeExt, Pdu, PduCount, PduEvent, PduId, pdu, state_res};
pub use parking_lot::{
Mutex as SyncMutex, RwLock as SyncRwLock, RwLockReadGuard as SyncRwLockReadGuard,
MappedMutexGuard as SyncMappedMutexGuard, Mutex as SyncMutex, MutexGuard as SyncMutexGuard,
RwLock as SyncRwLock, RwLockReadGuard as SyncRwLockReadGuard,
RwLockWriteGuard as SyncRwLockWriteGuard,
};
pub use server::Server;
+5
View File
@@ -153,6 +153,11 @@ pub(super) static MAPS: &[Descriptor] = &[
index_size: 512,
..descriptor::SEQUENTIAL
},
Descriptor {
name: "pduid_unredactedcontent",
key_size_hint: Some(16),
..descriptor::SEQUENTIAL
},
Descriptor {
name: "publicroomids",
..descriptor::RANDOM_SMALL
+4
View File
@@ -145,3 +145,7 @@ workspace = true
[package.metadata.cargo-shear]
ignored = ["reqwest_0_12"]
[dev-dependencies]
opentelemetry.workspace = true
rustls = { workspace = true, features = ["ring"] }
+7 -1
View File
@@ -2,7 +2,7 @@ use std::sync::Arc;
use conduwuit::{
Err, Result, err,
utils::{ReadyExt, result::LogErr, stream::TryIgnore},
utils::{MutexMap, ReadyExt, result::LogErr, stream::TryIgnore},
};
use database::{Deserialized, Handle, Ignore, Json, Map};
use futures::{Stream, StreamExt, TryFutureExt};
@@ -27,6 +27,7 @@ pub enum AnyRawAccountDataEvent {
pub struct Service {
services: Services,
db: Data,
update_mutex: MutexMap<OwnedUserId, ()>,
}
struct Data {
@@ -50,6 +51,7 @@ impl crate::Service for Service {
roomuserdataid_accountdata: args.db["roomuserdataid_accountdata"].clone(),
roomusertype_roomuserdataid: args.db["roomusertype_roomuserdataid"].clone(),
},
update_mutex: MutexMap::new(),
}))
}
@@ -71,6 +73,10 @@ impl Service {
return Err!(Request(InvalidParam("Account data doesn't have all required fields.")));
}
// Two updates reading the same previous entry would both remove it,
// and the entry of the one that lost the index would stay forever.
let _lock = self.update_mutex.lock(user_id).await;
let count = self.services.globals.next_count().unwrap();
let roomuserdataid = (room_id, user_id, count, &event_type);
self.db
+10 -2
View File
@@ -338,8 +338,16 @@ fn builder_interface(
fn get_dns_resolver(server: &Arc<Server>) -> Result<Arc<TokioResolver>> {
let config = &server.config;
let (system_resolver_config, mut opts) = hickory_resolver::system_conf::read_system_conf()
.map_err(|e| err!(error!("Failed to configure DNS resolver from system: {e}")))?;
let (system_resolver_config, mut opts) =
match hickory_resolver::system_conf::read_system_conf() {
| Ok(system_conf) => system_conf,
| Err(e) if config.dns_servers.is_empty() =>
return Err(err!(error!("Failed to configure DNS resolver from system: {e}"))),
| Err(e) => {
warn!("Failed to read system DNS configuration, using dns_servers: {e}");
Default::default()
},
};
let mut conf = ResolverConfig::from_name_servers(vec![]);
+71 -3
View File
@@ -1,4 +1,9 @@
use std::{borrow::Cow, fmt::Debug, mem, time::Instant};
use std::{
borrow::Cow,
fmt::Debug,
mem,
time::{Duration, Instant},
};
use conduwuit::{
Err, Error, Result, debug, debug_error, debug_info, debug_warn, err, metrics::KeyValue,
@@ -133,12 +138,19 @@ impl super::Service {
self.ensure_remote_is_healthy(dest)?;
/// How long to wait with re-resolution if a server fails to resolve
const UNRESOLVABLE_RETRY_AFTER: Duration = Duration::from_hours(24 * 90);
let actual = self
.services
.client
.matrix_resolver
.resolve_server(dest.as_str())
.await?;
.await
.inspect_err(|_| {
self.hit_unhealthy(dest.to_owned(), Some(UNRESOLVABLE_RETRY_AFTER));
self.mark_destination_stale(dest);
})?;
let request = Request::try_from(request.try_into_http_request::<Vec<u8>>(
actual.base_url().as_str(),
@@ -210,7 +222,7 @@ impl super::Service {
if self.should_mark_stale(&wrapped) {
debug_info!("{dest} is unhealthy & stale due to a connect error");
self.mark_destination_stale(dest);
self.hit_unhealthy(dest.to_owned());
self.hit_unhealthy(dest.to_owned(), None);
}
let Error::Reqwest(unwrapped) = wrapped else {
unreachable!("wrapped reqwest error must unwrap to a reqwest error");
@@ -300,6 +312,26 @@ async fn into_http_response(
actual.base_url(),
);
if url.path() != "/.well-known/matrix/server" {
// For some reason, the spec starts off saying federation responses MUST
// include a `Content-Type` header of `application/json` on all
// responses. Then, the definition for the well-known server endpoint
// says that it's a SHOULD and that servers SHOULD just assume that the
// response is JSON regardless... And then there's media wayyyy down in
// the spec doc that just throws a `multipart/mixed` in there.
//
// Media has a special case regarding status codes. Only 200 OK
// responses should have the multipart assertion, as errors are JSON.
let ct = if url.path().starts_with("/_matrix/federation/v1/media/")
&& response.status().is_success()
{
"multipart/mixed"
} else {
"application/json"
};
enforce_content_type(&response, ct)?;
}
let mut http_response_builder = http::Response::builder()
.status(status)
.version(response.version());
@@ -353,6 +385,42 @@ fn handle_error(
Err(e.into())
}
/// Enforces that the `Content-Type` response header is present, and that the
/// first part matches the expected header. This does not enforce that multipart
/// responses have a boundary as only the text left of a semicolon, if present,
/// is compared.
///
/// Returns `M_UNKNOWN` with HTTP 415 (Unsupported Media Type) if the response
/// header is missing or mismatched.
fn enforce_content_type(response: &Response, expected: &str) -> Result<()> {
// N.B. Content type's value is case-insensitive per RFC 9110. The Matrix
// spec explicitly prescribes `application/json` and `multipart/mixed` etc,
// but it's assumed they're intended to be case-insensitive.
debug_assert_eq!(
expected,
expected.to_lowercase(),
"Content type checks should use the lowercase content type"
); // ^ Saves us double-folding
match response
.headers()
.get(&http::header::CONTENT_TYPE)
.and_then(|h| h.to_str().ok())
.map(|h| h.split_once(';').unwrap_or((h, "")).0.to_lowercase())
{
| Some(ct) if ct == expected => Ok(()),
| Some(ct) => Err!(Request(
Unknown(
"Remote server returned the wrong Content-Type: expected {expected}, got {ct:?}"
),
UNSUPPORTED_MEDIA_TYPE
)),
| None => Err!(Request(
Unknown("Remote server did not return a Content-Type header"),
UNSUPPORTED_MEDIA_TYPE
)),
}
}
/// A trait for the input types of acceptable path builders for outgoing
/// federation requests.
///
+11 -10
View File
@@ -92,7 +92,7 @@ impl Service {
/// retry count is incremented and next retry window is updated.
///
/// Does not update the marker if the backoff period is already in effect.
pub fn hit_unhealthy(&self, server_name: OwnedServerName) {
pub fn hit_unhealthy(&self, server_name: OwnedServerName, next_attempt: Option<Duration>) {
if server_name == self.services.server.name {
return;
}
@@ -109,7 +109,8 @@ impl Service {
}
*retries = retries.saturating_add(1);
let next_interval = self.services.server.config.sender_retry_backoff(*retries);
let next_interval = next_attempt
.unwrap_or_else(|| self.services.server.config.sender_retry_backoff(*retries));
*next_retry = millis_from_now(next_interval);
debug!(
"{} is (now) unhealthy ({} retries, blocked until: {})",
@@ -200,14 +201,14 @@ impl Service {
}
match error.status_code() {
// Some special servers account for this specifically
| StatusCode::MISDIRECTED_REQUEST
// Common error codes observed for misdirected requests
// | StatusCode::NOT_FOUND This one can be encountered naturally
| StatusCode::METHOD_NOT_ALLOWED
| StatusCode::IM_A_TEAPOT => true,
_ => false,
}
// Some special servers account for this specifically
| StatusCode::MISDIRECTED_REQUEST
// Common error codes observed for misdirected requests
// | StatusCode::NOT_FOUND This one can be encountered naturally
| StatusCode::METHOD_NOT_ALLOWED
| StatusCode::IM_A_TEAPOT => true,
_ => false,
}
}
/// Returns a clone of the internal remote health tracking map.
+33 -1
View File
@@ -18,7 +18,7 @@ use conduwuit::{
},
warn,
};
use database::Json;
use database::{Deserialized, Ignore, Json};
use futures::{FutureExt, StreamExt, TryStreamExt};
use itertools::Itertools;
use ruma::{
@@ -173,6 +173,9 @@ migration!(stringify!($name) => $name)
// Re-calculates extremities for any rooms that actually lack any
// extremities at all.
migration!(consistency_check_extremity_tracker),
// This is backwards compatible because old versions never read the
// account data entries it removes.
migration!(remove_replaced_account_data),
]
};
@@ -1018,6 +1021,35 @@ async fn remove_unknown_extremities(services: &Services) -> Result {
Ok(())
}
async fn remove_replaced_account_data(services: &Services) -> Result {
type Key = (Option<OwnedRoomId>, OwnedUserId, u64, String);
type Latest = (Ignore, Ignore, u64, Ignore);
let entries = services.db["roomuserdataid_accountdata"].clone();
let latest_of_type = services.db["roomusertype_roomuserdataid"].clone();
let keys: Vec<Key> = entries.keys().ignore_err().collect().await;
let mut removed: usize = 0;
for (room_id, user_id, count, event_type) in &keys {
let latest = latest_of_type
.qry(&(room_id, user_id, event_type))
.await
.deserialized::<Latest>();
if latest.is_ok_and(|(_, _, latest, _)| latest != *count) {
entries.del((room_id, user_id, count, event_type));
removed = removed.saturating_add(1);
}
}
info!(
total = keys.len(),
?removed,
"Removed replaced entries in 'roomuserdataid_accountdata'."
);
Ok(())
}
#[tracing::instrument(skip_all)]
async fn consistency_check_extremity_tracker(services: &Services) -> Result {
let mut rooms = services.rooms.metadata.iter_ids();
+1
View File
@@ -33,6 +33,7 @@ pub mod oidc;
pub mod presence;
pub mod pusher;
pub mod registration_tokens;
pub mod rendezvous;
pub mod rooms;
pub mod sending;
pub mod server_keys;
+37 -5
View File
@@ -106,12 +106,14 @@ impl Display for RequestedScopes {
pub struct RawScopes(String);
impl RawScopes {
const MIN_DEVICE_ID_LENGTH: usize = 5;
#[allow(clippy::trivial_regex)]
pub fn to_scopes(&self) -> Result<RequestedScopes, String> {
let client_api_token_regex =
regex!(r"urn:matrix:(client|org.matrix.msc2967.client):api:\*");
let device_token_regex =
regex!(r"urn:matrix:(client|org.matrix.msc2967.client):device:([a-zA-Z0-9-._~]{5,})");
regex!(r"urn:matrix:(client|org.matrix.msc2967.client):device:(.+)");
let server_administration_regex =
regex!(r"urn:matrix:client:cc.c10y.msc4484.server_administration");
@@ -124,10 +126,40 @@ impl RawScopes {
} else if server_administration_regex.is_match(token) {
scopes.scopes.insert(OAuthClientScope::ServerAdministration)
} else if let Some(captures) = device_token_regex.captures(token) {
scopes
.device_id
.replace(captures.get(2).unwrap().as_str().into())
.is_none()
let device_id = captures.get(2).unwrap().as_str();
if device_id.len() < Self::MIN_DEVICE_ID_LENGTH {
return Err(format!(
"Device ID is too short, it must be at least {} characters",
Self::MIN_DEVICE_ID_LENGTH
));
}
// The Matrix specification has a "suggested" set of
// characters to be used in the device
// ID scope. In the past we checked against this set, but we
// no longer do that; instead we check
// against the _required_ set of
// characters defined by the OAuth specification.
// We do this because we have observed SDKs in the wild
// (*cough* matrix-rust-sdk) that will provide device IDs
// that are just unpadded base64, which they're allowed to
// do, since the spec just says that
// clients "SHOULD" only use the suggested character set and
// servers "MAY" choose to require that they do.
// Of course this actually means that clients will do
// whatever the hell they want and
// servers can never ever be stricter
// than they absolutely have to be. What
// a stupid provision.
if device_id
.chars()
.any(|char| !matches!(char, '\x21' | '\x23'..='\x5b' | '\x5d'..='\x7e'))
{
return Err("Device ID contains disallowed characters".to_owned());
}
scopes.device_id.replace(device_id.into()).is_none()
} else {
continue;
}
+73 -45
View File
@@ -2,17 +2,17 @@ use std::{collections::HashMap, str::FromStr, sync::Arc, time::Duration};
use async_trait::async_trait;
use conduwuit::{
Result,
Result, SyncRwLock,
config::{OidcConfig, OidcProfileKeyImportMode},
debug, err, error, info, warn,
};
use database::{Deserialized, Map};
use lettre::Address;
use openidconnect::{
AdditionalClaims, AuthorizationCode, ClientSecret, CsrfToken, EmptyExtraTokenFields,
EndpointMaybeSet, EndpointNotSet, EndpointSet, IdTokenClaims, IdTokenFields, IssuerUrl,
Nonce, PkceCodeChallenge, PkceCodeVerifier, RedirectUrl, StandardErrorResponse,
StandardTokenResponse, TokenResponse,
AdditionalClaims, AuthorizationCode, ClaimsVerificationError, ClientSecret, CsrfToken,
EmptyExtraTokenFields, EndpointMaybeSet, EndpointNotSet, EndpointSet, IdTokenClaims,
IdTokenFields, IssuerUrl, Nonce, PkceCodeChallenge, PkceCodeVerifier, RedirectUrl,
SignatureVerificationError, StandardErrorResponse, StandardTokenResponse, TokenResponse,
core::{
CoreAuthDisplay, CoreAuthPrompt, CoreAuthenticationFlow, CoreErrorResponseType,
CoreGenderClaim, CoreJsonWebKey, CoreJweContentEncryptionAlgorithm,
@@ -60,7 +60,7 @@ struct Services {
struct OidcClient {
config: OidcConfig,
client_secret: ClientSecret,
machine: SetOnce<OidcClientMachine>,
machine: SetOnce<SyncRwLock<Arc<OidcClientMachine>>>,
client: reqwest::Client,
}
@@ -180,31 +180,10 @@ impl crate::Service for Service {
}
async fn worker(self: Arc<Self>) -> Result {
if let Some(OidcClient { config, client_secret, machine, client }) = &self.client {
let redirect_url = self
.services
.config
.get_client_domain()
.join(&format!("{}/oidc/complete", conduwuit::ROUTE_PREFIX))
.expect("redirect url should be valid");
let provider_metadata = CoreProviderMetadata::discover_async(
IssuerUrl::new(config.discovery_url.clone())
.map_err(|err| err!("Failed to parse OIDC discovery URL: {err}"))?,
client,
)
.await
.map_err(|err| err!("Failed to discover OIDC provider metadata: {err}"))?;
if let Some(OidcClient { machine, .. }) = &self.client {
let discovered = self.discover().await?;
machine
.set(
OidcClientMachine::from_provider_metadata(
provider_metadata,
config.client_id.clone(),
Some(client_secret.clone()),
)
.set_redirect_uri(RedirectUrl::from_url(redirect_url)),
)
.set(SyncRwLock::new(Arc::new(discovered)))
.expect("machine should be empty");
}
@@ -224,6 +203,33 @@ impl Service {
pub fn enabled(&self) -> bool { self.client.is_some() }
async fn discover(&self) -> Result<OidcClientMachine> {
let OidcClient { config, client_secret, client, .. } =
self.client.as_ref().expect("oidc should be configured");
let redirect_url = self
.services
.config
.get_client_domain()
.join(&format!("{}/oidc/complete", conduwuit::ROUTE_PREFIX))
.expect("redirect url should be valid");
let provider_metadata = CoreProviderMetadata::discover_async(
IssuerUrl::new(config.discovery_url.clone())
.map_err(|err| err!("Failed to parse OIDC discovery URL: {err}"))?,
client,
)
.await
.map_err(|err| err!("Failed to discover OIDC provider metadata: {err}"))?;
Ok(OidcClientMachine::from_provider_metadata(
provider_metadata,
config.client_id.clone(),
Some(client_secret.clone()),
)
.set_redirect_uri(RedirectUrl::from_url(redirect_url)))
}
pub fn provider_name(&self) -> Option<String> {
let OidcClient { config, .. } = self.client.as_ref().expect("oidc should be configured");
@@ -253,7 +259,7 @@ impl Service {
pub async fn begin_session(&self, prompt: Option<CoreAuthPrompt>) -> (PendingSession, Url) {
let OidcClient { machine, config, .. } =
self.client.as_ref().expect("oidc should be configured");
let machine = machine.wait().await;
let machine = machine.wait().await.read().clone();
let (pkce_challenge, pkce_verifier) = PkceCodeChallenge::new_random_sha256();
@@ -284,13 +290,13 @@ impl Service {
return Err("Delegated authentication is not enabled on this server.");
};
let machine = machine.wait().await;
let current = machine.wait().await.read().clone();
if session.csrf_token.into_secret() != response.state {
return Err("State mismatch.");
}
let token_response = machine
let token_response = current
.exchange_code(AuthorizationCode::new(response.code))
.expect("machine should be configured correctly")
.set_pkce_verifier(session.pkce_verifier)
@@ -307,19 +313,41 @@ impl Service {
return Err(Self::SERVER_MISCONFIGURED);
};
let verifier = machine
.id_token_verifier()
.set_other_audience_verifier_fn(|audience| {
config.additional_trusted_audiences.contains(audience)
});
let verify = |machine: &OidcClientMachine| {
let verifier =
machine
.id_token_verifier()
.set_other_audience_verifier_fn(|audience| {
config.additional_trusted_audiences.contains(audience)
});
let claims = id_token
.claims(&verifier, &session.nonce)
.map_err(|err| {
error!("Failed to verify id token claims: {err}");
Self::SERVER_MISCONFIGURED
})?
.to_owned();
id_token
.claims(&verifier, &session.nonce)
.map(ToOwned::to_owned)
};
let mut result = verify(&current);
if matches!(
result,
Err(ClaimsVerificationError::SignatureVerification(
SignatureVerificationError::NoMatchingKey
))
) {
match self.discover().await {
| Ok(discovered) => {
info!("Refreshed OIDC provider metadata after an unknown signing key");
result = verify(&discovered);
*machine.wait().await.write() = Arc::new(discovered);
},
| Err(err) => warn!("Failed to refresh OIDC provider metadata: {err}"),
}
}
let claims = result.map_err(|err| {
error!("Failed to verify id token claims: {err}");
Self::SERVER_MISCONFIGURED
})?;
info!(subject = claims.subject().as_str(), "Authenticated subject");
+168
View File
@@ -0,0 +1,168 @@
use std::{
sync::Arc,
time::{Duration, SystemTime},
};
use conduwuit::{Err, Result, SyncMappedMutexGuard, SyncMutex, SyncMutexGuard, at, err, utils};
use lru_cache::LruCache;
use ruma::{
OwnedTransactionId,
api::client::rendezvous::{
create_rendezvous_session, delete_rendezvous_session, get_rendezvous_session,
update_rendezvous_session,
},
};
pub struct Service {
sessions: SyncMutex<LruCache<String, Session>>,
}
struct Session {
data: String,
created_at: SystemTime,
last_sequence_token: String,
transaction_sequences: LruCache<OwnedTransactionId, String>,
}
impl Session {
const SAVED_TRANSACTION_SEQUENCES: usize = 256;
fn new(data: String, sequence_token: String) -> Self {
Self {
data,
created_at: SystemTime::now(),
last_sequence_token: sequence_token,
transaction_sequences: LruCache::new(Self::SAVED_TRANSACTION_SEQUENCES),
}
}
}
impl crate::Service for Service {
fn build(_: crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
sessions: SyncMutex::new(LruCache::new(Self::MAX_SESSIONS)),
}))
}
fn name(&self) -> &str { crate::service::make_name(std::module_path!()) }
}
impl Service {
const MAX_DATA_SIZE_BYTES: usize = 4096;
const MAX_SESSIONS: usize = 256;
const SESSION_MAX_AGE: Duration = Duration::from_secs(300);
const TOKEN_LENGTH: usize = 32;
fn create_token() -> String { utils::random_string(Self::TOKEN_LENGTH) }
/// Lock and fetch an unexpired rendezvous session.
fn lock_session(&self, id: &str) -> Result<SyncMappedMutexGuard<'_, Session>> {
// We don't clear out expired sessions manually, the LRU cache will
// evict them over time
SyncMutexGuard::try_map_or_err(self.sessions.lock(), |sessions| {
sessions
.get_mut(id)
.filter(|session| {
SystemTime::now()
.duration_since(session.created_at)
.is_ok_and(|duration| duration < Self::SESSION_MAX_AGE)
})
.ok_or_else(|| err!(Request(NotFound("Unknown session"))))
})
.map_err(at!(1))
}
/// Create a fresh rendezvous session.
pub fn create_session(
&self,
data: String,
) -> Result<create_rendezvous_session::msc4388::Response> {
if data.len() > Self::MAX_DATA_SIZE_BYTES {
return Err!(Request(TooLarge("Data too large")));
}
let id = Self::create_token();
let sequence_token = Self::create_token();
self.sessions
.lock()
.insert(id.clone(), Session::new(data, sequence_token.clone()));
Ok(create_rendezvous_session::msc4388::Response::new(
id,
sequence_token,
Self::SESSION_MAX_AGE,
))
}
/// Update a rendezvous session with new data.
pub fn update_session(
&self,
id: &str,
transaction: OwnedTransactionId,
sequence_token: String,
data: String,
) -> Result<update_rendezvous_session::msc4388::Response> {
let mut session = self.lock_session(id)?;
if data.len() > Self::MAX_DATA_SIZE_BYTES {
return Err!(Request(TooLarge("Data too large")));
}
// If the provided transaction ID was used already, we have to return
// the sequence token that we returned last time it was used.
// This makes session updates with the same transaction ID idempotent.
if let Some(sequence_token) = session.transaction_sequences.get_mut(&transaction) {
return Ok(update_rendezvous_session::msc4388::Response::new(
sequence_token.to_owned(),
));
}
if session.last_sequence_token != sequence_token {
return Err!(Request(ConcurrentWrite("Sequence token mismatch")));
}
drop(sequence_token);
let new_sequence_token = Self::create_token();
session.data = data;
session.last_sequence_token.clone_from(&new_sequence_token);
session
.transaction_sequences
.insert(transaction, new_sequence_token.clone());
Ok(update_rendezvous_session::msc4388::Response::new(new_sequence_token))
}
/// Look up a rendezvous session by ID.
pub fn get_session(&self, id: &str) -> Result<get_rendezvous_session::msc4388::Response> {
let session = self.lock_session(id)?;
let session_age = SystemTime::now()
.duration_since(session.created_at)
.unwrap_or(Duration::MAX);
let session_time_remaining = Self::SESSION_MAX_AGE.saturating_sub(session_age);
Ok(get_rendezvous_session::msc4388::Response::new(
session.last_sequence_token.clone(),
session.data.clone(),
session_time_remaining,
))
}
/// Delete a rendezvous session.
pub fn delete_session(
&self,
id: &str,
) -> Result<delete_rendezvous_session::msc4388::Response> {
let mut sessions = self.sessions.lock();
if sessions.remove(id).is_some() {
Ok(delete_rendezvous_session::msc4388::Response::new())
} else {
Err!(Request(NotFound("Unknown session")))
}
}
}
@@ -15,6 +15,9 @@ use ruma::{OwnedEventId, RoomId, room_version_rules::RoomVersionRules};
use crate::rooms::short::ShortStateHash;
#[cfg(test)]
mod tests;
impl super::Service {
/// Resolves the state before the incoming event.
///
@@ -124,7 +127,7 @@ impl super::Service {
.pdu_shortstatehash(prev_eventid)
.map_ok(move |sstatehash| (sstatehash, prev_event))
})
.try_collect::<HashMap<_, _>>()
.try_collect::<Vec<_>>()
.inspect_err(|e| debug_error!("failed to calculate N-degree short state hashes: {e}"))
.await
else {
@@ -0,0 +1,277 @@
use std::sync::Arc;
use conduwuit::{
Config, PduEvent, Server,
log::{Log, LogLevelReloadHandles},
metrics::Metrics,
};
use futures::StreamExt;
use ruma::{RoomId, RoomVersionId, events::StateEventType};
use serde_json::json;
#[tokio::test]
async fn admitted_joins_do_not_disappear_after_a_merge() {
use conduwuit::matrix::PartialPdu;
use ruma::{
UserId,
events::room::{
join_rules::{JoinRule, RoomJoinRulesEventContent},
member::{MembershipState, RoomMemberEventContent},
},
};
let (services, path) = test_services().await;
let alice = UserId::parse("@alice:test.example").unwrap();
let bob = UserId::parse("@bob:bob.example").unwrap();
let charlie = UserId::parse("@charlie:charlie.example").unwrap();
let dave = UserId::parse("@dave:dave.example").unwrap();
let mut remote_keys = Vec::new();
for user in [&bob, &charlie, &dave] {
let key = ruma::signatures::Ed25519KeyPair::from_der(
&ruma::signatures::Ed25519KeyPair::generate(),
"test".into(),
)
.unwrap();
cache_key(&services, user.server_name(), &key);
remote_keys.push(key);
}
let bootstrap = services
.rooms
.state
.mutex
.lock("!bootstrap:test.example")
.await;
let create_id = services
.rooms
.timeline
.build_and_append_pdu(
PartialPdu {
event_type: "m.room.create".into(),
content: serde_json::value::to_raw_value(&json!({ "room_version": "12" }))
.unwrap(),
state_key: Some("".into()),
..Default::default()
},
&alice,
None,
&bootstrap,
)
.await
.unwrap();
drop(bootstrap);
let room = RoomId::parse(create_id.as_str().replacen('$', "!", 1)).unwrap();
let lock = services.rooms.state.mutex.lock(&room).await;
services
.rooms
.timeline
.build_and_append_pdu(
PartialPdu::state(
alice.to_string(),
&RoomMemberEventContent::new(MembershipState::Join),
),
&alice,
Some(&room),
&lock,
)
.await
.unwrap();
let rules_id = services
.rooms
.timeline
.build_and_append_pdu(
PartialPdu::state("", &RoomJoinRulesEventContent::new(JoinRule::Public)),
&alice,
Some(&room),
&lock,
)
.await
.unwrap();
drop(lock);
let rules = services.rooms.timeline.get_pdu(&rules_id).await.unwrap();
let (dave_join, json) = signed_remote_event(
json!({
"room_id": room, "sender": dave, "type": "m.room.member", "state_key": dave,
"content": { "membership": "join" }, "auth_events": [rules_id], "prev_events": [rules_id],
"depth": rules.depth + ruma::uint!(1), "origin_server_ts": conduwuit::utils::millis_since_unix_epoch(),
}),
dave.server_name(),
&remote_keys[2],
);
assert!(
services
.rooms
.event_handler
.handle_incoming_pdu(dave.server_name(), &room, &dave_join.event_id, json, false)
.await
.unwrap()
.is_some()
);
let mut joins = Vec::new();
for (user, key) in [&bob, &charlie].into_iter().zip(&remote_keys) {
let signed = signed_remote_event(
json!({
"room_id": room, "sender": user, "type": "m.room.member", "state_key": user,
"content": { "membership": "join" }, "auth_events": [rules_id], "prev_events": [dave_join.event_id],
"depth": dave_join.depth + ruma::uint!(1), "origin_server_ts": conduwuit::utils::millis_since_unix_epoch(),
}),
user.server_name(),
key,
);
joins.push(signed);
}
for ((pdu, json), user) in joins.iter().zip([&bob, &charlie]) {
let accepted = services
.rooms
.event_handler
.handle_incoming_pdu(user.server_name(), &room, &pdu.event_id, json.clone(), false)
.await
.unwrap();
assert!(accepted.is_some());
}
let bob_hash = services
.rooms
.state_accessor
.pdu_shortstatehash(&joins[0].0.event_id)
.await
.unwrap();
let charlie_hash = services
.rooms
.state_accessor
.pdu_shortstatehash(&joins[1].0.event_id)
.await
.unwrap();
assert_eq!(bob_hash, charlie_hash);
let (merge, json) = signed_remote_event(
json!({
"room_id": room, "sender": dave, "type": "m.room.message",
"content": { "msgtype": "m.text", "body": "merge" },
"auth_events": [dave_join.event_id],
"prev_events": [joins[0].0.event_id, joins[1].0.event_id],
"depth": joins[0].0.depth + ruma::uint!(1),
"origin_server_ts": conduwuit::utils::millis_since_unix_epoch(),
}),
dave.server_name(),
&remote_keys[2],
);
assert!(
services
.rooms
.event_handler
.handle_incoming_pdu(dave.server_name(), &room, &merge.event_id, json, false)
.await
.unwrap()
.is_some()
);
let mut results = Vec::new();
for ((user, key), (join, _)) in [&bob, &charlie].into_iter().zip(&remote_keys).zip(&joins) {
let membership = services
.rooms
.state_accessor
.room_state_get_content::<RoomMemberEventContent>(
&room,
&StateEventType::RoomMember,
user.as_str(),
)
.await
.unwrap();
assert_eq!(membership.membership, MembershipState::Join);
let prev_events = services
.rooms
.state
.get_forward_extremities(&room)
.collect::<Vec<_>>()
.await;
let depth = services
.rooms
.timeline
.get_pdu(&prev_events[0])
.await
.unwrap()
.depth
+ ruma::uint!(1);
let (message, json) = signed_remote_event(
json!({
"room_id": room, "sender": user, "type": "m.room.message",
"content": { "msgtype": "m.text", "body": format!("message from {user}") },
"auth_events": [join.event_id], "prev_events": prev_events,
"depth": depth, "origin_server_ts": conduwuit::utils::millis_since_unix_epoch(),
}),
user.server_name(),
key,
);
let result = services
.rooms
.event_handler
.handle_incoming_pdu(user.server_name(), &room, &message.event_id, json, false)
.await;
results.push(result.is_ok_and(|pdu| pdu.is_some()));
}
services.stop().await;
drop(services);
std::fs::remove_dir_all(path).unwrap();
assert_eq!(results, [true, true], "both joined users must be able to send messages");
}
async fn test_services() -> (Arc<crate::Services>, std::path::PathBuf) {
let _ = rustls::crypto::ring::default_provider().install_default();
let path = std::env::temp_dir()
.join(format!("continuwuity-shared-state-{:016x}", rand::random::<u64>()));
std::fs::create_dir(&path).unwrap();
let config: Config = serde_json::from_value(json!({
"server_name": "test.example",
"database_path": path,
"db_cache_capacity_mb": 16.0,
"rocksdb_write_buffer_capacity_mb": 4.0,
"allow_local_presence": false,
"dns_servers": ["127.0.0.1"],
"allow_invalid_tls_certificates_yes_i_know_what_the_fuck_i_am_doing_with_this_and_i_know_this_is_insecure": true
}))
.unwrap();
let runtime = tokio::runtime::Handle::current();
let server = Arc::new(Server::new(
config,
Some(runtime.clone()),
Log {
reload: LogLevelReloadHandles::default(),
capture: Arc::default(),
},
Metrics::new(Some(runtime), opentelemetry::global::meter("test"), None),
));
let services = crate::Services::build(server).await.unwrap();
(services, path)
}
fn cache_key(
services: &crate::Services,
server: &ruma::ServerName,
key: &ruma::signatures::Ed25519KeyPair,
) {
let mut response = ruma::api::federation::discovery::ServerSigningKeys::new(
server.to_owned(),
crate::server_keys::in_one_week(),
);
let id: ruma::OwnedServerSigningKeyId =
format!("ed25519:{}", key.version()).try_into().unwrap();
response.verify_keys.insert(
id.clone(),
ruma::api::federation::discovery::VerifyKey::new(ruma::serde::Base64::new(
key.public_key().to_vec(),
)),
);
services.db["servernamekeyid_response"]
.put((server.as_str(), id.as_str()), database::Json(&response));
}
fn signed_remote_event(
value: serde_json::Value,
server: &ruma::ServerName,
key: &ruma::signatures::Ed25519KeyPair,
) -> (PduEvent, ruma::CanonicalJsonObject) {
let rules = RoomVersionId::V12.rules().unwrap();
let mut value = serde_json::from_value(value).unwrap();
ruma::signatures::hash_and_sign_event(server.as_str(), key, &mut value, &rules.redaction)
.unwrap();
let id = conduwuit::matrix::event::gen_event_id(&value, &rules).unwrap();
let pdu = PduEvent::from_id_val(&id, value.clone()).unwrap();
(pdu, value)
}
+3
View File
@@ -221,6 +221,9 @@ impl Service {
// We couldn't authorize a local join, probably because it's
// restricted and we couldn't satisfy
// the join rules ourselves.
if servers.is_empty() {
return Err(err);
}
info!(?err, "Failed to join room locally, trying over federation instead");
},
}
+1 -1
View File
@@ -666,7 +666,7 @@ impl Service {
return Accessibility::NotFound;
}
let request = assign!(get_stripped_state::unstable::Request::new(room_id.to_owned()), {
let request = assign!(get_stripped_state::msc4560::Request::new(room_id.to_owned()), {
state: state.to_owned(),
num_joined_members
});
+55 -2
View File
@@ -3,11 +3,18 @@ use std::sync::Arc;
use conduwuit::{
Err, PduCount, PduEvent, Result, at, err,
result::NotFound,
utils::{self, stream::TryReadyExt},
utils::{
self,
stream::{ReadyExt, TryReadyExt},
},
};
use database::{Database, Deserialized, Json, KeyVal, Map};
use futures::{FutureExt, Stream, TryFutureExt, TryStreamExt, future::select_ok, pin_mut};
use futures::{
FutureExt, Stream, StreamExt, TryFutureExt, TryStreamExt, future::select_ok, pin_mut,
};
use ruma::{CanonicalJsonObject, EventId, OwnedUserId, RoomId, api::Direction};
use serde::{Deserialize, Serialize};
use serde_json::value::RawValue as RawJsonValue;
use super::{PduId, RawPduId};
use crate::{Dep, rooms, rooms::short::ShortRoomId};
@@ -16,6 +23,7 @@ pub(super) struct Data {
eventid_outlierpdu: Arc<Map>,
eventid_pduid: Arc<Map>,
pduid_pdu: Arc<Map>,
pduid_unredactedcontent: Arc<Map>,
roomid_lasttimelinecount: Arc<Map>,
userroomid_highlightcount: Arc<Map>,
userroomid_notificationcount: Arc<Map>,
@@ -29,6 +37,12 @@ struct Services {
pub type PdusIterItem = (PduCount, PduEvent);
#[derive(Deserialize, Serialize)]
pub(super) struct UnredactedContent {
pub(super) created: u64,
pub(super) content: Box<RawJsonValue>,
}
impl Data {
pub(super) fn new(args: &crate::Args<'_>) -> Self {
let db = &args.db;
@@ -36,6 +50,7 @@ impl Data {
eventid_outlierpdu: db["eventid_outlierpdu"].clone(),
eventid_pduid: db["eventid_pduid"].clone(),
pduid_pdu: db["pduid_pdu"].clone(),
pduid_unredactedcontent: db["pduid_unredactedcontent"].clone(),
roomid_lasttimelinecount: db["roomid_lasttimelinecount"].clone(),
userroomid_highlightcount: db["userroomid_highlightcount"].clone(),
userroomid_notificationcount: db["userroomid_notificationcount"].clone(),
@@ -234,6 +249,44 @@ impl Data {
Ok(())
}
pub(super) fn save_unredacted_content(&self, pdu_id: &RawPduId, content: &RawJsonValue) {
let entry = UnredactedContent {
created: utils::millis_since_unix_epoch(),
content: content.to_owned(),
};
self.pduid_unredactedcontent.raw_put(pdu_id, Json(&entry));
}
pub(super) async fn get_unredacted_content(
&self,
pdu_id: &RawPduId,
) -> Result<UnredactedContent> {
self.pduid_unredactedcontent
.get(pdu_id)
.await
.deserialized()
}
pub(super) async fn purge_unredacted_content(&self, cutoff: u64) -> usize {
let expired: Vec<_> = self
.pduid_unredactedcontent
.raw_stream()
.ready_filter_map(Result::ok)
.ready_filter_map(|(key, val)| {
let entry: UnredactedContent = serde_json::from_slice(val).ok()?;
(entry.created < cutoff).then(|| key.to_vec())
})
.collect()
.await;
for key in &expired {
self.pduid_unredactedcontent.remove(key);
}
expired.len()
}
/// Returns an iterator over all events and their tokens in a room that
/// happened before the event with id `until` in reverse-chronological
/// order.
+53 -3
View File
@@ -6,17 +6,17 @@ mod data;
mod helpers;
mod redact;
use std::{fmt::Write, sync::Arc};
use std::{fmt::Write, sync::Arc, time::Duration};
use async_trait::async_trait;
pub use conduwuit_core::matrix::pdu::{PduId, RawPduId};
use conduwuit_core::{
Result, Server, at, err,
Err, Result, Server, at, debug, err,
matrix::{
event::Event,
pdu::{PduCount, PduEvent},
},
utils::{MutexMap, MutexMapGuard, future::TryExtExt, stream::TryIgnore},
utils::{self, MutexMap, MutexMapGuard, future::TryExtExt, stream::TryIgnore},
warn,
};
use futures::{Future, Stream, TryStreamExt, pin_mut};
@@ -25,6 +25,11 @@ use ruma::{
events::room::encrypted::Relation,
};
use serde::Deserialize;
use serde_json::value::RawValue as RawJsonValue;
use tokio::{
sync::Notify,
time::{MissedTickBehavior, interval},
};
use self::data::Data;
pub use self::{create::pdu_fits, data::PdusIterItem};
@@ -56,6 +61,7 @@ struct ExtractBody {
}
pub struct Service {
interrupt: Notify,
services: Services,
db: Data,
pub mutex_insert: RoomMutexMap,
@@ -87,6 +93,8 @@ struct Services {
users: Dep<users::Service>,
}
const PURGE_INTERVAL_SECS: u64 = 3600;
type RoomMutexMap = MutexMap<OwnedRoomId, ()>;
pub type RoomMutexGuard = MutexMapGuard<OwnedRoomId, ()>;
@@ -124,9 +132,35 @@ impl crate::Service for Service {
},
db: Data::new(&args),
mutex_insert: RoomMutexMap::new(),
interrupt: Notify::new(),
}))
}
#[tracing::instrument(skip_all, name = "unredacted_content_purge", level = "debug")]
async fn worker(self: Arc<Self>) -> Result<()> {
// Runs while disabled too, so old retained content still ages out.
let mut i = interval(Duration::from_secs(PURGE_INTERVAL_SECS));
i.set_missed_tick_behavior(MissedTickBehavior::Delay);
loop {
tokio::select! {
() = self.interrupt.notified() => break,
_ = i.tick() => (),
}
let purged = self
.db
.purge_unredacted_content(self.unredacted_content_cutoff())
.await;
if purged > 0 {
debug!("Purged {purged} expired unredacted event contents");
}
}
Ok(())
}
fn interrupt(&self) { self.interrupt.notify_waiters(); }
async fn memory_usage(&self, out: &mut (dyn Write + Send)) -> Result {
let mutex_insert = self.mutex_insert.len();
writeln!(out, "insert_mutex: {mutex_insert}")?;
@@ -242,6 +276,22 @@ impl Service {
self.db.replace_pdu(pdu_id, pdu_json).await
}
pub async fn get_unredacted_content(&self, pdu_id: &RawPduId) -> Result<Box<RawJsonValue>> {
let entry = self.db.get_unredacted_content(pdu_id).await?;
if entry.created < self.unredacted_content_cutoff() {
return Err!(Request(NotFound("Unredacted content has expired.")));
}
Ok(entry.content)
}
fn unredacted_content_cutoff(&self) -> u64 {
let max_age = self.services.config.unredacted_content_max_age_secs;
utils::millis_since_unix_epoch().saturating_sub(max_age.saturating_mul(1000))
}
/// Returns an iterator over all PDUs in a room. Unknown rooms produce no
/// items.
#[inline]
+15 -1
View File
@@ -4,7 +4,7 @@ use conduwuit_core::{
utils::{self},
warn,
};
use ruma::{EventId, events::room::encrypted::Relation};
use ruma::{EventId, events::room::encrypted::Relation, signatures::content_hash};
use super::{ExtractBody, ExtractRelatesTo};
use crate::rooms::short::ShortRoomId;
@@ -52,6 +52,20 @@ impl super::Service {
.get_room_version(&pdu.room_id_or_hash())
.await?;
if self
.services
.config
.allow_moderators_to_view_redacted_content
{
let mut pdu_json = self.get_pdu_json_from_id(&pdu_id).await?;
pdu_json.remove("event_id");
if content_hash(&pdu_json)
.is_ok_and(|hash| hash.encode() == pdu.hashes.sha256.trim_end_matches('='))
{
self.db.save_unredacted_content(&pdu_id, &pdu.content);
}
}
pdu.redact(&room_version_id, Some(reason.event_id()))?;
let obj = utils::to_canonical_object(&pdu).map_err(|e| {
+2 -2
View File
@@ -149,10 +149,10 @@ impl Service {
{
debug!("{dest} is now unhealthy & stale due to a connect error: {e:?}");
self.services.federation.mark_destination_stale(dest);
self.services.federation.hit_unhealthy(dest.clone());
self.services.federation.hit_unhealthy(dest.clone(), None);
} else if e.status_code() != StatusCode::OK {
debug!("{dest} is now unhealthy due to error response: {e:?}");
self.services.federation.hit_unhealthy(dest.clone());
self.services.federation.hit_unhealthy(dest.clone(), None);
}
}
Self::handle_response_err(dest, statuses, &e);
+4 -2
View File
@@ -11,8 +11,8 @@ use crate::{
account_data, admin, announcements, antispam, appservice, client, config, emergency,
federation, firstrun, globals, key_backups, mailer,
manager::Manager,
media, moderation, oauth, oidc, presence, pusher, registration_tokens, rooms, sending,
server_keys,
media, moderation, oauth, oidc, presence, pusher, registration_tokens, rendezvous, rooms,
sending, server_keys,
service::{self, Args, Map, Service},
sync, threepid, transactions, uiaa, users,
};
@@ -33,6 +33,7 @@ pub struct Services {
pub presence: Arc<presence::Service>,
pub pusher: Arc<pusher::Service>,
pub registration_tokens: Arc<registration_tokens::Service>,
pub rendezvous: Arc<rendezvous::Service>,
pub rooms: rooms::Service,
pub federation: Arc<federation::Service>,
pub firstrun: Arc<firstrun::Service>,
@@ -89,6 +90,7 @@ impl Services {
presence: build!(presence::Service),
pusher: build!(pusher::Service),
registration_tokens: build!(registration_tokens::Service),
rendezvous: build!(rendezvous::Service),
rooms: rooms::Service {
alias: build!(rooms::alias::Service),
auth_chain: build!(rooms::auth_chain::Service),
+72 -36
View File
@@ -6,7 +6,8 @@ use std::{
use conduwuit::{Result, SyncMutex, trace};
use futures::StreamExt;
use ruma::{
OwnedDeviceId, OwnedRoomId, OwnedUserId, RoomId, UserId, api::client::sync::sync_events::v5,
OwnedDeviceId, OwnedRoomId, OwnedUserId, RoomId, UserId,
api::client::sync::sync_events::msc4186,
};
use tokio::sync::watch;
@@ -24,21 +25,32 @@ struct Services {
#[allow(unused, reason = "TODO refactor")]
struct SlidingSyncCache {
lists: BTreeMap<String, v5::request::List>,
subscriptions: BTreeMap<OwnedRoomId, v5::request::RoomSubscription>,
lists: BTreeMap<String, msc4186::request::List>,
subscriptions: BTreeMap<OwnedRoomId, msc4186::request::RoomSubscription>,
// For every room, the roomsince number
known_rooms: BTreeMap<String, BTreeMap<OwnedRoomId, u64>>,
extensions: v5::request::Extensions,
extensions: msc4186::request::Extensions,
}
/// For every in-scope room, the stream position up to which sticky events
/// have been delivered on this connection.
pub type StickyDelivered = BTreeMap<OwnedRoomId, u64>;
#[derive(Default)]
struct SnakeSyncCache {
lists: BTreeMap<String, v5::request::List>,
subscriptions: BTreeMap<OwnedRoomId, v5::request::RoomSubscription>,
lists: BTreeMap<String, msc4186::request::List>,
subscriptions: BTreeMap<OwnedRoomId, msc4186::request::RoomSubscription>,
known_rooms: BTreeMap<String, BTreeMap<OwnedRoomId, u64>>,
sticky_delivered: StickyDelivered,
acknowledged_pos: u64,
pending: BTreeMap<u64, BTreeMap<String, BTreeMap<OwnedRoomId, u64>>>,
extensions: v5::request::Extensions,
pending: BTreeMap<u64, PendingState>,
extensions: msc4186::request::Extensions,
}
#[derive(Default)]
struct PendingState {
known_rooms: BTreeMap<String, BTreeMap<OwnedRoomId, u64>>,
sticky_delivered: StickyDelivered,
}
impl SnakeSyncCache {
@@ -47,13 +59,19 @@ impl SnakeSyncCache {
}
fn acknowledge(&mut self, pos: u64) {
if let Some(known_rooms) = self.pending.remove(&pos) {
self.known_rooms = known_rooms;
if let Some(pending) = self.pending.remove(&pos) {
self.known_rooms = pending.known_rooms;
self.sticky_delivered = pending.sticky_delivered;
self.acknowledged_pos = pos;
}
}
fn stage_pending(&mut self, pos: u64, known_rooms: BTreeMap<String, BTreeSet<OwnedRoomId>>) {
fn stage_pending(
&mut self,
pos: u64,
known_rooms: BTreeMap<String, BTreeSet<OwnedRoomId>>,
sticky_delivered: StickyDelivered,
) {
let mut pending_rooms = self.known_rooms.clone();
for (list_id, rooms) in known_rooms {
let list = pending_rooms.entry(list_id).or_default();
@@ -61,7 +79,10 @@ impl SnakeSyncCache {
list.insert(room_id, pos);
}
}
self.pending.insert(pos, pending_rooms);
self.pending.insert(pos, PendingState {
known_rooms: pending_rooms,
sticky_delivered,
});
}
}
@@ -177,8 +198,8 @@ impl Service {
&self,
snake_key: &SnakeConnectionsKey,
pos: u64,
request: &mut v5::Request,
) -> BTreeMap<String, BTreeMap<OwnedRoomId, u64>> {
request: &mut msc4186::Request,
) -> (BTreeMap<String, BTreeMap<OwnedRoomId, u64>>, StickyDelivered) {
let mut cache = self.snake_connections.lock();
let cached = Arc::clone(
cache
@@ -190,7 +211,7 @@ impl Service {
cached.acknowledge(pos);
//v5::Request::try_from_http_request(req, path_args);
//msc4186::Request::try_from_http_request(req, path_args);
for (list_id, list) in &mut request.lists {
if let Some(cached_list) = cached.lists.get(list_id) {
list_or_sticky(
@@ -224,18 +245,6 @@ impl Service {
.room_subscriptions
.extend(cached.subscriptions.clone());
request.extensions.e2ee.enabled = request
.extensions
.e2ee
.enabled
.or(cached.extensions.e2ee.enabled);
request.extensions.to_device.enabled = request
.extensions
.to_device
.enabled
.or(cached.extensions.to_device.enabled);
request.extensions.account_data.enabled = request
.extensions
.account_data
@@ -275,9 +284,25 @@ impl Service {
&mut request.extensions.receipts.lists,
cached.extensions.receipts.lists.clone(),
);
some_or_sticky(
&mut request.extensions.sticky_events.enabled,
cached.extensions.sticky_events.enabled,
);
some_or_sticky(
&mut request.extensions.sticky_events.limit,
cached.extensions.sticky_events.limit,
);
some_or_sticky(
&mut request.extensions.sticky_events.rooms,
cached.extensions.sticky_events.rooms.clone(),
);
some_or_sticky(
&mut request.extensions.sticky_events.lists,
cached.extensions.sticky_events.lists.clone(),
);
cached.extensions = request.extensions.clone();
cached.known_rooms.clone()
(cached.known_rooms.clone(), cached.sticky_delivered.clone())
}
pub fn store_snake_sync_pending(
@@ -285,6 +310,7 @@ impl Service {
key: &SnakeConnectionsKey,
pos: u64,
known_rooms: BTreeMap<String, BTreeSet<OwnedRoomId>>,
sticky_delivered: StickyDelivered,
) {
let mut cache = self.snake_connections.lock();
let cached = Arc::clone(
@@ -295,13 +321,13 @@ impl Service {
let cached = &mut cached.lock();
drop(cache);
cached.stage_pending(pos, known_rooms);
cached.stage_pending(pos, known_rooms, sticky_delivered);
}
pub fn update_snake_sync_subscriptions(
&self,
key: &SnakeConnectionsKey,
subscriptions: BTreeMap<OwnedRoomId, v5::request::RoomSubscription>,
subscriptions: BTreeMap<OwnedRoomId, msc4186::request::RoomSubscription>,
) {
let mut cache = self.snake_connections.lock();
let cached = Arc::clone(
@@ -412,10 +438,13 @@ mod tests {
fn pending_rooms_are_committed_only_when_the_response_pos_is_acknowledged() {
let room_id = OwnedRoomId::try_from("!room:example.com").unwrap();
let mut cache = SnakeSyncCache {
pending: BTreeMap::from([(
42,
BTreeMap::from([("list".to_owned(), BTreeMap::from([(room_id, 42)]))]),
)]),
pending: BTreeMap::from([(42, PendingState {
known_rooms: BTreeMap::from([(
"list".to_owned(),
BTreeMap::from([(room_id, 42)]),
)]),
sticky_delivered: StickyDelivered::new(),
})]),
..Default::default()
};
@@ -438,7 +467,11 @@ mod tests {
let dropped = OwnedRoomId::try_from("!dropped:example.com").unwrap();
let mut cache = SnakeSyncCache::default();
let stage = |cache: &mut SnakeSyncCache, pos, rooms: BTreeSet<OwnedRoomId>| {
cache.stage_pending(pos, BTreeMap::from([("all_rooms".to_owned(), rooms)]));
cache.stage_pending(
pos,
BTreeMap::from([("all_rooms".to_owned(), rooms)]),
StickyDelivered::new(),
);
cache.acknowledge(pos);
};
@@ -458,7 +491,10 @@ mod tests {
fn overlapping_responses_accept_either_response_position() {
let mut cache = SnakeSyncCache {
acknowledged_pos: 100,
pending: BTreeMap::from([(200, BTreeMap::new()), (201, BTreeMap::new())]),
pending: BTreeMap::from([
(200, PendingState::default()),
(201, PendingState::default()),
]),
..Default::default()
};
+1 -1
View File
@@ -3,7 +3,7 @@ use conduwuit_database::{Deserialized, Json};
use ruma::{
DeviceId, OwnedDeviceId, UserId,
api::client::dehydrated_device::{
DehydratedDeviceData, put_dehydrated_device::unstable::Request,
DehydratedDeviceData, put_dehydrated_device::msc3814::Request,
},
serde::Raw,
};