mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-16 05:36:50 +00:00
Compare commits
73
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38fb7897bb | ||
|
|
ba0ea752a9 | ||
|
|
c7c54f880a | ||
|
|
c65eb6de91 | ||
|
|
596f269a90 | ||
|
|
49ebbcc63e | ||
|
|
7241150204 | ||
|
|
c66a863bb2 | ||
|
|
6dbe40238d | ||
|
|
77bc7476f3 | ||
|
|
94270e732c | ||
|
|
0bc55cb590 | ||
|
|
0375643ade | ||
|
|
c67f08a208 | ||
|
|
fb3113ea69 | ||
|
|
6f6fba4310 | ||
|
|
9ace03c107 | ||
|
|
304bf69c32 | ||
|
|
2173577bac | ||
|
|
bbf3bd1294 | ||
|
|
dd11fc5a25 | ||
|
|
f1798c004a | ||
|
|
b570420b9f | ||
|
|
0a52421b65 | ||
|
|
79b49134f4 | ||
|
|
4a721dad07 | ||
|
|
3abb32dd75 | ||
|
|
7a6bea70b2 | ||
|
|
b2b9c79927 | ||
|
|
23a3ada393 | ||
|
|
88441a409a | ||
|
|
e21d86161c | ||
|
|
f42955602e | ||
|
|
c7aebd2b52 | ||
|
|
61a50a627b | ||
|
|
76ace2bc09 | ||
|
|
e0d3d12654 | ||
|
|
be2f540a9d | ||
|
|
0368097791 | ||
|
|
4d7a7d6cdc | ||
|
|
d677486100 | ||
|
|
684b83491b | ||
|
|
db83bc4c63 | ||
|
|
bf028274f8 | ||
|
|
779374bb54 | ||
|
|
e217ebb5e0 | ||
|
|
87b2ca81a3 | ||
|
|
a9bb74df6d | ||
|
|
144777dab0 | ||
|
|
60a0784a36 | ||
|
|
a484c28f99 | ||
|
|
f4f0a69fe4 | ||
|
|
fcde5634da | ||
|
|
2edd61062c | ||
|
|
bfabac095f | ||
|
|
d6710a9f00 | ||
|
|
be5ff91eb3 | ||
|
|
5ff6d71e7c | ||
|
|
6782e12231 | ||
|
|
2e43797d95 | ||
|
|
15b4e8e2f9 | ||
|
|
7c451888ae | ||
|
|
1716913b1a | ||
|
|
ce986d9c40 | ||
|
|
6075e6e3ad | ||
|
|
02f96d311b | ||
|
|
1af92add88 | ||
|
|
c3f0d2ffa5 | ||
|
|
02aed4fb23 | ||
|
|
4a3b0366ac | ||
|
|
15f7aabca6 | ||
|
|
a57e0945eb | ||
|
|
b095103e23 |
No files matched your search
@@ -44,7 +44,7 @@ runs:
|
||||
|
||||
- name: Login to builtin registry
|
||||
if: ${{ env.BUILTIN_REGISTRY_ENABLED == 'true' }}
|
||||
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4
|
||||
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4
|
||||
with:
|
||||
registry: ${{ env.BUILTIN_REGISTRY }}
|
||||
username: ${{ inputs.registry_user }}
|
||||
|
||||
@@ -79,7 +79,7 @@ runs:
|
||||
|
||||
- name: Login to builtin registry
|
||||
if: ${{ env.BUILTIN_REGISTRY_ENABLED == 'true' }}
|
||||
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4
|
||||
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4
|
||||
with:
|
||||
registry: ${{ env.BUILTIN_REGISTRY }}
|
||||
username: ${{ inputs.registry_user }}
|
||||
|
||||
@@ -7,7 +7,7 @@ runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Install sccache
|
||||
uses: https://forgejo.ellis.link/continuwuation/sccache-action@v1
|
||||
uses: https://forgejo.ellis.link/continuwuation/sccache-action@b5ae5b4541ed5fb0f616e3cb616bf213fefa1c40 # v1
|
||||
- name: Configure sccache
|
||||
uses: https://github.com/actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
|
||||
with:
|
||||
|
||||
@@ -29,7 +29,7 @@ runs:
|
||||
steps:
|
||||
- name: Detect runner OS
|
||||
id: runner-os
|
||||
uses: https://forgejo.ellis.link/continuwuation/detect-versions@v1
|
||||
uses: https://forgejo.ellis.link/continuwuation/detect-versions@d39555789fed25b8eb8e086d9f199c514dfa311e # v1
|
||||
|
||||
- name: Configure cross-compilation architecture
|
||||
if: inputs.dpkg-arch != ''
|
||||
|
||||
@@ -39,7 +39,7 @@ runs:
|
||||
steps:
|
||||
- name: Detect runner OS
|
||||
id: runner-os
|
||||
uses: https://forgejo.ellis.link/continuwuation/detect-versions@v1
|
||||
uses: https://forgejo.ellis.link/continuwuation/detect-versions@d39555789fed25b8eb8e086d9f199c514dfa311e # v1
|
||||
|
||||
- name: Configure Cargo environment
|
||||
shell: bash
|
||||
@@ -147,7 +147,7 @@ runs:
|
||||
run: echo "::group::📦 Restoring build cache"
|
||||
|
||||
- name: Setup sccache
|
||||
uses: https://forgejo.ellis.link/continuwuation/sccache-action@v1
|
||||
uses: https://forgejo.ellis.link/continuwuation/sccache-action@b5ae5b4541ed5fb0f616e3cb616bf213fefa1c40 # v1
|
||||
|
||||
- name: End build cache restore group
|
||||
shell: bash
|
||||
|
||||
@@ -71,7 +71,7 @@ runs:
|
||||
|
||||
- name: Install timelord-cli and git-warp-time
|
||||
if: steps.check-binaries.outputs.need-install == 'true'
|
||||
uses: https://github.com/taiki-e/install-action@682ce6c3c696a4cd5168a05f98e51aa02b877941 # v2
|
||||
uses: https://github.com/taiki-e/install-action@cfdb7ed4ccc7c7dce37759eae89dc5674b469b39 # v2
|
||||
with:
|
||||
tool: git-warp-time,timelord-cli@3.0.1
|
||||
|
||||
|
||||
@@ -4,11 +4,6 @@ on:
|
||||
pull_request_target:
|
||||
types: [opened, reopened]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
issues: write
|
||||
|
||||
jobs:
|
||||
auto-label:
|
||||
name: Apply labels based on changed files
|
||||
|
||||
@@ -60,7 +60,7 @@ jobs:
|
||||
cargo-debian-${{ steps.debian-version.outputs.distribution }}-${{ matrix.arch }}-
|
||||
|
||||
- name: Setup sccache
|
||||
uses: https://forgejo.ellis.link/continuwuation/sccache-action@v1
|
||||
uses: https://forgejo.ellis.link/continuwuation/sccache-action@b5ae5b4541ed5fb0f616e3cb616bf213fefa1c40 # v1
|
||||
|
||||
- name: Configure sccache environment
|
||||
run: |
|
||||
|
||||
@@ -54,8 +54,6 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- build
|
||||
permissions:
|
||||
contents: write
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
steps:
|
||||
- name: Download binary artifacts
|
||||
@@ -65,7 +63,7 @@ jobs:
|
||||
path: binaries
|
||||
merge-multiple: true
|
||||
- name: Create Release and Upload
|
||||
uses: https://github.com/softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3
|
||||
uses: https://github.com/softprops/action-gh-release@8a0cd651e5b2365bd640854a3fa5dfc70e4875f3 # v3
|
||||
with:
|
||||
draft: true
|
||||
files: binaries/*
|
||||
@@ -4,11 +4,6 @@ on:
|
||||
pull_request_target:
|
||||
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
issues: write
|
||||
|
||||
jobs:
|
||||
check-changelog:
|
||||
name: Check changelog is added
|
||||
|
||||
@@ -28,7 +28,7 @@ jobs:
|
||||
|
||||
- name: Detect runner environment
|
||||
id: runner-env
|
||||
uses: https://forgejo.ellis.link/continuwuation/detect-versions@v1
|
||||
uses: https://forgejo.ellis.link/continuwuation/detect-versions@d39555789fed25b8eb8e086d9f199c514dfa311e # v1
|
||||
|
||||
- name: Setup Node.js
|
||||
if: steps.runner-env.outputs.node_major == '' || steps.runner-env.outputs.node_major < '20'
|
||||
|
||||
@@ -7,10 +7,6 @@ on:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
|
||||
jobs:
|
||||
fast-checks:
|
||||
name: Pre-commit & Formatting
|
||||
|
||||
@@ -31,11 +31,6 @@ jobs:
|
||||
build-release:
|
||||
name: "Build ${{ matrix.slug }} (release)"
|
||||
runs-on: dind
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
attestations: write
|
||||
id-token: write
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
@@ -84,6 +79,7 @@ jobs:
|
||||
outputs: |
|
||||
${{ env.BUILTIN_REGISTRY_ENABLED == 'true' && format('type=image,"name={0}",push-by-digest=true,name-canonical=true,push=true', env.IMAGE_PATH) || format('type=image,"name={0}",push=false', env.IMAGE_PATH) }}
|
||||
type=local,dest=/tmp/binaries
|
||||
pull: true # Base images were becoming out of date
|
||||
env:
|
||||
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
|
||||
- name: Upload Docker artifacts
|
||||
@@ -117,11 +113,6 @@ jobs:
|
||||
name: "Build ${{ matrix.slug }} (max-perf)"
|
||||
runs-on: dind
|
||||
needs: build-release
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
attestations: write
|
||||
id-token: write
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
@@ -172,6 +163,7 @@ jobs:
|
||||
outputs: |
|
||||
${{ env.BUILTIN_REGISTRY_ENABLED == 'true' && format('type=image,"name={0}",push-by-digest=true,name-canonical=true,push=true', env.IMAGE_PATH) || format('type=image,"name={0}",push=false', env.IMAGE_PATH) }}
|
||||
type=local,dest=/tmp/binaries
|
||||
pull: true # Base images were becoming out of date
|
||||
env:
|
||||
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
|
||||
- name: Upload max-perf Docker artifacts
|
||||
@@ -207,8 +199,6 @@ jobs:
|
||||
needs:
|
||||
- build-release
|
||||
- build-maxperf
|
||||
permissions:
|
||||
contents: write
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
steps:
|
||||
- name: Download binary artifacts
|
||||
@@ -218,7 +208,7 @@ jobs:
|
||||
path: binaries
|
||||
merge-multiple: true
|
||||
- name: Create Release and Upload
|
||||
uses: https://github.com/softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3
|
||||
uses: https://github.com/softprops/action-gh-release@8a0cd651e5b2365bd640854a3fa5dfc70e4875f3 # v3
|
||||
with:
|
||||
draft: true
|
||||
files: binaries/*
|
||||
|
||||
@@ -32,7 +32,7 @@ repos:
|
||||
stages: [ commit-msg ]
|
||||
|
||||
- repo: https://github.com/crate-ci/committed
|
||||
rev: v1.1.11
|
||||
rev: v1.1.12
|
||||
hooks:
|
||||
- id: committed
|
||||
|
||||
|
||||
@@ -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
+589
-576
File diff suppressed because it is too large.
Load diff
+79
-66
@@ -12,17 +12,17 @@ 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"
|
||||
|
||||
[workspace.dependencies.arrayvec]
|
||||
version = "0.7.6"
|
||||
version = "0.7.8"
|
||||
features = ["serde"]
|
||||
|
||||
[workspace.dependencies.smallvec]
|
||||
version = "1.14.0"
|
||||
version = "1.16.5"
|
||||
features = [
|
||||
"const_generics",
|
||||
"const_new",
|
||||
@@ -39,10 +39,10 @@ features = ["ffi", "std", "union"]
|
||||
version = "1.1.0"
|
||||
|
||||
[workspace.dependencies.ctor]
|
||||
version = "1.0.6"
|
||||
version = "1.0.13"
|
||||
|
||||
[workspace.dependencies.dtor]
|
||||
version = "1.0.0"
|
||||
version = "1.0.6"
|
||||
|
||||
[workspace.dependencies.cargo_toml]
|
||||
version = "1.0"
|
||||
@@ -50,7 +50,7 @@ default-features = false
|
||||
features = ["features"]
|
||||
|
||||
[workspace.dependencies.toml]
|
||||
version = "1.1.2"
|
||||
version = "1.2.1"
|
||||
default-features = false
|
||||
features = ["parse", "serde"]
|
||||
|
||||
@@ -58,7 +58,7 @@ features = ["parse", "serde"]
|
||||
version = "0.6.0"
|
||||
|
||||
[workspace.dependencies.base64]
|
||||
version = "0.23.0"
|
||||
version = "0.23.1"
|
||||
default-features = false
|
||||
|
||||
# used for TURN server authentication
|
||||
@@ -71,36 +71,36 @@ version = "0.5.0"
|
||||
default-features = false
|
||||
|
||||
[workspace.dependencies.p256]
|
||||
version = "0.13.2"
|
||||
version = "0.14.0"
|
||||
default-features = false
|
||||
features = ["ecdsa", "std"]
|
||||
|
||||
# used for checking if an IP is in specific subnets / CIDR ranges easier
|
||||
[workspace.dependencies.ipaddress]
|
||||
version = "0.2.0"
|
||||
version = "0.2.11"
|
||||
|
||||
[workspace.dependencies.rand]
|
||||
version = "0.10.1"
|
||||
version = "0.10.3"
|
||||
|
||||
# Used for the http request / response body type for Ruma endpoints used with reqwest
|
||||
[workspace.dependencies.bytes]
|
||||
version = "1.10.1"
|
||||
version = "1.12.1"
|
||||
|
||||
[workspace.dependencies.http-body-util]
|
||||
version = "0.1.3"
|
||||
version = "0.1.5"
|
||||
|
||||
[workspace.dependencies.http]
|
||||
version = "1.3.1"
|
||||
version = "1.5.0"
|
||||
|
||||
# parses the HTTP-date form of Retry-After
|
||||
[workspace.dependencies.httpdate]
|
||||
version = "1.0.3"
|
||||
|
||||
[workspace.dependencies.regex]
|
||||
version = "1.11.1"
|
||||
version = "1.13.1"
|
||||
|
||||
[workspace.dependencies.axum]
|
||||
version = "0.8.8"
|
||||
version = "0.8.9"
|
||||
default-features = false
|
||||
features = [
|
||||
"form",
|
||||
@@ -114,7 +114,7 @@ features = [
|
||||
]
|
||||
|
||||
[workspace.dependencies.axum-extra]
|
||||
version = "0.12.0"
|
||||
version = "0.12.6"
|
||||
default-features = false
|
||||
features = ["typed-header", "tracing", "cookie"]
|
||||
|
||||
@@ -133,12 +133,12 @@ default-features = false
|
||||
version = "0.2"
|
||||
|
||||
[workspace.dependencies.tower]
|
||||
version = "0.5.2"
|
||||
version = "0.5.3"
|
||||
default-features = false
|
||||
features = ["util"]
|
||||
|
||||
[workspace.dependencies.tower-http]
|
||||
version = "0.7.0"
|
||||
version = "0.7.1"
|
||||
default-features = false
|
||||
features = [
|
||||
"add-extension",
|
||||
@@ -152,38 +152,46 @@ features = [
|
||||
]
|
||||
|
||||
[workspace.dependencies.rustls]
|
||||
version = "0.23.25"
|
||||
version = "0.23.46"
|
||||
default-features = false
|
||||
|
||||
[workspace.dependencies.reqwest]
|
||||
version = "0.13.2"
|
||||
version = "0.13.5"
|
||||
default-features = false
|
||||
features = [
|
||||
"rustls-no-provider",
|
||||
"socks",
|
||||
"hickory-dns",
|
||||
"http2",
|
||||
"stream",
|
||||
"form",
|
||||
]
|
||||
|
||||
# Needed for as long as openidconnect is on an outdated reqwest
|
||||
[workspace.dependencies.reqwest_0_12]
|
||||
package = "reqwest"
|
||||
version = "0.12"
|
||||
default-features = false
|
||||
features = [
|
||||
"rustls-tls-native-roots-no-provider",
|
||||
]
|
||||
|
||||
[workspace.dependencies.serde]
|
||||
version = "1.0.219"
|
||||
version = "1.0.229"
|
||||
default-features = false
|
||||
features = ["rc"]
|
||||
|
||||
[workspace.dependencies.serde_json]
|
||||
version = "1.0.140"
|
||||
version = "1.0.154"
|
||||
default-features = false
|
||||
features = ["raw_value"]
|
||||
|
||||
# Used for appservice registration files
|
||||
[workspace.dependencies.serde-saphyr]
|
||||
version = "1.0.0"
|
||||
version = "2.1.1"
|
||||
|
||||
# Used to load forbidden room/user regex from config
|
||||
[workspace.dependencies.serde_regex]
|
||||
version = "1.1.0"
|
||||
version = "1.2.0"
|
||||
|
||||
# Used for password hashing
|
||||
[workspace.dependencies.argon2]
|
||||
@@ -193,7 +201,7 @@ default-features = false
|
||||
|
||||
# Used to generate thumbnails for images
|
||||
[workspace.dependencies.image]
|
||||
version = "0.25.5"
|
||||
version = "0.25.10"
|
||||
default-features = false
|
||||
features = [
|
||||
"jpeg",
|
||||
@@ -204,29 +212,29 @@ features = [
|
||||
|
||||
# logging
|
||||
[workspace.dependencies.log]
|
||||
version = "0.4.27"
|
||||
version = "0.4.35"
|
||||
default-features = false
|
||||
[workspace.dependencies.tracing]
|
||||
version = "0.1.41"
|
||||
version = "0.1.44"
|
||||
default-features = false
|
||||
[workspace.dependencies.tracing-subscriber]
|
||||
version = "0.3.20"
|
||||
version = "0.3.23"
|
||||
default-features = false
|
||||
features = ["env-filter", "std", "tracing", "tracing-log", "ansi", "fmt"]
|
||||
[workspace.dependencies.tracing-journald]
|
||||
version = "0.3.1"
|
||||
version = "0.3.2"
|
||||
[workspace.dependencies.tracing-core]
|
||||
version = "0.1.34"
|
||||
version = "0.1.36"
|
||||
default-features = false
|
||||
|
||||
# for URL previews
|
||||
[workspace.dependencies.webpage]
|
||||
version = "2.0.1"
|
||||
version = "2.1.0"
|
||||
default-features = false
|
||||
|
||||
# used for conduwuit's CLI and admin room command parsing
|
||||
[workspace.dependencies.clap]
|
||||
version = "4.5.35"
|
||||
version = "4.6.7"
|
||||
default-features = false
|
||||
features = [
|
||||
"derive",
|
||||
@@ -239,12 +247,12 @@ features = [
|
||||
]
|
||||
|
||||
[workspace.dependencies.futures]
|
||||
version = "0.3.31"
|
||||
version = "0.3.34"
|
||||
default-features = false
|
||||
features = ["std", "async-await"]
|
||||
|
||||
[workspace.dependencies.tokio]
|
||||
version = "1.44.2"
|
||||
version = "1.54.1"
|
||||
default-features = false
|
||||
features = [
|
||||
"fs",
|
||||
@@ -259,25 +267,25 @@ features = [
|
||||
]
|
||||
|
||||
[workspace.dependencies.tokio-metrics]
|
||||
version = "0.5.0"
|
||||
version = "0.5.2"
|
||||
|
||||
[workspace.dependencies.libloading]
|
||||
version = "0.9.0"
|
||||
|
||||
# Validating urls in config, was already a transitive dependency
|
||||
[workspace.dependencies.url]
|
||||
version = "2.5.4"
|
||||
version = "2.5.8"
|
||||
default-features = false
|
||||
features = ["serde"]
|
||||
|
||||
# standard date and time tools
|
||||
[workspace.dependencies.chrono]
|
||||
version = "0.4.38"
|
||||
version = "0.4.45"
|
||||
features = ["alloc", "std"]
|
||||
default-features = false
|
||||
|
||||
[workspace.dependencies.hyper]
|
||||
version = "1.6.0"
|
||||
version = "1.12.0"
|
||||
default-features = false
|
||||
features = [
|
||||
"server",
|
||||
@@ -296,7 +304,7 @@ features = [
|
||||
|
||||
# to support multiple variations of setting a config option
|
||||
[workspace.dependencies.either]
|
||||
version = "1.15.0"
|
||||
version = "1.19.0"
|
||||
default-features = false
|
||||
features = ["serde"]
|
||||
|
||||
@@ -307,7 +315,7 @@ default-features = false
|
||||
features = ["env", "toml"]
|
||||
|
||||
[workspace.dependencies.hickory-resolver]
|
||||
version = "0.26.0"
|
||||
version = "0.26.3"
|
||||
default-features = false
|
||||
features = [
|
||||
"serde",
|
||||
@@ -317,7 +325,7 @@ features = [
|
||||
|
||||
# Used for conduwuit::Error type
|
||||
[workspace.dependencies.thiserror]
|
||||
version = "2.0.12"
|
||||
version = "2.0.21"
|
||||
default-features = false
|
||||
|
||||
# Used to make working with iterators easier, was already a transitive depdendency
|
||||
@@ -338,7 +346,7 @@ version = "0.6.0"
|
||||
version = "2.5.0"
|
||||
|
||||
[workspace.dependencies.async-trait]
|
||||
version = "0.1.88"
|
||||
version = "0.1.92"
|
||||
|
||||
[workspace.dependencies.lru-cache]
|
||||
version = "0.1.2"
|
||||
@@ -395,7 +403,7 @@ features = [
|
||||
|
||||
[workspace.dependencies.rust-rocksdb]
|
||||
git = "https://forgejo.ellis.link/continuwuation/rust-rocksdb-zaidoon1"
|
||||
rev = "0a25ff92f7c09b55eec496b9c192c7d5136ab2b8"
|
||||
rev = "6021299f3e0e9455dc3f2e39c65e1dc217be8903"
|
||||
default-features = false
|
||||
features = [
|
||||
"multi-threaded-cf",
|
||||
@@ -406,7 +414,7 @@ features = [
|
||||
]
|
||||
|
||||
[workspace.dependencies.sha2]
|
||||
version = "0.11.0"
|
||||
version = "0.11.1"
|
||||
default-features = false
|
||||
|
||||
[workspace.dependencies.sha1]
|
||||
@@ -414,11 +422,13 @@ version = "0.11.0"
|
||||
default-features = false
|
||||
|
||||
[workspace.dependencies.openidconnect]
|
||||
version = "4.0.1"
|
||||
version = "4.1.0"
|
||||
default-features = false
|
||||
features = ["reqwest"]
|
||||
|
||||
# optional opentelemetry, performance measurements, flamegraphs, etc for performance measurements and monitoring
|
||||
[workspace.dependencies.opentelemetry]
|
||||
version = "0.33.0"
|
||||
version = "0.33.1"
|
||||
|
||||
[workspace.dependencies.opentelemetry-instrumentation-tower]
|
||||
version = "0.19.0"
|
||||
@@ -426,7 +436,7 @@ default-features = false
|
||||
features = ["axum"]
|
||||
|
||||
[workspace.dependencies.opentelemetry-semantic-conventions]
|
||||
version = "0.33.0"
|
||||
version = "0.33.1"
|
||||
features = ["semconv_experimental"]
|
||||
|
||||
[workspace.dependencies.tracing-flame]
|
||||
@@ -436,25 +446,25 @@ version = "0.2.0"
|
||||
version = "0.34.0"
|
||||
|
||||
[workspace.dependencies.opentelemetry_sdk]
|
||||
version = "0.33.0"
|
||||
version = "0.33.1"
|
||||
features = ["rt-tokio"]
|
||||
|
||||
[workspace.dependencies.opentelemetry-prometheus]
|
||||
version = "0.33.0"
|
||||
version = "0.33.1"
|
||||
|
||||
[workspace.dependencies.prometheus]
|
||||
version = "0.14.0"
|
||||
default-features = false
|
||||
|
||||
[workspace.dependencies.opentelemetry-otlp]
|
||||
version = "0.33.0"
|
||||
version = "0.33.1"
|
||||
features = ["http", "grpc-tonic", "trace", "logs", "metrics"]
|
||||
|
||||
|
||||
|
||||
# optional sentry metrics for crash/panic reporting
|
||||
[workspace.dependencies.sentry]
|
||||
version = "0.49.0"
|
||||
version = "0.49.5"
|
||||
default-features = false
|
||||
features = [
|
||||
"backtrace",
|
||||
@@ -469,14 +479,14 @@ features = [
|
||||
]
|
||||
|
||||
[workspace.dependencies.sentry-tracing]
|
||||
version = "0.49.0"
|
||||
version = "0.49.5"
|
||||
[workspace.dependencies.sentry-tower]
|
||||
version = "0.49.0"
|
||||
version = "0.49.5"
|
||||
|
||||
# jemalloc usage
|
||||
[workspace.dependencies.tikv-jemalloc-sys]
|
||||
git = "https://forgejo.ellis.link/continuwuation/jemallocator"
|
||||
rev = "df86ff89d4b1e223b9f7d2dd2fbb7f202da7f554"
|
||||
rev = "ac4d4861b335b199f812807996e8c9166961041a"
|
||||
default-features = false
|
||||
features = [
|
||||
"background_threads_runtime_support",
|
||||
@@ -484,7 +494,7 @@ features = [
|
||||
]
|
||||
[workspace.dependencies.tikv-jemallocator]
|
||||
git = "https://forgejo.ellis.link/continuwuation/jemallocator"
|
||||
rev = "df86ff89d4b1e223b9f7d2dd2fbb7f202da7f554"
|
||||
rev = "ac4d4861b335b199f812807996e8c9166961041a"
|
||||
default-features = false
|
||||
features = [
|
||||
"background_threads_runtime_support",
|
||||
@@ -492,7 +502,7 @@ features = [
|
||||
]
|
||||
[workspace.dependencies.tikv-jemalloc-ctl]
|
||||
git = "https://forgejo.ellis.link/continuwuation/jemallocator"
|
||||
rev = "df86ff89d4b1e223b9f7d2dd2fbb7f202da7f554"
|
||||
rev = "ac4d4861b335b199f812807996e8c9166961041a"
|
||||
default-features = false
|
||||
features = ["use_std"]
|
||||
|
||||
@@ -500,7 +510,7 @@ features = ["use_std"]
|
||||
version = "0.5"
|
||||
|
||||
[workspace.dependencies.nix]
|
||||
version = "0.31.0"
|
||||
version = "0.31.3"
|
||||
default-features = false
|
||||
features = ["resource"]
|
||||
|
||||
@@ -522,7 +532,7 @@ version = "0.4.9"
|
||||
default-features = false
|
||||
|
||||
[workspace.dependencies.termimad]
|
||||
version = "0.35.0"
|
||||
version = "0.35.5"
|
||||
default-features = false
|
||||
|
||||
[workspace.dependencies.checked_ops]
|
||||
@@ -548,7 +558,7 @@ features = ["hardware-lock-elision", "deadlock_detection"] # TODO: Check if dead
|
||||
version = "0.5.0"
|
||||
|
||||
[workspace.dependencies.bytesize]
|
||||
version = "2.0"
|
||||
version = "2.7"
|
||||
|
||||
[workspace.dependencies.core_affinity]
|
||||
version = "0.8.3"
|
||||
@@ -560,11 +570,11 @@ version = "0.2"
|
||||
version = "0.2"
|
||||
|
||||
[workspace.dependencies.minicbor]
|
||||
version = "2.1.1"
|
||||
version = "2.3.1"
|
||||
features = ["std"]
|
||||
|
||||
[workspace.dependencies.minicbor-serde]
|
||||
version = "0.7.0"
|
||||
version = "0.7.2"
|
||||
features = ["std"]
|
||||
|
||||
[workspace.dependencies.maplit]
|
||||
@@ -574,10 +584,10 @@ version = "1.0.2"
|
||||
version = "1.0.1"
|
||||
|
||||
[workspace.dependencies.askama]
|
||||
version = "0.16.0"
|
||||
version = "0.16.1"
|
||||
|
||||
[workspace.dependencies.lettre]
|
||||
version = "0.11.19"
|
||||
version = "0.11.23"
|
||||
default-features = false
|
||||
features = ["smtp-transport", "pool", "hostname", "builder", "rustls", "rustls-native-certs", "tokio1", "rustls-no-provider", "tokio1-rustls", "tracing", "serde"]
|
||||
|
||||
@@ -590,7 +600,7 @@ features = ["std"]
|
||||
version = "0.3.0"
|
||||
|
||||
[workspace.dependencies.resolvematrix]
|
||||
version = "1.3.0"
|
||||
version = "1.4.0"
|
||||
|
||||
[workspace.dependencies.serde_urlencoded]
|
||||
version = "0.7.1"
|
||||
@@ -1010,4 +1020,7 @@ collapsible_if = "allow"
|
||||
cognitive_complexity = "allow"
|
||||
|
||||
[workspace.metadata.cargo-shear]
|
||||
ignored = ["const-str", "ctor", "dtor"]
|
||||
# All of these crates provide macros that are used across the codebase
|
||||
# and that every crate depends on. cargo-shear can't tell this because
|
||||
# it doesn't expand macros.
|
||||
ignored = ["const-str", "ctor", "dtor", "tracing"]
|
||||
+2
-2
@@ -53,7 +53,7 @@ fi
|
||||
|
||||
# The base docker image to use for complement tests
|
||||
# You can build the default with `docker build -t continuwuity:complement -f ./docker/complement.Dockerfile .`
|
||||
# after running `cargo build`. Only the debug binary is used.
|
||||
# after running `cargo build -p conduwuit --features openreg`. Only the debug binary is used.
|
||||
COMPLEMENT_BASE_IMAGE="${COMPLEMENT_BASE_IMAGE:-continuwuity:complement}"
|
||||
|
||||
# Complement tests that are skipped due to flakiness/reliability issues or we don't implement such features and won't for a long time
|
||||
@@ -99,7 +99,7 @@ fi
|
||||
|
||||
if ! docker image inspect "$COMPLEMENT_BASE_IMAGE" > /dev/null 2>&1; then
|
||||
echo "Complement base image not found: $COMPLEMENT_BASE_IMAGE"
|
||||
echo "Build it with: cargo build -p conduwuit && docker build -t $COMPLEMENT_BASE_IMAGE -f docker/complement.Dockerfile ."
|
||||
echo "Build it with: cargo build -p conduwuit --features openreg && docker build -t $COMPLEMENT_BASE_IMAGE -f docker/complement.Dockerfile ."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Upgraded rocksdb from 11.1.1 to 11.12.0 and jemalloc to 5.4.0.
|
||||
@@ -0,0 +1 @@
|
||||
The documentation now refers to the Continuwuity Docker service as `continuwuity` instead of `homeserver`.
|
||||
@@ -0,0 +1 @@
|
||||
Fix incoming federation events losing state changes when predecessors share the same state-before snapshot. Contributed by @eleboucher.
|
||||
@@ -0,0 +1 @@
|
||||
Client-server API endpoints are now properly ratelimited for unauthenticated requests. Contributed by @ginger.
|
||||
@@ -0,0 +1 @@
|
||||
Ensure HTTP clients actually follow the `dns_servers` config option. Contributed by @silversys
|
||||
@@ -0,0 +1 @@
|
||||
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).
|
||||
@@ -0,0 +1 @@
|
||||
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
|
||||
@@ -685,6 +685,13 @@
|
||||
# env: CONTINUWUITY_SENDER_SHUTDOWN_TIMEOUT
|
||||
#sender_shutdown_timeout = 5
|
||||
|
||||
# Maximum number of requests per minute that unauthenticated clients
|
||||
# may make to ratelimited client-server API routes. This ratelimit is
|
||||
# global across all endpoints for each IP.
|
||||
#
|
||||
# env: CONTINUWUITY_UNAUTHENTICATED_REQUEST_RATELIMIT
|
||||
#unauthenticated_request_ratelimit = 30
|
||||
|
||||
# Enables registration. If set to false, no users can register on this
|
||||
# server.
|
||||
#
|
||||
|
||||
+2
-2
@@ -50,7 +50,7 @@ EOF
|
||||
|
||||
# Developer tool versions
|
||||
# renovate: datasource=github-releases depName=cargo-bins/cargo-binstall
|
||||
ENV BINSTALL_VERSION=1.26.1
|
||||
ENV BINSTALL_VERSION=1.26.2
|
||||
# renovate: datasource=github-releases depName=psastras/sbom-rs
|
||||
ENV CARGO_SBOM_VERSION=0.9.1
|
||||
# renovate: datasource=crate depName=lddtree
|
||||
@@ -192,7 +192,7 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
jq -r ".target_directory"))
|
||||
mkdir /out/sbin
|
||||
PACKAGE=conduwuit
|
||||
CARGO_LOG=debug xx-cargo build --locked --profile ${RUST_PROFILE} \
|
||||
xx-cargo build --locked --profile ${RUST_PROFILE} \
|
||||
--no-default-features --features ${CARGO_FEATURES} \
|
||||
-p $PACKAGE;
|
||||
BINARIES=($(cargo metadata --no-deps --format-version 1 | \
|
||||
|
||||
@@ -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.1
|
||||
ENV BINSTALL_VERSION=1.26.2
|
||||
# renovate: datasource=github-releases depName=psastras/sbom-rs
|
||||
ENV CARGO_SBOM_VERSION=0.9.1
|
||||
# renovate: datasource=crate depName=lddtree
|
||||
|
||||
@@ -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
@@ -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
@@ -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
|
||||
|
||||
+5
-4
@@ -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
|
||||
|
||||
@@ -348,7 +349,7 @@ After configuration and spin-up, the destination `turns:turn.example.com:443?tra
|
||||
<summary>Using static credentials</summary>
|
||||
|
||||
:::caution
|
||||
Static credentials are less secure than shared secrets because they don't expire and must be configured in coturn separately. It is strongly advised you use [shared secret authentication](#2-configuration).
|
||||
Static credentials are less secure than shared secrets because they don't expire and must be configured in coturn separately. It is strongly advised you use [shared secret authentication](#2-configuring-coturn).
|
||||
:::
|
||||
|
||||
If you prefer static username/password credentials instead of shared secrets:
|
||||
|
||||
+1
-1
@@ -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).
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -69,7 +69,7 @@ Docker's default DNS resolver is known to [**cause timeout issues**](../troubles
|
||||
|
||||
```yaml title='docker-compose.yml'
|
||||
services:
|
||||
homeserver:
|
||||
continuwuity:
|
||||
# ...
|
||||
volumes:
|
||||
- ./continuwuity-resolv.conf:/etc/resolv.conf
|
||||
@@ -95,7 +95,7 @@ Then, create a Caddyfile with the following content:
|
||||
|
||||
```
|
||||
https://example.com:443, https://example.com:8448 {
|
||||
reverse_proxy http://homeserver:8008
|
||||
reverse_proxy http://continuwuity:8008
|
||||
}
|
||||
```
|
||||
|
||||
@@ -297,7 +297,7 @@ For Docker Compose deployments this means adding `stdin_open: true` and `tty: tr
|
||||
|
||||
```yaml
|
||||
services:
|
||||
homeserver:
|
||||
continuwuity:
|
||||
stdin_open: true
|
||||
tty: true
|
||||
# ...
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
@@ -12,11 +12,14 @@ Install Git, Rust, Docker, Go, and `jq`. From this repository's root, build the
|
||||
server image and run the suite:
|
||||
|
||||
```bash
|
||||
cargo build -p conduwuit
|
||||
cargo build -p conduwuit --features openreg
|
||||
docker build -t continuwuity:complement -f docker/complement.Dockerfile .
|
||||
./bin/complement
|
||||
```
|
||||
|
||||
The `openreg` feature is required: without it the server refuses the open
|
||||
registrations Complement uses to create test users, and almost every test fails.
|
||||
|
||||
The run can take up to an hour. The runner writes the full Go test stream to
|
||||
`tests/test_results/complement/test_logs.jsonl` and a sorted pass/fail/skip
|
||||
summary to `tests/test_results/complement/test_results.jsonl`. It exits nonzero
|
||||
|
||||
@@ -226,10 +226,10 @@ The following Compose files are taken from [Docker deployment instructions](../d
|
||||
|
||||
```txt title="Caddyfile"
|
||||
https://matrix.example.com:443 {
|
||||
reverse_proxy http://homeserver:8008
|
||||
reverse_proxy http://continuwuity:8008
|
||||
}
|
||||
https://example.com:443 {
|
||||
reverse_proxy /.well-known/matrix* http://homeserver:8008
|
||||
reverse_proxy /.well-known/matrix* http://continuwuity:8008
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ networks:
|
||||
- subnet: "10.10.10.0/24"
|
||||
|
||||
services:
|
||||
homeserver:
|
||||
continuwuity:
|
||||
# ...
|
||||
volume:
|
||||
- ./continuwuity-resolv.conf:/etc/resolv.conf:ro
|
||||
|
||||
+15
-19
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ Continuwuity has moderation admin commands for:
|
||||
- fetching `/.well-known/matrix/support` from servers (`!admin federation`)
|
||||
- blocking incoming federation for certain rooms (not the same as room banning)
|
||||
(`!admin federation`)
|
||||
- deleting media (see [the media section](#media))
|
||||
- deleting media
|
||||
|
||||
Any commands with `-list` in them will require a codeblock in the message with
|
||||
each object being newline delimited. An example of doing this is:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Continuwuity - Behind Traefik Reverse Proxy
|
||||
|
||||
services:
|
||||
homeserver:
|
||||
continuwuity:
|
||||
image: "forgejo.ellis.link/continuwuation/continuwuity:latest"
|
||||
restart: unless-stopped
|
||||
command: /sbin/conduwuit
|
||||
|
||||
@@ -16,9 +16,9 @@ services:
|
||||
restart: unless-stopped
|
||||
labels:
|
||||
caddy: example.com
|
||||
caddy.reverse_proxy: /.well-known/matrix/* homeserver:8008
|
||||
caddy.reverse_proxy: /.well-known/matrix/* continuwuity:8008
|
||||
|
||||
homeserver:
|
||||
continuwuity:
|
||||
image: "forgejo.ellis.link/continuwuation/continuwuity:latest"
|
||||
restart: unless-stopped
|
||||
command: /sbin/conduwuit
|
||||
|
||||
@@ -14,7 +14,7 @@ services:
|
||||
- ./Caddyfile:/etc/caddy/Caddyfile
|
||||
restart: unless-stopped
|
||||
|
||||
homeserver:
|
||||
continuwuity:
|
||||
image: "forgejo.ellis.link/continuwuation/continuwuity:latest"
|
||||
restart: unless-stopped
|
||||
command: /sbin/conduwuit
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Continuwuity - With Traefik Reverse Proxy
|
||||
|
||||
services:
|
||||
homeserver:
|
||||
continuwuity:
|
||||
image: "forgejo.ellis.link/continuwuation/continuwuity:latest"
|
||||
restart: unless-stopped
|
||||
command: /sbin/conduwuit
|
||||
|
||||
@@ -37,7 +37,7 @@ services:
|
||||
|
||||
# If you already configured `[global.well_known]` with Continuwuity,
|
||||
# comment out the *_respond labels and uncomment the line below:
|
||||
# caddy.reverse_proxy: /.well-known/matrix/* homeserver:8008
|
||||
# caddy.reverse_proxy: /.well-known/matrix/* continuwuity:8008
|
||||
|
||||
# If you are having problems with continuwuity serving headers,
|
||||
# uncomment the header section below.
|
||||
@@ -48,7 +48,7 @@ services:
|
||||
# caddy.0_header.Access-Control-Allow-Headers: "Authorization"
|
||||
# caddy.0_header.Content-Type: "application/json"
|
||||
|
||||
homeserver:
|
||||
continuwuity:
|
||||
image: forgejo.ellis.link/continuwuation/continuwuity:latest
|
||||
restart: unless-stopped
|
||||
# add additional environment, volume, and network config here...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Continuwuity - Behind Traefik Reverse Proxy
|
||||
|
||||
services:
|
||||
homeserver:
|
||||
continuwuity:
|
||||
image: "forgejo.ellis.link/continuwuation/continuwuity:latest"
|
||||
restart: unless-stopped
|
||||
command: /sbin/conduwuit
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Continuwuity - Traefik Reverse Proxy Labels (override file)
|
||||
|
||||
services:
|
||||
homeserver:
|
||||
continuwuity:
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.docker.network=proxy" # Change this to the name of your Traefik docker proxy network
|
||||
|
||||
@@ -15,7 +15,7 @@ services:
|
||||
- ./caddy-data:/data
|
||||
restart: unless-stopped
|
||||
|
||||
homeserver:
|
||||
continuwuity:
|
||||
image: "forgejo.ellis.link/continuwuation/continuwuity:latest"
|
||||
restart: unless-stopped
|
||||
command: /sbin/conduwuit
|
||||
|
||||
@@ -15,7 +15,7 @@ services:
|
||||
- ./Caddyfile:/etc/caddy/Caddyfile
|
||||
restart: unless-stopped
|
||||
|
||||
homeserver:
|
||||
continuwuity:
|
||||
image: "forgejo.ellis.link/continuwuation/continuwuity:latest"
|
||||
restart: unless-stopped
|
||||
command: /sbin/conduwuit
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Continuwuity - With Traefik Reverse Proxy
|
||||
|
||||
services:
|
||||
homeserver:
|
||||
continuwuity:
|
||||
image: "forgejo.ellis.link/continuwuation/continuwuity:latest"
|
||||
restart: unless-stopped
|
||||
command: /sbin/conduwuit
|
||||
|
||||
Generated
+24
-24
@@ -3,11 +3,11 @@
|
||||
"advisory-db": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1789329924,
|
||||
"narHash": "sha256-mykGMFabQ7yP6G373M3VHkrac9PJPKJstrhQz2D/Rdc=",
|
||||
"lastModified": 1793979272,
|
||||
"narHash": "sha256-oUcBtPbtS7PlEMuSrgTAN4wv49cXYbwKbQqhH2pah5w=",
|
||||
"owner": "rustsec",
|
||||
"repo": "advisory-db",
|
||||
"rev": "455fd4bac659b5f1fca3810661c2d8b3c25dad05",
|
||||
"rev": "309392b18f6b17022f82c701f300433126901068",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -18,11 +18,11 @@
|
||||
},
|
||||
"crane": {
|
||||
"locked": {
|
||||
"lastModified": 1788465171,
|
||||
"narHash": "sha256-Y1/TTVXjYXGF068IThQH9fPSZ0SIE74PABlUxnWTUH0=",
|
||||
"lastModified": 1793836618,
|
||||
"narHash": "sha256-TREenflwEjxOSq292FYwbc3kEm7TDRtXCZRNWEdjBmg=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "eb35abda9f232cc6610b1d1e3200d15c49b7ac54",
|
||||
"rev": "79fd63528501446749c09f08cad486a58c7d173e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -39,11 +39,11 @@
|
||||
"rust-analyzer-src": "rust-analyzer-src"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1789298866,
|
||||
"narHash": "sha256-6eaV5+MdWy1tAlN4HAFr64pTnYc9jiKGXBsu18cyVjE=",
|
||||
"lastModified": 1794142885,
|
||||
"narHash": "sha256-xWFSr7q8IerDAVRk4W7/CgTmi05hMy2qjZ0z3VYpOVk=",
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"rev": "1fc6f36a23fa16e3740987957266f6e4b915c3cd",
|
||||
"rev": "f7d416b5073152c7f2e4de1a28d1a4330dd30a26",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -74,11 +74,11 @@
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1788450739,
|
||||
"narHash": "sha256-glZLQlzIn1fXH6PazR2iUmTo7kzzyYSshrWhLS9TqCU=",
|
||||
"lastModified": 1793576659,
|
||||
"narHash": "sha256-V1h85lUaJBQoHFrB2vpXZOE0Ju1MYSnIpsehoVZYlDo=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "31729ca8cbdb4fa927b34e5f4353e6a83f39e993",
|
||||
"rev": "ea2630b7470978622c7689a1ff75d2b389175399",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -89,11 +89,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1789149629,
|
||||
"narHash": "sha256-H6GwaZzZf+4npqv0tph94w9tZddSjFjmQrVsW0z78uk=",
|
||||
"lastModified": 1794042290,
|
||||
"narHash": "sha256-ziZn2PvCJE5JEEpqTdxXwJpPB+L3YqoCpTAMCzyaP3U=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "eaad089433ca2bb662274377d33df3d0e51ef28b",
|
||||
"rev": "f4a03c008967841f2a0b3cb7c436fc6fc31671f6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -105,11 +105,11 @@
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1788057806,
|
||||
"narHash": "sha256-DTQSMxzDWmT0zhguthvegnVkn7CFqGCv4IHCzk5ZUpM=",
|
||||
"lastModified": 1793504054,
|
||||
"narHash": "sha256-ThkfL3D/FhCiZFc9+3BtxwuMmpuK+/bGtXCSo1+yVew=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "596e2e3940e09b2abbeb03f75fa1828c57fcd72c",
|
||||
"rev": "7851ba61fd862b277cb6a9cef37394bc18bb94e4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -132,11 +132,11 @@
|
||||
"rust-analyzer-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1789128286,
|
||||
"narHash": "sha256-KRxxgHiKIBp7R2n41IJuE5K4IUiLOpg47EEi3AxuSp8=",
|
||||
"lastModified": 1794096810,
|
||||
"narHash": "sha256-dWC+YtMX+cwH3e9ndiFB77ijTsKtO5I2OxfcvUY4j3k=",
|
||||
"owner": "rust-lang",
|
||||
"repo": "rust-analyzer",
|
||||
"rev": "6aeeb8cf02741e5da07a1615a05faa506cecb21a",
|
||||
"rev": "03ae6be57aa063bb373f69eead3b8e15168a45d2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -153,11 +153,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1786901030,
|
||||
"narHash": "sha256-WSFCsDSE5ffgD2MqzkM2CYjeFiKhRF/dJUN8uedb6YE=",
|
||||
"lastModified": 1791885023,
|
||||
"narHash": "sha256-C3alQ2MEt0zVrUSho5NUDo3jmhbff72++bfwoqT9Omo=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "27b3b12a8e6375f28ebe122f07d230ca5459bbfa",
|
||||
"rev": "0d6d739a833ba9a9c93034862e4a7b061a062a1c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -42,7 +42,12 @@ let
|
||||
|
||||
env = {
|
||||
CARGO_PROFILE = profile;
|
||||
RUSTFLAGS = rustflags;
|
||||
# Rust links with its bundled rust-lld by default on linux-gnu targets.
|
||||
# This bypasses nixpkgs' linker wrapper (and its rpaths), so we make it use the system one.
|
||||
# `-C linker-features=-lld` is only stable on x86_64, but cc takes the last `-fuse-ld`.
|
||||
RUSTFLAGS = lib.concatStringsSep " " (
|
||||
lib.optional stdenv.hostPlatform.isLinux "-C link-arg=-fuse-ld=bfd" ++ [ rustflags ]
|
||||
);
|
||||
GIT_COMMIT_HASH = self.rev or self.dirtyRev or "";
|
||||
GIT_COMMIT_HASH_SHORT = self.shortRev or self.dirtyShortRev or "";
|
||||
}
|
||||
@@ -60,18 +65,6 @@ craneLib.buildPackage (
|
||||
inherit cargoExtraArgs;
|
||||
cargoArtifacts = craneLib.buildDepsOnly attrs;
|
||||
|
||||
# Needed to make continuwuity link to rocksdb
|
||||
postFixup = lib.optionalString (stdenv.hostPlatform.isLinux && rocksdb != null) ''
|
||||
old_rpath="$(patchelf --print-rpath $out/bin/conduwuit)"
|
||||
extra_rpath="${
|
||||
lib.makeLibraryPath [
|
||||
rocksdb
|
||||
]
|
||||
}"
|
||||
|
||||
patchelf --set-rpath "$old_rpath:$extra_rpath" $out/bin/conduwuit
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "A community-driven Matrix homeserver in Rust";
|
||||
mainProgram = "conduwuit";
|
||||
|
||||
@@ -18,6 +18,23 @@
|
||||
{
|
||||
packages =
|
||||
let
|
||||
# These musl deps aren't in the binary cache, so they're built locally, and their
|
||||
# test suites run (and break) when the builder can execute musl binaries.
|
||||
#
|
||||
# TODO: drop tzdata override once https://github.com/NixOS/nixpkgs/pull/582577 reaches nixos-unstable
|
||||
# - tzdata: `now.ck` checks against the current date.
|
||||
# TODO: drop sqlite override once https://github.com/NixOS/nixpkgs/issues/580629 is resolved
|
||||
# - sqlite: its test runner fails to build `testfixture` when cross-compiling to musl.
|
||||
muslOverlay =
|
||||
_final: prev:
|
||||
lib.genAttrs [ "tzdata" "sqlite" ] (
|
||||
name:
|
||||
if prev.stdenv.hostPlatform.isMusl then
|
||||
prev.${name}.overrideAttrs { doCheck = false; }
|
||||
else
|
||||
prev.${name}
|
||||
);
|
||||
|
||||
mkPackages =
|
||||
pkgs:
|
||||
let
|
||||
@@ -78,6 +95,7 @@
|
||||
import inputs.nixpkgs {
|
||||
localSystem = system;
|
||||
crossSystem = "x86_64-unknown-linux-musl";
|
||||
overlays = [ muslOverlay ];
|
||||
}
|
||||
)
|
||||
))
|
||||
@@ -86,6 +104,7 @@
|
||||
import inputs.nixpkgs {
|
||||
localSystem = system;
|
||||
crossSystem = "aarch64-unknown-linux-musl";
|
||||
overlays = [ muslOverlay ];
|
||||
}
|
||||
)
|
||||
));
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
inherit enableJemalloc;
|
||||
}).overrideAttrs
|
||||
({
|
||||
version = "continuwuity-v0.5.0-unstable-2026-05-19";
|
||||
version = "continuwuity-v0.5.0-unstable-2026-11-08";
|
||||
src = fetchFromGitea {
|
||||
domain = "forgejo.ellis.link";
|
||||
owner = "continuwuation";
|
||||
repo = "rocksdb";
|
||||
rev = "3756b2b905e13216d8b56bcc783d814e7b073aff";
|
||||
hash = "sha256-rSv4fr2bf9JJwdodgeuPCuceeh7k97KVxrAOC0wyPQY=";
|
||||
rev = "722fa3219df4169610fda8962221a1ff74026fdb";
|
||||
hash = "sha256-ZuXXp83Hgj0B5v499CNxa9oNQUS/ZKYOAZEhmarUifc=";
|
||||
};
|
||||
|
||||
# We have this already at https://forgejo.ellis.link/continuwuation/rocksdb/commit/a935c0273e1ba44eacf88ce3685a9b9831486155
|
||||
|
||||
Generated
+372
-335
File diff suppressed because it is too large.
Load diff
@@ -62,8 +62,6 @@ release_max_log_level = [
|
||||
"conduwuit-service/release_max_log_level",
|
||||
"tracing/max_level_trace",
|
||||
"tracing/release_max_level_info",
|
||||
"log/max_level_trace",
|
||||
"log/release_max_level_info",
|
||||
]
|
||||
zstd_compression = [
|
||||
"conduwuit-api/zstd_compression",
|
||||
@@ -84,7 +82,6 @@ ctor.workspace = true
|
||||
dtor.workspace = true
|
||||
futures.workspace = true
|
||||
lettre.workspace = true
|
||||
log.workspace = true
|
||||
ruma.workspace = true
|
||||
serde_json.workspace = true
|
||||
serde-saphyr.workspace = true
|
||||
|
||||
@@ -983,7 +983,8 @@ impl crate::Context<'_> {
|
||||
let resolver: &MatrixResolver = if no_cache {
|
||||
&MatrixResolverBuilder::new()
|
||||
.dangerous_tls_accept_invalid_certs(self.services.server.config.allow_invalid_tls_certificates_yes_i_know_what_the_fuck_i_am_doing_with_this_and_i_know_this_is_insecure)
|
||||
.http_client(self.services.client.dns.clone())
|
||||
.http_client(self.services.client.matrix_http_client.clone())
|
||||
.dns_resolver(self.services.client.dns_resolver.clone())
|
||||
.build()?
|
||||
} else {
|
||||
&self.services.client.matrix_resolver
|
||||
|
||||
@@ -51,8 +51,6 @@ jemalloc_stats = [
|
||||
release_max_log_level = [
|
||||
"conduwuit-core/release_max_log_level",
|
||||
"conduwuit-service/release_max_log_level",
|
||||
"log/max_level_trace",
|
||||
"log/release_max_level_info",
|
||||
"tracing/max_level_trace",
|
||||
"tracing/release_max_level_info",
|
||||
]
|
||||
@@ -80,7 +78,6 @@ http-body-util.workspace = true
|
||||
hyper.workspace = true
|
||||
itertools.workspace = true
|
||||
lettre.workspace = true
|
||||
log.workspace = true
|
||||
rand.workspace = true
|
||||
reqwest.workspace = true
|
||||
ruma.workspace = true
|
||||
|
||||
+18
-3
@@ -523,7 +523,22 @@ where
|
||||
for (server, response) in futures {
|
||||
match response {
|
||||
| Ok(response) => {
|
||||
for (user, master_key) in response.master_keys {
|
||||
let is_wanted = |user_id: &UserId| {
|
||||
user_id.server_name() == server && device_keys_input.contains_key(user_id)
|
||||
};
|
||||
let filtered_master_keys = response
|
||||
.master_keys
|
||||
.into_iter()
|
||||
.filter(|(user_id, _)| is_wanted(user_id));
|
||||
let filtered_self_signing_keys = response
|
||||
.self_signing_keys
|
||||
.into_iter()
|
||||
.filter(|(user_id, _)| is_wanted(user_id));
|
||||
let filtered_device_keys = response
|
||||
.device_keys
|
||||
.into_iter()
|
||||
.filter(|(user_id, _)| is_wanted(user_id));
|
||||
for (user, master_key) in filtered_master_keys {
|
||||
let (master_key_id, mut master_key) = parse_master_key(&user, &master_key)?;
|
||||
|
||||
if let Ok(our_master_key) = services
|
||||
@@ -549,8 +564,8 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
self_signing_keys.extend(response.self_signing_keys);
|
||||
device_keys.extend(response.device_keys);
|
||||
self_signing_keys.extend(filtered_self_signing_keys);
|
||||
device_keys.extend(filtered_device_keys);
|
||||
},
|
||||
| Err(e) => {
|
||||
failures.insert(server.to_string(), json!({ "error": e.to_string() }));
|
||||
|
||||
+18
-21
@@ -22,7 +22,7 @@ use conduwuit_service::{
|
||||
};
|
||||
use futures::{FutureExt, StreamExt, TryFutureExt, future::OptionFuture, pin_mut};
|
||||
use ruma::{
|
||||
RoomId, UserId,
|
||||
EventId, RoomId, UserId,
|
||||
api::{
|
||||
Direction,
|
||||
client::{filter::RoomEventFilter, message::get_message_events},
|
||||
@@ -30,8 +30,9 @@ use ruma::{
|
||||
},
|
||||
assign,
|
||||
events::{
|
||||
AnyStateEvent, StateEventType,
|
||||
AnyStateEvent, StateEventType, SyncEphemeralRoomEvent,
|
||||
TimelineEventType::{self, *},
|
||||
receipt::ReceiptEventContent,
|
||||
},
|
||||
serde::Raw,
|
||||
};
|
||||
@@ -209,36 +210,32 @@ pub(crate) async fn lazy_loading_witness<'a, I>(
|
||||
where
|
||||
I: Iterator<Item = &'a PdusIterItem> + Clone + Send,
|
||||
{
|
||||
let oldest = events
|
||||
.clone()
|
||||
.map(|(count, _)| count)
|
||||
.copied()
|
||||
.min()
|
||||
.unwrap_or_else(PduCount::max);
|
||||
|
||||
let newest = events
|
||||
.clone()
|
||||
.map(|(count, _)| count)
|
||||
.copied()
|
||||
.max()
|
||||
.unwrap_or_else(PduCount::max);
|
||||
let chunk_event_ids: std::collections::HashSet<&EventId> =
|
||||
events.clone().map(|(_, event)| event.event_id()).collect();
|
||||
|
||||
let receipts = services
|
||||
.rooms
|
||||
.read_receipt
|
||||
.readreceipts_since(lazy_loading_context.room_id, Some(oldest.into_unsigned()));
|
||||
.readreceipts_since(lazy_loading_context.room_id, None);
|
||||
|
||||
pin_mut!(receipts);
|
||||
let receipt_users = receipts.ready_filter_map(|(user_id, _, raw)| {
|
||||
let event =
|
||||
serde_json::from_str::<SyncEphemeralRoomEvent<ReceiptEventContent>>(raw.json().get())
|
||||
.ok()?;
|
||||
event
|
||||
.content
|
||||
.keys()
|
||||
.any(|id| chunk_event_ids.contains(&**id))
|
||||
.then_some(user_id)
|
||||
});
|
||||
|
||||
let witness: MemberSet = events
|
||||
.stream()
|
||||
.map(ref_at!(1))
|
||||
.map(Event::sender)
|
||||
.map(ToOwned::to_owned)
|
||||
.chain(
|
||||
receipts
|
||||
.ready_take_while(|(_, c, _)| *c <= newest.into_unsigned())
|
||||
.map(|(user_id, ..)| user_id),
|
||||
)
|
||||
.chain(receipt_users)
|
||||
.collect()
|
||||
.await;
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use axum::extract::State;
|
||||
use conduwuit::{Err, PduCount, Result, err};
|
||||
use conduwuit::{Err, Result, err};
|
||||
use ruma::{
|
||||
MilliSecondsSinceUnixEpoch,
|
||||
api::client::{read_marker::set_read_marker, receipt::create_receipt},
|
||||
events::{
|
||||
RoomAccountDataEventType,
|
||||
fully_read::{FullyReadEvent, FullyReadEventContent},
|
||||
receipt::{Receipt, ReceiptEvent, ReceiptEventContent, ReceiptType},
|
||||
receipt::{Receipt, ReceiptEvent, ReceiptEventContent, ReceiptThread, ReceiptType},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -27,6 +27,15 @@ pub(crate) async fn set_read_marker_route(
|
||||
) -> Result<set_read_marker::v3::Response> {
|
||||
let sender_user = body.identity.expect_sender_user()?;
|
||||
|
||||
if !services
|
||||
.rooms
|
||||
.state_cache
|
||||
.is_joined(sender_user, &body.room_id)
|
||||
.await
|
||||
{
|
||||
return Err!(Request(Forbidden("You are not in this room.")));
|
||||
}
|
||||
|
||||
if let Some(event) = &body.fully_read {
|
||||
let fully_read_event = FullyReadEvent::new(FullyReadEventContent::new(event.to_owned()));
|
||||
|
||||
@@ -92,13 +101,8 @@ pub(crate) async fn set_read_marker_route(
|
||||
.timeline
|
||||
.get_pdu_count(event)
|
||||
.await
|
||||
.map_err(|_| err!(Request(NotFound("Event not found."))))?;
|
||||
|
||||
let PduCount::Normal(count) = count else {
|
||||
return Err!(Request(InvalidParam(
|
||||
"Event is a backfilled PDU and cannot be marked as read."
|
||||
)));
|
||||
};
|
||||
.map_err(|_| err!(Request(NotFound("Event not found."))))?
|
||||
.into_unsigned();
|
||||
|
||||
services
|
||||
.rooms
|
||||
@@ -122,11 +126,26 @@ pub(crate) async fn create_receipt_route(
|
||||
) -> Result<create_receipt::v3::Response> {
|
||||
let sender_user = body.identity.expect_sender_user()?;
|
||||
|
||||
if !services
|
||||
.rooms
|
||||
.state_cache
|
||||
.is_joined(sender_user, &body.room_id)
|
||||
.await
|
||||
{
|
||||
return Err!(Request(Forbidden("You are not in this room.")));
|
||||
}
|
||||
|
||||
services
|
||||
.users
|
||||
.update_device_last_seen(sender_user, body.identity.sender_device(), client_ip)
|
||||
.await;
|
||||
|
||||
if body.receipt_type == create_receipt::v3::ReceiptType::FullyRead
|
||||
&& body.thread != ReceiptThread::Unthreaded
|
||||
{
|
||||
return Err!(Request(InvalidParam("thread_id cannot be specified for m.fully_read")));
|
||||
}
|
||||
|
||||
if matches!(
|
||||
&body.receipt_type,
|
||||
create_receipt::v3::ReceiptType::Read | create_receipt::v3::ReceiptType::ReadPrivate
|
||||
@@ -159,44 +178,41 @@ pub(crate) async fn create_receipt_route(
|
||||
)
|
||||
.await?;
|
||||
},
|
||||
| create_receipt::v3::ReceiptType::Read => {
|
||||
let receipt_content = [(
|
||||
body.event_id.clone(),
|
||||
BTreeMap::from_iter([(
|
||||
ReceiptType::Read,
|
||||
| create_receipt::v3::ReceiptType::Read =>
|
||||
if services.config.allow_local_read_receipts
|
||||
&& !services.users.is_suspended(sender_user).await?
|
||||
{
|
||||
let mut receipt = Receipt::new(MilliSecondsSinceUnixEpoch::now());
|
||||
receipt.thread = body.thread.clone();
|
||||
let receipt_content = [(
|
||||
body.event_id.clone(),
|
||||
BTreeMap::from_iter([(
|
||||
sender_user.to_owned(),
|
||||
Receipt::new(MilliSecondsSinceUnixEpoch::now()),
|
||||
ReceiptType::Read,
|
||||
BTreeMap::from_iter([(sender_user.to_owned(), receipt)]),
|
||||
)]),
|
||||
)]),
|
||||
)];
|
||||
)];
|
||||
|
||||
services
|
||||
.rooms
|
||||
.read_receipt
|
||||
.readreceipt_update(
|
||||
sender_user,
|
||||
&body.room_id,
|
||||
ReceiptEvent::new(
|
||||
body.room_id.clone(),
|
||||
ReceiptEventContent::from_iter(receipt_content),
|
||||
),
|
||||
)
|
||||
.await;
|
||||
},
|
||||
services
|
||||
.rooms
|
||||
.read_receipt
|
||||
.readreceipt_update(
|
||||
sender_user,
|
||||
&body.room_id,
|
||||
ReceiptEvent::new(
|
||||
body.room_id.clone(),
|
||||
ReceiptEventContent::from_iter(receipt_content),
|
||||
),
|
||||
)
|
||||
.await;
|
||||
},
|
||||
| create_receipt::v3::ReceiptType::ReadPrivate => {
|
||||
let count = services
|
||||
.rooms
|
||||
.timeline
|
||||
.get_pdu_count(&body.event_id)
|
||||
.await
|
||||
.map_err(|_| err!(Request(NotFound("Event not found."))))?;
|
||||
|
||||
let PduCount::Normal(count) = count else {
|
||||
return Err!(Request(InvalidParam(
|
||||
"Event is a backfilled PDU and cannot be marked as read."
|
||||
)));
|
||||
};
|
||||
.map_err(|_| err!(Request(NotFound("Event not found."))))?
|
||||
.into_unsigned();
|
||||
|
||||
services
|
||||
.rooms
|
||||
|
||||
+46
-38
@@ -2,7 +2,7 @@ use axum::extract::State;
|
||||
use conduwuit::{
|
||||
Err, Result, at, debug_warn, err,
|
||||
matrix::{Event, event::RelationTypeEqual, pdu::PduCount},
|
||||
utils::{IterStream, ReadyExt, result::FlatOk, stream::WidebandExt},
|
||||
utils::{IterStream, result::FlatOk, stream::WidebandExt},
|
||||
};
|
||||
use conduwuit_service::Services;
|
||||
use futures::StreamExt;
|
||||
@@ -98,6 +98,10 @@ pub(crate) async fn get_relating_events_route(
|
||||
.await
|
||||
}
|
||||
|
||||
// Spec (v1.10) recommends a depth of at least 3
|
||||
const RECURSION_DEPTH: u8 = 3;
|
||||
const LEVELS_BELOW: u8 = RECURSION_DEPTH - 1;
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn paginate_relations_with_filter(
|
||||
services: &Services,
|
||||
@@ -147,28 +151,49 @@ async fn paginate_relations_with_filter(
|
||||
.unwrap_or(30)
|
||||
.min(100);
|
||||
|
||||
// Spec (v1.10) recommends depth of at least 3
|
||||
let depth: u8 = if recurse { 3 } else { 1 };
|
||||
let max_depth = if recurse { LEVELS_BELOW } else { 0 };
|
||||
|
||||
let events: Vec<_> = services
|
||||
// One more than the limit, to know whether there's another page
|
||||
let mut events = services
|
||||
.rooms
|
||||
.pdu_metadata
|
||||
.get_relations(sender_user, room_id, target, start, limit, depth, dir)
|
||||
.await
|
||||
.get_relations(
|
||||
sender_user,
|
||||
room_id,
|
||||
target,
|
||||
start,
|
||||
limit.saturating_add(1),
|
||||
max_depth,
|
||||
dir,
|
||||
|pdu| {
|
||||
filter_event_type
|
||||
.as_ref()
|
||||
.is_none_or(|kind| kind == pdu.kind())
|
||||
&& filter_rel_type
|
||||
.as_ref()
|
||||
.is_none_or(|rel_type| rel_type.relation_type_equal(pdu))
|
||||
},
|
||||
)
|
||||
.await;
|
||||
|
||||
let past_to = to.and_then(|to| {
|
||||
events
|
||||
.iter()
|
||||
.position(|(count, _)| !to.is_after(*count, dir))
|
||||
});
|
||||
if let Some(past_to) = past_to {
|
||||
events.truncate(past_to);
|
||||
}
|
||||
|
||||
let has_more = past_to.is_none() && events.len() > limit;
|
||||
events.truncate(limit);
|
||||
|
||||
let next_batch =
|
||||
has_more.then(|| events.last().map_or(start, |(count, _)| *count).to_string());
|
||||
|
||||
let chunk: Vec<_> = events
|
||||
.into_iter()
|
||||
.filter(|(_, pdu)| {
|
||||
filter_event_type
|
||||
.as_ref()
|
||||
.is_none_or(|kind| kind == pdu.kind())
|
||||
})
|
||||
.filter(|(_, pdu)| {
|
||||
filter_rel_type
|
||||
.as_ref()
|
||||
.is_none_or(|rel_type| rel_type.relation_type_equal(pdu))
|
||||
})
|
||||
.stream()
|
||||
.ready_take_while(|(count, _)| Some(*count) != to)
|
||||
.take(limit)
|
||||
.wide_filter_map(|item| visibility_filter(services, sender_user, item))
|
||||
.wide_filter_map(|item| ignored_filter(services, item, sender_user))
|
||||
.then(async |mut pdu| {
|
||||
@@ -182,32 +207,15 @@ async fn paginate_relations_with_filter(
|
||||
}
|
||||
pdu
|
||||
})
|
||||
.collect()
|
||||
.await;
|
||||
|
||||
// Determine if there are more events to fetch
|
||||
let has_more = events.len() >= limit;
|
||||
|
||||
let next_batch = if has_more {
|
||||
match dir {
|
||||
| Direction::Forward => events.last(),
|
||||
| Direction::Backward => events.first(),
|
||||
}
|
||||
.map(|(count, _)| count.to_string())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let chunk: Vec<_> = events
|
||||
.into_iter()
|
||||
.map(at!(1))
|
||||
.map(Event::into_format)
|
||||
.collect();
|
||||
.collect()
|
||||
.await;
|
||||
|
||||
Ok(assign!(get_relating_events::v1::Response::new(chunk), {
|
||||
next_batch,
|
||||
prev_batch: from.map(Into::into),
|
||||
recursion_depth: recurse.then_some(depth.into()),
|
||||
recursion_depth: recurse.then_some(RECURSION_DEPTH.into()),
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ pub(crate) async fn get_room_event_route(
|
||||
services.rooms.state_accessor.is_world_readable(room_id)
|
||||
);
|
||||
if !joined && !world_readable {
|
||||
return Err!(Request(NotFound("Event {} not found.", event_id)));
|
||||
return Err!(Request(NotFound("Event {event_id} not found.")));
|
||||
}
|
||||
|
||||
services
|
||||
@@ -32,10 +32,15 @@ pub(crate) async fn get_room_event_route(
|
||||
.timeline
|
||||
.get_remote_pdu(room_id, event_id)
|
||||
.await
|
||||
.map_err(|_| err!(Request(NotFound("Event {} not found.", event_id))))?
|
||||
.map_err(|_| err!(Request(NotFound("Event {event_id} not found."))))?
|
||||
},
|
||||
| Err(e) => return Err(e),
|
||||
};
|
||||
if !event.room_id_or_hash().eq(room_id) {
|
||||
// Return not found instead of invalid param to avoid revealing the
|
||||
// existence of events the user might not be allowed to know about.
|
||||
return Err!(Request(NotFound("Event {event_id} not found.")));
|
||||
}
|
||||
|
||||
// NOTE: checked after fetching, as visibility of an unknown event cannot
|
||||
// be determined (user_can_see_event returns true for those).
|
||||
|
||||
@@ -15,7 +15,7 @@ use conduwuit::{
|
||||
},
|
||||
warn,
|
||||
};
|
||||
use conduwuit_service::Services;
|
||||
use conduwuit_service::{Services, rooms::read_receipt::pack_receipts};
|
||||
use futures::{
|
||||
FutureExt, StreamExt, TryFutureExt,
|
||||
future::{OptionFuture, join, join3, join4, try_join, try_join3},
|
||||
@@ -243,9 +243,14 @@ async fn build_ephemeral(
|
||||
let (receipt_events, typing_event, private_read_event) =
|
||||
join3(receipt_events, typing_event, private_read_event).await;
|
||||
|
||||
let mut edus = receipt_events;
|
||||
let mut all_receipts = receipt_events;
|
||||
all_receipts.extend(private_read_event);
|
||||
|
||||
let mut edus = Vec::new();
|
||||
if !all_receipts.is_empty() {
|
||||
edus.push(pack_receipts(all_receipts.into_iter()).cast());
|
||||
}
|
||||
edus.extend(typing_event);
|
||||
edus.extend(private_read_event);
|
||||
|
||||
Ok(assign!(Ephemeral::new(), { events: edus }))
|
||||
}
|
||||
|
||||
+13
-4
@@ -1,18 +1,21 @@
|
||||
use std::ops::Deref;
|
||||
use std::{
|
||||
net::{IpAddr, Ipv4Addr},
|
||||
ops::Deref,
|
||||
};
|
||||
|
||||
use axum::{
|
||||
RequestExt, RequestPartsExt,
|
||||
body::Body,
|
||||
extract::{FromRequest, Path, Query},
|
||||
};
|
||||
use conduwuit::{Error, Result, err};
|
||||
use conduwuit::{Error, Result, err, error};
|
||||
use ruma::{
|
||||
CanonicalJsonObject,
|
||||
api::{IncomingRequest, IncomingRequestExt, auth_scheme::AuthScheme},
|
||||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{State, router::auth::CheckAuth};
|
||||
use crate::{State, client_ip::ClientIp, router::auth::CheckAuth};
|
||||
|
||||
/// Query parameters needed to authenticate requests
|
||||
#[derive(Deserialize)]
|
||||
@@ -87,6 +90,11 @@ where
|
||||
let Path(path): Path<Vec<String>> = parts.extract().await?;
|
||||
let borrowed_path: Vec<_> = path.iter().map(String::as_str).collect();
|
||||
let Query(auth_query): Query<AuthQueryParams> = parts.extract().await?;
|
||||
let ClientIp(ip) = parts
|
||||
.extract_with_state(services)
|
||||
.await
|
||||
.inspect_err(|err| error!("Failed to extract client IP: {err:?}"))
|
||||
.unwrap_or(ClientIp(IpAddr::V4(Ipv4Addr::UNSPECIFIED)));
|
||||
|
||||
// Assemble a new request from the read body and parts
|
||||
let request = hyper::Request::from_parts(parts, body.as_ref());
|
||||
@@ -102,7 +110,8 @@ where
|
||||
})?;
|
||||
|
||||
let identity =
|
||||
R::Authentication::check::<R>(services, &request, authentication, auth_query).await?;
|
||||
R::Authentication::check::<R>(services, &request, ip, authentication, auth_query)
|
||||
.await?;
|
||||
|
||||
// Deserialize the body
|
||||
let body = R::try_from_http_request(request, &borrowed_path)
|
||||
|
||||
+37
-1
@@ -1,6 +1,7 @@
|
||||
use std::{
|
||||
any::{Any, TypeId},
|
||||
collections::BTreeSet,
|
||||
net::IpAddr,
|
||||
};
|
||||
|
||||
use conduwuit::{
|
||||
@@ -18,7 +19,10 @@ use ruma::{
|
||||
AuthScheme, NoAccessToken, NoAuthentication,
|
||||
},
|
||||
client,
|
||||
error::{ErrorKind, InsufficientUserAuthenticationErrorData, UnknownTokenErrorData},
|
||||
error::{
|
||||
ErrorKind, InsufficientUserAuthenticationErrorData, LimitExceededErrorData,
|
||||
UnknownTokenErrorData,
|
||||
},
|
||||
federation::authentication::ServerSignatures,
|
||||
},
|
||||
assign,
|
||||
@@ -90,6 +94,7 @@ pub(crate) trait CheckAuth: AuthScheme {
|
||||
fn check<R: IncomingRequest<Authentication = Self> + Any>(
|
||||
services: &Services,
|
||||
incoming_request: &hyper::Request<&[u8]>,
|
||||
request_ip: IpAddr,
|
||||
authentication: Self::Output,
|
||||
query: AuthQueryParams,
|
||||
) -> impl Future<Output = Result<Self::Identity>> + Send;
|
||||
@@ -101,6 +106,7 @@ impl CheckAuth for ServerSignatures {
|
||||
async fn check<R: IncomingRequest<Authentication = Self> + Any>(
|
||||
services: &Services,
|
||||
incoming_request: &hyper::Request<&[u8]>,
|
||||
_request_ip: IpAddr,
|
||||
authentication: Self::Output,
|
||||
_query: AuthQueryParams,
|
||||
) -> Result<Self::Identity> {
|
||||
@@ -161,6 +167,7 @@ impl CheckAuth for AccessToken {
|
||||
async fn check<R: IncomingRequest<Authentication = Self> + Any>(
|
||||
services: &Services,
|
||||
_incoming_request: &hyper::Request<&[u8]>,
|
||||
_request_ip: IpAddr,
|
||||
authentication: Self::Output,
|
||||
query: AuthQueryParams,
|
||||
) -> Result<Self::Identity> {
|
||||
@@ -181,6 +188,7 @@ impl CheckAuth for AccessTokenOptional {
|
||||
async fn check<R: IncomingRequest<Authentication = Self> + Any>(
|
||||
services: &Services,
|
||||
_incoming_request: &hyper::Request<&[u8]>,
|
||||
request_ip: IpAddr,
|
||||
authentication: Self::Output,
|
||||
query: AuthQueryParams,
|
||||
) -> Result<Self::Identity> {
|
||||
@@ -195,6 +203,10 @@ impl CheckAuth for AccessTokenOptional {
|
||||
.await
|
||||
.map(Some)
|
||||
} else {
|
||||
if R::RATE_LIMITED {
|
||||
check_unauthenticated_request_ratelimiting(services, request_ip)?;
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
@@ -206,6 +218,7 @@ impl CheckAuth for AppserviceToken {
|
||||
async fn check<R: IncomingRequest + Any>(
|
||||
services: &Services,
|
||||
_incoming_request: &hyper::Request<&[u8]>,
|
||||
_request_ip: IpAddr,
|
||||
authentication: Self::Output,
|
||||
_query: AuthQueryParams,
|
||||
) -> Result<Self::Identity> {
|
||||
@@ -219,6 +232,7 @@ impl CheckAuth for AppserviceTokenOptional {
|
||||
async fn check<R: IncomingRequest<Authentication = Self> + Any>(
|
||||
services: &Services,
|
||||
_incoming_request: &hyper::Request<&[u8]>,
|
||||
_request_ip: IpAddr,
|
||||
authentication: Self::Output,
|
||||
_query: AuthQueryParams,
|
||||
) -> Result<Self::Identity> {
|
||||
@@ -238,6 +252,7 @@ impl CheckAuth for NoAuthentication {
|
||||
fn check<R: IncomingRequest<Authentication = Self> + Any>(
|
||||
_services: &Services,
|
||||
_incoming_request: &hyper::Request<&[u8]>,
|
||||
_request_ip: IpAddr,
|
||||
_authentication: Self::Output,
|
||||
_query: AuthQueryParams,
|
||||
) -> impl Future<Output = Result<Self::Identity>> + Send {
|
||||
@@ -251,6 +266,7 @@ impl CheckAuth for NoAccessToken {
|
||||
async fn check<R: IncomingRequest<Authentication = Self> + Any>(
|
||||
services: &Services,
|
||||
incoming_request: &hyper::Request<&[u8]>,
|
||||
request_ip: IpAddr,
|
||||
_authentication: Self::Output,
|
||||
query: AuthQueryParams,
|
||||
) -> Result<Self::Identity> {
|
||||
@@ -267,6 +283,10 @@ impl CheckAuth for NoAccessToken {
|
||||
.await
|
||||
.map(Some)
|
||||
} else {
|
||||
if R::RATE_LIMITED {
|
||||
check_unauthenticated_request_ratelimiting(services, request_ip)?;
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
@@ -408,3 +428,19 @@ async fn check_appservice_token(services: &Services, token: &str) -> Result<Regi
|
||||
|
||||
Ok(appservice_info)
|
||||
}
|
||||
|
||||
fn check_unauthenticated_request_ratelimiting(services: &Services, ip: IpAddr) -> Result<()> {
|
||||
if services
|
||||
.config
|
||||
.unauthenticated_request_ratelimit
|
||||
.check_key(&ip)
|
||||
.is_err()
|
||||
{
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::LimitExceeded(LimitExceededErrorData::new()),
|
||||
"Rate limit exceeded.",
|
||||
));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -421,7 +421,6 @@ async fn validate_invite_create_event(
|
||||
if !state_res::auth_check(
|
||||
room_version_rules,
|
||||
pdu,
|
||||
None,
|
||||
|_, _| async {
|
||||
unreachable!("No state should be fetched when processing a lone create event");
|
||||
},
|
||||
|
||||
+14
-22
@@ -581,28 +581,20 @@ async fn handle_edu_receipt_room_user(
|
||||
}
|
||||
|
||||
let data = &user_updates.data;
|
||||
user_updates
|
||||
.event_ids
|
||||
.into_iter()
|
||||
.stream()
|
||||
.for_each_concurrent(automatic_width(), |event_id| async move {
|
||||
let user_data = [(user_id.to_owned(), data.clone())];
|
||||
let receipts = [(ReceiptType::Read, BTreeMap::from(user_data))];
|
||||
let content = [(event_id.clone(), BTreeMap::from(receipts))];
|
||||
services
|
||||
.rooms
|
||||
.read_receipt
|
||||
.readreceipt_update(
|
||||
user_id,
|
||||
room_id,
|
||||
ReceiptEvent::new(
|
||||
room_id.to_owned(),
|
||||
ReceiptEventContent::from_iter(content),
|
||||
),
|
||||
)
|
||||
.await;
|
||||
})
|
||||
.await;
|
||||
for event_id in user_updates.event_ids {
|
||||
let user_data = [(user_id.to_owned(), data.clone())];
|
||||
let receipts = [(ReceiptType::Read, BTreeMap::from(user_data))];
|
||||
let content = [(event_id, BTreeMap::from(receipts))];
|
||||
services
|
||||
.rooms
|
||||
.read_receipt
|
||||
.readreceipt_update(
|
||||
user_id,
|
||||
room_id,
|
||||
ReceiptEvent::new(room_id.to_owned(), ReceiptEventContent::from_iter(content)),
|
||||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
|
||||
async fn handle_edu_typing(services: &Services, origin: &ServerName, typing: TypingContent) {
|
||||
|
||||
+1
-3
@@ -47,8 +47,6 @@ perf_measurements = []
|
||||
release_max_log_level = [
|
||||
"tracing/max_level_trace",
|
||||
"tracing/release_max_level_info",
|
||||
"log/max_level_trace",
|
||||
"log/release_max_level_info",
|
||||
]
|
||||
sentry_telemetry = []
|
||||
zstd_compression = [
|
||||
@@ -77,13 +75,13 @@ cyborgtime.workspace = true
|
||||
either.workspace = true
|
||||
figment.workspace = true
|
||||
futures.workspace = true
|
||||
governor.workspace = true
|
||||
http-body-util.workspace = true
|
||||
http.workspace = true
|
||||
ipaddress.workspace = true
|
||||
libc.workspace = true
|
||||
libloading.workspace = true
|
||||
libloading.optional = true
|
||||
log.workspace = true
|
||||
lettre.workspace = true
|
||||
num-traits.workspace = true
|
||||
rand.workspace = true
|
||||
|
||||
+43
-1
@@ -5,7 +5,10 @@ pub mod proxy;
|
||||
|
||||
use std::{
|
||||
collections::{BTreeMap, BTreeSet, HashMap},
|
||||
hash::Hash,
|
||||
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
|
||||
num::NonZero,
|
||||
ops::Deref,
|
||||
path::PathBuf,
|
||||
time::Duration,
|
||||
};
|
||||
@@ -17,6 +20,7 @@ use either::{
|
||||
};
|
||||
use figment::providers::{Env, Format, Toml};
|
||||
pub use figment::{Figment, value::Value as FigmentValue};
|
||||
use governor::{DefaultKeyedRateLimiter, Quota, RateLimiter};
|
||||
use lettre::message::Mailbox;
|
||||
use openidconnect::{Audience, ClientId, ClientSecret, Scope};
|
||||
use regex::RegexSet;
|
||||
@@ -40,7 +44,7 @@ use crate::{Result, err, error::Error, utils::sys};
|
||||
/// All the config options for continuwuity.
|
||||
#[allow(clippy::struct_excessive_bools)]
|
||||
#[allow(rustdoc::broken_intra_doc_links, rustdoc::bare_urls)]
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[config_example_generator(
|
||||
filename = "conduwuit-example.toml",
|
||||
section = "global",
|
||||
@@ -790,6 +794,14 @@ pub struct Config {
|
||||
#[serde(default = "default_sender_shutdown_timeout")]
|
||||
pub sender_shutdown_timeout: u64,
|
||||
|
||||
/// Maximum number of requests per minute that unauthenticated clients
|
||||
/// may make to ratelimited client-server API routes. This ratelimit is
|
||||
/// global across all endpoints for each IP.
|
||||
///
|
||||
/// default: 30
|
||||
#[serde(default = "default_unauthenticated_request_ratelimit")]
|
||||
pub unauthenticated_request_ratelimit: PerMinuteRatelimiter<IpAddr>,
|
||||
|
||||
/// Enables registration. If set to false, no users can register on this
|
||||
/// server.
|
||||
///
|
||||
@@ -2960,6 +2972,32 @@ impl TrustedServerConfig {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PerMinuteRatelimiter<K: Hash + Eq + Clone> {
|
||||
ratelimiter: DefaultKeyedRateLimiter<K>,
|
||||
}
|
||||
|
||||
impl<K: Hash + Eq + Clone> PerMinuteRatelimiter<K> {
|
||||
fn new(quota: Quota) -> Self { Self { ratelimiter: RateLimiter::keyed(quota) } }
|
||||
}
|
||||
|
||||
impl<K: Hash + Eq + Clone> Deref for PerMinuteRatelimiter<K> {
|
||||
type Target = DefaultKeyedRateLimiter<K>;
|
||||
|
||||
fn deref(&self) -> &Self::Target { &self.ratelimiter }
|
||||
}
|
||||
|
||||
impl<'de, K: Hash + Eq + Clone> Deserialize<'de> for PerMinuteRatelimiter<K> {
|
||||
fn deserialize<D>(deserializer: D) -> std::prelude::v1::Result<Self, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
let max_burst = NonZero::<u32>::deserialize(deserializer)?;
|
||||
|
||||
Ok(Self::new(Quota::per_minute(max_burst)))
|
||||
}
|
||||
}
|
||||
|
||||
const DEPRECATED_KEYS: &[&str] = &[
|
||||
"cache_capacity",
|
||||
"conduit_cache_capacity_modifier",
|
||||
@@ -3403,3 +3441,7 @@ fn default_preferred_username_claim() -> String { "preferred_username".to_owned(
|
||||
fn default_profile_key_map() -> HashMap<String, String> {
|
||||
HashMap::from_iter([(ProfileFieldName::DisplayName.to_string(), "name".to_owned())])
|
||||
}
|
||||
|
||||
fn default_unauthenticated_request_ratelimit<K: Hash + Eq + Clone>() -> PerMinuteRatelimiter<K> {
|
||||
PerMinuteRatelimiter::new(Quota::per_minute(30.try_into().unwrap()))
|
||||
}
|
||||
@@ -16,7 +16,12 @@ use ruma::{
|
||||
use serde::Deserialize;
|
||||
use serde_json::{Value as JsonValue, value::RawValue as RawJsonValue};
|
||||
|
||||
pub use self::{filter::Matches, id::*, relation::RelationTypeEqual, type_ext::TypeExt};
|
||||
pub use self::{
|
||||
filter::Matches,
|
||||
id::*,
|
||||
relation::{RelationTypeEqual, relation_type},
|
||||
type_ext::TypeExt,
|
||||
};
|
||||
use super::{pdu::Pdu, state_key::StateKey};
|
||||
use crate::{Result, utils};
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ pub trait RelationTypeEqual<E: Event> {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
struct ExtractRelatesToEventId {
|
||||
struct ExtractRelatesToRelType {
|
||||
#[serde(rename = "m.relates_to")]
|
||||
relates_to: ExtractRelType,
|
||||
}
|
||||
@@ -18,11 +18,16 @@ struct ExtractRelType {
|
||||
rel_type: RelationType,
|
||||
}
|
||||
|
||||
/// The type of an event's relation, if it has one
|
||||
pub fn relation_type<E: Event>(event: &E) -> Option<RelationType> {
|
||||
event
|
||||
.get_content()
|
||||
.map(|c: ExtractRelatesToRelType| c.relates_to.rel_type)
|
||||
.ok()
|
||||
}
|
||||
|
||||
impl<E: Event> RelationTypeEqual<E> for RelationType {
|
||||
fn relation_type_equal(&self, event: &E) -> bool {
|
||||
event
|
||||
.get_content()
|
||||
.map(|c: ExtractRelatesToEventId| c.relates_to.rel_type)
|
||||
.is_ok_and(|r| r == *self)
|
||||
relation_type(event).is_some_and(|r| r == *self)
|
||||
}
|
||||
}
|
||||
@@ -105,6 +105,16 @@ impl Count {
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether this comes after `other` when going in the direction of `dir`
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn is_after(self, other: Self, dir: Direction) -> bool {
|
||||
match dir {
|
||||
| Direction::Forward => self > other,
|
||||
| Direction::Backward => self < other,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn saturating_add(self, add: u64) -> Self {
|
||||
|
||||
@@ -5,17 +5,21 @@ use futures::{
|
||||
future::{OptionFuture, join, join3},
|
||||
};
|
||||
use ruma::{
|
||||
Int, OwnedUserId, RoomVersionId, UserId,
|
||||
AnyKeyName, CanonicalJsonObject, Int, OwnedUserId, RoomVersionId, SigningKeyId, UserId,
|
||||
events::room::{
|
||||
join_rules::{JoinRule, RoomJoinRulesEventContent},
|
||||
member::{MembershipState, ThirdPartyInvite},
|
||||
member::MembershipState,
|
||||
power_levels::{RoomPowerLevelsEventContent, UserPowerLevel},
|
||||
third_party_invite::PublicKey,
|
||||
},
|
||||
int,
|
||||
room_version_rules::{RoomIdFormatVersion, RoomVersionRules},
|
||||
serde::Raw,
|
||||
serde::{Raw, base64, base64::Standard},
|
||||
signatures,
|
||||
signatures::to_canonical_json_string_for_signing,
|
||||
third_party_invite::IdentityServerBase64PublicKey,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{from_str as from_json_str, value::RawValue as RawJsonValue};
|
||||
|
||||
use super::{
|
||||
@@ -25,7 +29,7 @@ use super::{
|
||||
deserialize_power_levels_content_redact,
|
||||
},
|
||||
};
|
||||
use crate::{debug, error, trace, warn};
|
||||
use crate::{debug, err, error, trace, warn};
|
||||
|
||||
// FIXME: field extracting could be bundled for `content`
|
||||
#[derive(Deserialize)]
|
||||
@@ -48,6 +52,40 @@ struct RoomCreateContentFields {
|
||||
federate: bool,
|
||||
}
|
||||
|
||||
// Workaround for https://github.com/matrix-org/matrix-spec/issues/2471
|
||||
#[derive(Deserialize, Debug)]
|
||||
struct RoomThirdPartyInviteContentFields {
|
||||
public_key: Option<IdentityServerBase64PublicKey>,
|
||||
public_keys: Option<Vec<PublicKey>>,
|
||||
}
|
||||
|
||||
// same here sort of (maintainers see https://forgejo.ellis.link/continuwuation/continuwuity-sec/issues/41)
|
||||
#[derive(Deserialize, Debug)]
|
||||
struct MemberThirdPartyInviteSignedContent {
|
||||
signed: ThirdPartyInviteSignedObject,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct ThirdPartyInviteSignedObject(CanonicalJsonObject);
|
||||
|
||||
impl ThirdPartyInviteSignedObject {
|
||||
#[inline]
|
||||
fn mxid(&self) -> Option<OwnedUserId> {
|
||||
self.0
|
||||
.get("mxid")?
|
||||
.as_str()
|
||||
.and_then(|raw| UserId::parse(raw).ok())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn token(&self) -> Option<&str> { self.0.get("token")?.as_str() }
|
||||
|
||||
#[inline]
|
||||
fn signatures(&self) -> Option<CanonicalJsonObject> {
|
||||
self.0.get("signatures")?.as_object().map(ToOwned::to_owned)
|
||||
}
|
||||
}
|
||||
|
||||
/// For the given event `kind` what are the relevant auth events that are needed
|
||||
/// to authenticate this `content`.
|
||||
///
|
||||
@@ -61,7 +99,7 @@ pub fn auth_types_for_event(
|
||||
state_key: Option<&str>,
|
||||
content: &RawJsonValue,
|
||||
room_version: &RoomVersionRules,
|
||||
) -> serde_json::Result<Vec<(StateEventType, StateKey)>> {
|
||||
) -> crate::Result<Vec<(StateEventType, StateKey)>> {
|
||||
if kind == &TimelineEventType::RoomCreate {
|
||||
return Ok(vec![]);
|
||||
}
|
||||
@@ -84,7 +122,7 @@ pub fn auth_types_for_event(
|
||||
#[allow(unused)]
|
||||
struct RoomMemberContentFields {
|
||||
membership: Option<Raw<MembershipState>>,
|
||||
third_party_invite: Option<Raw<ThirdPartyInvite>>,
|
||||
third_party_invite: Option<Raw<MemberThirdPartyInviteSignedContent>>,
|
||||
join_authorised_via_users_server: Option<Raw<OwnedUserId>>,
|
||||
}
|
||||
|
||||
@@ -116,16 +154,24 @@ pub fn auth_types_for_event(
|
||||
auth_types.push(key);
|
||||
}
|
||||
|
||||
// TODO: restore this once 3pid support isn't broken
|
||||
// if membership == MembershipState::Invite {
|
||||
// if let Some(Ok(t_id)) = content.third_party_invite.map(|t|
|
||||
// t.deserialize()) { let key =
|
||||
// (StateEventType::RoomThirdPartyInvite,
|
||||
// t_id.signed.token.into()); if !auth_types.contains(&
|
||||
// key) { auth_types.push(key);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if membership == MembershipState::Invite {
|
||||
if let Some(Ok(t_id)) = content.third_party_invite.map(|t| t.deserialize()) {
|
||||
let key = (
|
||||
StateEventType::RoomThirdPartyInvite,
|
||||
t_id.signed
|
||||
.token()
|
||||
.ok_or_else(|| {
|
||||
err!(Request(BadJson(
|
||||
"Third party invite content missing a token"
|
||||
)))
|
||||
})?
|
||||
.into(),
|
||||
);
|
||||
if !auth_types.contains(&key) {
|
||||
auth_types.push(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,12 +225,11 @@ fn get_user_power_level(
|
||||
pub async fn auth_check<E, F, Fut>(
|
||||
room_version: &RoomVersionRules,
|
||||
incoming_event: &E,
|
||||
current_third_party_invite: Option<&E>,
|
||||
fetch_state: F,
|
||||
create_event: &E,
|
||||
) -> Result<bool, Error>
|
||||
where
|
||||
F: Fn(&StateEventType, &str) -> Fut + Send,
|
||||
F: Fn(&StateEventType, &str) -> Fut + Send + Copy,
|
||||
Fut: Future<Output = Option<E>> + Send,
|
||||
E: Event + Send + Sync,
|
||||
for<'a> &'a E: Event + Send,
|
||||
@@ -444,13 +489,15 @@ where
|
||||
sender,
|
||||
sender_member_event.as_ref(),
|
||||
incoming_event,
|
||||
current_third_party_invite,
|
||||
fetch_state,
|
||||
power_levels_event.as_ref(),
|
||||
join_rules_event.as_ref(),
|
||||
user_for_join_auth.as_deref(),
|
||||
&user_for_join_auth_membership,
|
||||
&room_create_event,
|
||||
)? {
|
||||
)
|
||||
.await?
|
||||
{
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
@@ -639,14 +686,14 @@ where
|
||||
/// event and the current State.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
fn valid_membership_change<E>(
|
||||
async fn valid_membership_change<E, F, Fut>(
|
||||
room_version: &RoomVersionRules,
|
||||
target_user: &UserId,
|
||||
target_user_membership_event: Option<&E>,
|
||||
sender: &UserId,
|
||||
sender_membership_event: Option<&E>,
|
||||
current_event: &E,
|
||||
current_third_party_invite: Option<&E>,
|
||||
fetch_state: F,
|
||||
power_levels_event: Option<&E>,
|
||||
join_rules_event: Option<&E>,
|
||||
user_for_join_auth: Option<&UserId>,
|
||||
@@ -655,11 +702,13 @@ fn valid_membership_change<E>(
|
||||
) -> Result<bool>
|
||||
where
|
||||
E: Event + Send + Sync,
|
||||
F: Fn(&StateEventType, &str) -> Fut + Send + Copy,
|
||||
Fut: Future<Output = Option<E>> + Send,
|
||||
for<'a> &'a E: Event + Send,
|
||||
{
|
||||
#[derive(Deserialize)]
|
||||
struct GetThirdPartyInvite {
|
||||
third_party_invite: Option<Raw<ThirdPartyInvite>>,
|
||||
third_party_invite: Option<Raw<MemberThirdPartyInviteSignedContent>>,
|
||||
}
|
||||
let create_content = from_json_str::<RoomCreateContentFields>(create_room.content().get())?;
|
||||
let creator = if room_version.authorization.use_room_create_sender {
|
||||
@@ -901,22 +950,18 @@ where
|
||||
| MembershipState::Invite => {
|
||||
// If content has third_party_invite key
|
||||
trace!("starting target_membership=invite check");
|
||||
match third_party_invite.and_then(|i| i.deserialize().ok()) {
|
||||
| Some(tp_id) =>
|
||||
match third_party_invite {
|
||||
| Some(raw_tp_id) =>
|
||||
if target_user_current_membership == MembershipState::Ban {
|
||||
warn!(?target_user_membership_event_id, "Can't invite banned user");
|
||||
false
|
||||
} else {
|
||||
let allow = verify_third_party_invite(
|
||||
Some(target_user),
|
||||
sender,
|
||||
&tp_id,
|
||||
current_third_party_invite,
|
||||
);
|
||||
if !allow {
|
||||
warn!("Third party invite invalid");
|
||||
}
|
||||
allow
|
||||
let Ok(tp_id) = raw_tp_id.deserialize() else {
|
||||
warn!("Invite third party content is invalid");
|
||||
return Ok(false);
|
||||
};
|
||||
verify_third_party_invite(Some(target_user), sender, &tp_id, fetch_state)
|
||||
.await
|
||||
},
|
||||
| _ =>
|
||||
if !sender_is_joined {
|
||||
@@ -1435,14 +1480,133 @@ fn get_send_level(
|
||||
.unwrap_or_else(|| if state_key.is_some() { int!(50) } else { int!(0) })
|
||||
}
|
||||
|
||||
fn verify_third_party_invite(
|
||||
_target_user: Option<&UserId>,
|
||||
_sender: &UserId,
|
||||
_tp_id: &ThirdPartyInvite,
|
||||
_current_third_party_invite: Option<&impl Event>,
|
||||
) -> bool {
|
||||
// TODO: implement proper verification here
|
||||
true
|
||||
async fn verify_third_party_invite<F, Fut, E>(
|
||||
target_user: Option<&UserId>,
|
||||
sender: &UserId,
|
||||
tp_id: &MemberThirdPartyInviteSignedContent,
|
||||
fetch_state: F,
|
||||
) -> bool
|
||||
where
|
||||
F: Fn(&StateEventType, &str) -> Fut + Send,
|
||||
Fut: Future<Output = Option<E>> + Send,
|
||||
E: Event + Send + Sync,
|
||||
{
|
||||
// If content.third_party_invite does not have a signed property, reject.
|
||||
// ^ This would be a deserialization error before this function call, which
|
||||
// equates to a rejection
|
||||
let signed = &tp_id.signed;
|
||||
// If signed does not have mxid and token properties, reject.
|
||||
let Some(mxid) = signed.mxid() else {
|
||||
warn!("Invite third party signed content is missing or has invalid `mxid` property");
|
||||
return false;
|
||||
};
|
||||
let Some(token) = signed.token() else {
|
||||
warn!("Invite third party signed content is missing or has invalid `token` property");
|
||||
return false;
|
||||
};
|
||||
if let Err(e) = mxid.validate_historical() {
|
||||
warn!(error=?e, ?mxid, "Invite third party signed content has invalid `mxid` property");
|
||||
return false;
|
||||
}
|
||||
// If mxid does not match state_key, reject.
|
||||
// N.B. target_user is the state_key
|
||||
if target_user.is_none_or(|u| u != mxid) {
|
||||
warn!(?target_user, %mxid, "Invite third party mxid does not match membership state key");
|
||||
return false;
|
||||
}
|
||||
// If there is no m.room.third_party_invite event in the current room state
|
||||
// with state_key matching token, reject.
|
||||
let Some(current_third_party_invite) =
|
||||
fetch_state(&StateEventType::RoomThirdPartyInvite, token).await
|
||||
else {
|
||||
warn!("No third party invite associated with the invite's third party invite found");
|
||||
return false;
|
||||
};
|
||||
let Ok(tpi_content) = current_third_party_invite
|
||||
.get_content::<RoomThirdPartyInviteContentFields>()
|
||||
.inspect_err(
|
||||
|e| warn!(error=?e, "Third party invite event content is invalid (cannot deserialize)"),
|
||||
)
|
||||
else {
|
||||
return false;
|
||||
};
|
||||
if current_third_party_invite.state_key() != Some(token) {
|
||||
warn!(
|
||||
state_key=?current_third_party_invite.state_key(),
|
||||
%token,
|
||||
"Third party invite state key mismatch with signed invite token"
|
||||
);
|
||||
return false;
|
||||
}
|
||||
// If sender does not match sender of the m.room.third_party_invite, reject.
|
||||
if sender != current_third_party_invite.sender() {
|
||||
warn!(
|
||||
?sender,
|
||||
third_party_invite_sender=%current_third_party_invite.sender(),
|
||||
"Third party invite sender does not match invite membership sender"
|
||||
);
|
||||
return false;
|
||||
}
|
||||
// If any signature in signed matches any public key in the
|
||||
// m.room.third_party_invite event, allow. The public keys are in content of
|
||||
// m.room.third_party_invite as:
|
||||
//
|
||||
// A single public key in the public_key property.
|
||||
// A list of public keys in the public_keys property.
|
||||
|
||||
// NOTE: Technically the two below operations shouldn't be fallible at this
|
||||
// point in execution, but if we can't de/serialize them now, we won't be
|
||||
// able to in the future, so rejecting the event is the right way to go.
|
||||
// We log an error though since this is unexpected.
|
||||
let Ok(signed_json) = to_canonical_json_string_for_signing(&signed.0).inspect_err(
|
||||
|e| error!(error=?e, "Canonical signed object cannot be cast to a signing string"),
|
||||
) else {
|
||||
return false;
|
||||
};
|
||||
let signatures = signed
|
||||
.signatures()
|
||||
.unwrap_or_default() // Empty sigs object will never pass so this is fine
|
||||
.values()
|
||||
.filter_map(|signatures| signatures.as_object())
|
||||
.flat_map(|signatures| {
|
||||
signatures.iter().map(|(key, sig)| {
|
||||
let key_id = SigningKeyId::<AnyKeyName>::parse(key).ok()?;
|
||||
base64::Base64::<Standard>::parse(sig.as_str()?)
|
||||
.map(|parsed| (key_id.algorithm(), parsed))
|
||||
.ok()
|
||||
})
|
||||
})
|
||||
.flatten()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
for public_key_bytes in tpi_content
|
||||
.public_key
|
||||
.into_iter()
|
||||
.chain(
|
||||
tpi_content
|
||||
.public_keys
|
||||
.unwrap_or_default()
|
||||
.iter()
|
||||
.map(|pk| pk.public_key.clone()),
|
||||
)
|
||||
.filter_map(|pk| pk.decode().ok())
|
||||
{
|
||||
for (algorithm, signature) in &signatures {
|
||||
if signatures::verify_canonical_json_bytes(
|
||||
algorithm,
|
||||
&public_key_bytes,
|
||||
signature.as_bytes(),
|
||||
signed_json.as_bytes(),
|
||||
)
|
||||
.is_ok()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
warn!("Invite via third party was not signed by any associated public keys");
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -1461,7 +1625,7 @@ mod tests {
|
||||
use serde_json::value::to_raw_value as to_raw_json_value;
|
||||
|
||||
use crate::{
|
||||
matrix::{Event, EventTypeExt, Pdu as PduEvent},
|
||||
matrix::{Event, EventTypeExt},
|
||||
state_res::{
|
||||
StateMap,
|
||||
event_auth::valid_membership_change,
|
||||
@@ -1472,8 +1636,8 @@ mod tests {
|
||||
},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_ban_pass() {
|
||||
#[tokio::test]
|
||||
async fn test_ban_pass() {
|
||||
let _ = tracing::subscriber::set_default(
|
||||
tracing_subscriber::fmt().with_test_writer().finish(),
|
||||
);
|
||||
@@ -1495,6 +1659,8 @@ mod tests {
|
||||
);
|
||||
|
||||
let fetch_state = |ty, key| auth_events.get(&(ty, key)).cloned();
|
||||
let async_fetch_state =
|
||||
|t: &StateEventType, k: &str| std::future::ready(fetch_state(t.to_owned(), k.into()));
|
||||
let target_user = charlie();
|
||||
let sender = alice();
|
||||
|
||||
@@ -1506,19 +1672,20 @@ mod tests {
|
||||
sender,
|
||||
fetch_state(StateEventType::RoomMember, sender.as_str().into()).as_ref(),
|
||||
&requester,
|
||||
None::<&PduEvent>,
|
||||
&async_fetch_state,
|
||||
fetch_state(StateEventType::RoomPowerLevels, "".into()).as_ref(),
|
||||
fetch_state(StateEventType::RoomJoinRules, "".into()).as_ref(),
|
||||
None,
|
||||
&MembershipState::Leave,
|
||||
&fetch_state(StateEventType::RoomCreate, "".into()).unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_join_non_creator() {
|
||||
#[tokio::test]
|
||||
async fn test_join_non_creator() {
|
||||
let _ = tracing::subscriber::set_default(
|
||||
tracing_subscriber::fmt().with_test_writer().finish(),
|
||||
);
|
||||
@@ -1540,6 +1707,8 @@ mod tests {
|
||||
);
|
||||
|
||||
let fetch_state = |ty, key| auth_events.get(&(ty, key)).cloned();
|
||||
let async_fetch_state =
|
||||
|t: &StateEventType, k: &str| std::future::ready(fetch_state(t.to_owned(), k.into()));
|
||||
let target_user = charlie();
|
||||
let sender = charlie();
|
||||
|
||||
@@ -1551,19 +1720,20 @@ mod tests {
|
||||
sender,
|
||||
fetch_state(StateEventType::RoomMember, sender.as_str().into()).as_ref(),
|
||||
&requester,
|
||||
None::<&PduEvent>,
|
||||
&async_fetch_state,
|
||||
fetch_state(StateEventType::RoomPowerLevels, "".into()).as_ref(),
|
||||
fetch_state(StateEventType::RoomJoinRules, "".into()).as_ref(),
|
||||
None,
|
||||
&MembershipState::Leave,
|
||||
&fetch_state(StateEventType::RoomCreate, "".into()).unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_join_creator() {
|
||||
#[tokio::test]
|
||||
async fn test_join_creator() {
|
||||
let _ = tracing::subscriber::set_default(
|
||||
tracing_subscriber::fmt().with_test_writer().finish(),
|
||||
);
|
||||
@@ -1585,6 +1755,8 @@ mod tests {
|
||||
);
|
||||
|
||||
let fetch_state = |ty, key| auth_events.get(&(ty, key)).cloned();
|
||||
let async_fetch_state =
|
||||
|t: &StateEventType, k: &str| std::future::ready(fetch_state(t.to_owned(), k.into()));
|
||||
let target_user = alice();
|
||||
let sender = alice();
|
||||
|
||||
@@ -1596,19 +1768,20 @@ mod tests {
|
||||
sender,
|
||||
fetch_state(StateEventType::RoomMember, sender.as_str().into()).as_ref(),
|
||||
&requester,
|
||||
None::<&PduEvent>,
|
||||
&async_fetch_state,
|
||||
fetch_state(StateEventType::RoomPowerLevels, "".into()).as_ref(),
|
||||
fetch_state(StateEventType::RoomJoinRules, "".into()).as_ref(),
|
||||
None,
|
||||
&MembershipState::Leave,
|
||||
&fetch_state(StateEventType::RoomCreate, "".into()).unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ban_fail() {
|
||||
#[tokio::test]
|
||||
async fn test_ban_fail() {
|
||||
let _ = tracing::subscriber::set_default(
|
||||
tracing_subscriber::fmt().with_test_writer().finish(),
|
||||
);
|
||||
@@ -1630,6 +1803,8 @@ mod tests {
|
||||
);
|
||||
|
||||
let fetch_state = |ty, key| auth_events.get(&(ty, key)).cloned();
|
||||
let async_fetch_state =
|
||||
|t: &StateEventType, k: &str| std::future::ready(fetch_state(t.to_owned(), k.into()));
|
||||
let target_user = alice();
|
||||
let sender = charlie();
|
||||
|
||||
@@ -1641,19 +1816,20 @@ mod tests {
|
||||
sender,
|
||||
fetch_state(StateEventType::RoomMember, sender.as_str().into()).as_ref(),
|
||||
&requester,
|
||||
None::<&PduEvent>,
|
||||
&async_fetch_state,
|
||||
fetch_state(StateEventType::RoomPowerLevels, "".into()).as_ref(),
|
||||
fetch_state(StateEventType::RoomJoinRules, "".into()).as_ref(),
|
||||
None,
|
||||
&MembershipState::Leave,
|
||||
&fetch_state(StateEventType::RoomCreate, "".into()).unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_restricted_join_rule() {
|
||||
#[tokio::test]
|
||||
async fn test_restricted_join_rule() {
|
||||
let _ = tracing::subscriber::set_default(
|
||||
tracing_subscriber::fmt().with_test_writer().finish(),
|
||||
);
|
||||
@@ -1692,6 +1868,8 @@ mod tests {
|
||||
);
|
||||
|
||||
let fetch_state = |ty, key| auth_events.get(&(ty, key)).cloned();
|
||||
let async_fetch_state =
|
||||
|t: &StateEventType, k: &str| std::future::ready(fetch_state(t.to_owned(), k.into()));
|
||||
let target_user = ella();
|
||||
let sender = ella();
|
||||
|
||||
@@ -1703,13 +1881,14 @@ mod tests {
|
||||
sender,
|
||||
fetch_state(StateEventType::RoomMember, sender.as_str().into()).as_ref(),
|
||||
&requester,
|
||||
None::<&PduEvent>,
|
||||
&async_fetch_state,
|
||||
fetch_state(StateEventType::RoomPowerLevels, "".into()).as_ref(),
|
||||
fetch_state(StateEventType::RoomJoinRules, "".into()).as_ref(),
|
||||
Some(alice()),
|
||||
&MembershipState::Join,
|
||||
&fetch_state(StateEventType::RoomCreate, "".into()).unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
);
|
||||
|
||||
@@ -1721,19 +1900,20 @@ mod tests {
|
||||
sender,
|
||||
fetch_state(StateEventType::RoomMember, sender.as_str().into()).as_ref(),
|
||||
&requester,
|
||||
None::<&PduEvent>,
|
||||
&async_fetch_state,
|
||||
fetch_state(StateEventType::RoomPowerLevels, "".into()).as_ref(),
|
||||
fetch_state(StateEventType::RoomJoinRules, "".into()).as_ref(),
|
||||
Some(ella()),
|
||||
&MembershipState::Leave,
|
||||
&fetch_state(StateEventType::RoomCreate, "".into()).unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_knock() {
|
||||
#[tokio::test]
|
||||
async fn test_knock() {
|
||||
let _ = tracing::subscriber::set_default(
|
||||
tracing_subscriber::fmt().with_test_writer().finish(),
|
||||
);
|
||||
@@ -1764,6 +1944,8 @@ mod tests {
|
||||
);
|
||||
|
||||
let fetch_state = |ty, key| auth_events.get(&(ty, key)).cloned();
|
||||
let async_fetch_state =
|
||||
|t: &StateEventType, k: &str| std::future::ready(fetch_state(t.to_owned(), k.into()));
|
||||
let target_user = ella();
|
||||
let sender = ella();
|
||||
|
||||
@@ -1775,13 +1957,14 @@ mod tests {
|
||||
sender,
|
||||
fetch_state(StateEventType::RoomMember, sender.as_str().into()).as_ref(),
|
||||
&requester,
|
||||
None::<&PduEvent>,
|
||||
&async_fetch_state,
|
||||
fetch_state(StateEventType::RoomPowerLevels, "".into()).as_ref(),
|
||||
fetch_state(StateEventType::RoomJoinRules, "".into()).as_ref(),
|
||||
None,
|
||||
&MembershipState::Leave,
|
||||
&fetch_state(StateEventType::RoomCreate, "".into()).unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -757,7 +757,8 @@ where
|
||||
Some(state_key),
|
||||
event.content(),
|
||||
room_version,
|
||||
)?;
|
||||
)
|
||||
.map_err(|e| Error::InvalidPdu(e.to_string()))?;
|
||||
trace!(list = ?auth_types, event_id = event.event_id().as_str(), "auth types for event");
|
||||
|
||||
let mut auth_state = StateMap::new();
|
||||
@@ -830,12 +831,6 @@ where
|
||||
|
||||
debug!(event_id = event.event_id().as_str(), "Running auth checks");
|
||||
|
||||
// The key for this is (eventType + a state_key of the signed token not
|
||||
// sender) so search for it
|
||||
let current_third_party = auth_state.iter().find_map(|(_, pdu)| {
|
||||
(*pdu.event_type() == TimelineEventType::RoomThirdPartyInvite).then_some(pdu)
|
||||
});
|
||||
|
||||
let fetch_state = |ty: &StateEventType, key: &str| {
|
||||
future::ready(
|
||||
auth_state
|
||||
@@ -847,7 +842,6 @@ where
|
||||
let auth_result = auth_check(
|
||||
room_version,
|
||||
&event,
|
||||
current_third_party,
|
||||
fetch_state,
|
||||
&fetch_state(&StateEventType::RoomCreate, "")
|
||||
.await
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
use std::fmt;
|
||||
|
||||
use tracing::Level;
|
||||
|
||||
use super::Result;
|
||||
use crate::error;
|
||||
|
||||
pub trait ErrLog<T, E>
|
||||
where
|
||||
E: fmt::Display,
|
||||
{
|
||||
fn log_err(self, level: Level) -> Self;
|
||||
|
||||
#[inline]
|
||||
fn err_log(self) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.log_err(Level::ERROR)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ErrDebugLog<T, E>
|
||||
where
|
||||
E: fmt::Debug,
|
||||
{
|
||||
fn log_err_debug(self, level: Level) -> Self;
|
||||
|
||||
#[inline]
|
||||
fn err_debug_log(self) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.log_err_debug(Level::ERROR)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E> ErrLog<T, E> for Result<T, E>
|
||||
where
|
||||
E: fmt::Display,
|
||||
{
|
||||
#[inline]
|
||||
fn log_err(self, level: Level) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.inspect_err(|error| error::inspect_log_level(&error, level))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E> ErrDebugLog<T, E> for Result<T, E>
|
||||
where
|
||||
E: fmt::Debug,
|
||||
{
|
||||
#[inline]
|
||||
fn log_err_debug(self, level: Level) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.inspect_err(|error| error::inspect_debug_log_level(&error, level))
|
||||
}
|
||||
}
|
||||
@@ -34,8 +34,6 @@ jemalloc_stats = [
|
||||
]
|
||||
release_max_log_level = [
|
||||
"conduwuit-core/release_max_log_level",
|
||||
"log/max_level_trace",
|
||||
"log/release_max_level_info",
|
||||
"tracing/max_level_trace",
|
||||
"tracing/release_max_level_info",
|
||||
]
|
||||
@@ -60,7 +58,6 @@ const-str.workspace = true
|
||||
ctor.workspace = true
|
||||
dtor.workspace = true
|
||||
futures.workspace = true
|
||||
log.workspace = true
|
||||
minicbor.workspace = true
|
||||
minicbor-serde.workspace = true
|
||||
rust-rocksdb.workspace = true
|
||||
|
||||
@@ -171,7 +171,7 @@ pub(super) static MAPS: &[Descriptor] = &[
|
||||
},
|
||||
Descriptor {
|
||||
name: "referencedevents",
|
||||
..descriptor::DROPPED
|
||||
..descriptor::RANDOM
|
||||
},
|
||||
Descriptor {
|
||||
name: "refreshtoken_refreshtokeninfo",
|
||||
|
||||
+8
-33
@@ -77,7 +77,6 @@ full = [
|
||||
]
|
||||
|
||||
brotli_compression = [
|
||||
"conduwuit-api/brotli_compression",
|
||||
"conduwuit-core/brotli_compression",
|
||||
"conduwuit-router/brotli_compression",
|
||||
"conduwuit-service/brotli_compression",
|
||||
@@ -89,11 +88,10 @@ direct_tls = [
|
||||
"conduwuit-router/direct_tls"
|
||||
]
|
||||
element_hacks = [
|
||||
"conduwuit-api/element_hacks",
|
||||
"conduwuit-service/element_hacks",
|
||||
"conduwuit-router/element_hacks",
|
||||
]
|
||||
gzip_compression = [
|
||||
"conduwuit-api/gzip_compression",
|
||||
"conduwuit-core/gzip_compression",
|
||||
"conduwuit-router/gzip_compression",
|
||||
"conduwuit-service/gzip_compression",
|
||||
@@ -102,21 +100,21 @@ hardened_malloc = [
|
||||
"conduwuit-core/hardened_malloc",
|
||||
]
|
||||
http3 = [
|
||||
"reqwest/http3"
|
||||
"conduwuit-service/http3"
|
||||
]
|
||||
ring = [
|
||||
"rustls/ring"
|
||||
"rustls/ring",
|
||||
]
|
||||
|
||||
aws_lc_rs = [
|
||||
"rustls/aws_lc_rs",
|
||||
"dep:aws-lc-rs"
|
||||
]
|
||||
io_uring = [
|
||||
"conduwuit-database/io_uring",
|
||||
"conduwuit-service/io_uring",
|
||||
]
|
||||
jemalloc = [
|
||||
"conduwuit-core/jemalloc",
|
||||
"conduwuit-database/jemalloc",
|
||||
"conduwuit-service/jemalloc",
|
||||
]
|
||||
jemalloc_prof = [
|
||||
"conduwuit-core/jemalloc_prof",
|
||||
@@ -145,19 +143,13 @@ perf_measurements = [
|
||||
release_max_log_level = [
|
||||
"tracing/max_level_trace",
|
||||
"tracing/release_max_level_info",
|
||||
"log/max_level_trace",
|
||||
"log/release_max_level_info",
|
||||
"conduwuit-admin/release_max_log_level",
|
||||
"conduwuit-api/release_max_log_level",
|
||||
"conduwuit-core/release_max_log_level",
|
||||
"conduwuit-database/release_max_log_level",
|
||||
"conduwuit-router/release_max_log_level",
|
||||
"conduwuit-service/release_max_log_level",
|
||||
]
|
||||
sentry_telemetry = [
|
||||
"dep:sentry",
|
||||
"dep:sentry-tracing",
|
||||
"dep:sentry-tower",
|
||||
"conduwuit-core/sentry_telemetry",
|
||||
"conduwuit-router/sentry_telemetry",
|
||||
]
|
||||
@@ -180,9 +172,7 @@ url_preview = [
|
||||
"conduwuit-service/url_preview",
|
||||
]
|
||||
zstd_compression = [
|
||||
"conduwuit-api/zstd_compression",
|
||||
"conduwuit-core/zstd_compression",
|
||||
"conduwuit-database/zstd_compression",
|
||||
"conduwuit-router/zstd_compression",
|
||||
"conduwuit-service/zstd_compression",
|
||||
]
|
||||
@@ -192,10 +182,10 @@ conduwuit_mods = [
|
||||
bindgen-static = [
|
||||
# "bindgen/static"
|
||||
# "clang-sys/static"
|
||||
"conduwuit-database/bindgen-static"
|
||||
"conduwuit-service/bindgen-static"
|
||||
]
|
||||
bindgen-runtime = [
|
||||
"conduwuit-database/bindgen-runtime"
|
||||
"conduwuit-service/bindgen-runtime"
|
||||
]
|
||||
|
||||
[build-dependencies]
|
||||
@@ -203,10 +193,7 @@ bindgen-runtime = [
|
||||
# clang-sys = {version = "1", default-features = false}
|
||||
|
||||
[dependencies]
|
||||
conduwuit-admin.workspace = true
|
||||
conduwuit-api.workspace = true
|
||||
conduwuit-core.workspace = true
|
||||
conduwuit-database.workspace = true
|
||||
conduwuit-router.workspace = true
|
||||
conduwuit-service.workspace = true
|
||||
conduwuit-build-metadata.workspace = true
|
||||
@@ -218,7 +205,6 @@ dtor.workspace = true
|
||||
console-subscriber.optional = true
|
||||
console-subscriber.workspace = true
|
||||
const-str.workspace = true
|
||||
log.workspace = true
|
||||
opentelemetry.workspace = true
|
||||
opentelemetry-otlp.optional = true
|
||||
opentelemetry-otlp.workspace = true
|
||||
@@ -226,14 +212,10 @@ opentelemetry-prometheus.workspace = true
|
||||
opentelemetry-semantic-conventions.workspace = true
|
||||
opentelemetry_sdk.workspace = true
|
||||
prometheus.workspace = true
|
||||
sentry-tower.optional = true
|
||||
sentry-tower.workspace = true
|
||||
sentry-tracing.optional = true
|
||||
sentry-tracing.workspace = true
|
||||
sentry.optional = true
|
||||
sentry.workspace = true
|
||||
tokio-metrics.optional = true
|
||||
tokio-metrics.workspace = true
|
||||
tokio.workspace = true
|
||||
tracing-flame.optional = true
|
||||
tracing-flame.workspace = true
|
||||
@@ -243,14 +225,7 @@ tracing-subscriber.workspace = true
|
||||
tracing.workspace = true
|
||||
tracing-journald = { workspace = true, optional = true }
|
||||
parking_lot.workspace = true
|
||||
reqwest = { workspace = true, default-features = false }
|
||||
rustls = { workspace = true, default-features = false }
|
||||
aws-lc-rs = { version = "1.16.3", default-features = false, optional = true }
|
||||
|
||||
|
||||
[target.'cfg(all(not(target_env = "msvc"), target_os = "linux"))'.dependencies]
|
||||
hardened_malloc-rs.workspace = true
|
||||
hardened_malloc-rs.optional = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
+9
-1
@@ -60,10 +60,18 @@ pub(crate) fn init(
|
||||
|
||||
#[cfg(feature = "sentry_telemetry")]
|
||||
let subscriber = {
|
||||
use tracing::Level;
|
||||
use tracing_subscriber::filter::{LevelFilter, filter_fn};
|
||||
|
||||
let sentry_filter = EnvFilter::try_new(&config.sentry_filter)
|
||||
.map_err(|e| err!(Config("sentry_filter", "{e}.")))?;
|
||||
|
||||
let sentry_layer = sentry_tracing::layer();
|
||||
let sentry_layer = sentry_tracing::SpanLayer::new()
|
||||
.with_filter(LevelFilter::INFO)
|
||||
.and_then(sentry_tracing::BreadcrumbLayer::new().with_filter(filter_fn(|metadata| {
|
||||
matches!(*metadata.level(), Level::WARN | Level::INFO)
|
||||
})))
|
||||
.and_then(sentry_tracing::ErrorLayer::new().with_filter(LevelFilter::ERROR));
|
||||
let (sentry_reload_filter, sentry_reload_handle) = reload::Layer::new(sentry_filter);
|
||||
|
||||
reload_handles.add("sentry", Box::new(sentry_reload_handle));
|
||||
|
||||
+4
-14
@@ -25,9 +25,11 @@ brotli_compression = [
|
||||
]
|
||||
direct_tls = [
|
||||
"axum-server/tls-rustls-no-provider",
|
||||
"dep:rustls",
|
||||
"dep:axum-server-dual-protocol",
|
||||
]
|
||||
element_hacks = [
|
||||
"conduwuit-api/element_hacks",
|
||||
]
|
||||
gzip_compression = [
|
||||
"conduwuit-admin/gzip_compression",
|
||||
"conduwuit-api/gzip_compression",
|
||||
@@ -71,13 +73,9 @@ release_max_log_level = [
|
||||
"conduwuit-service/release_max_log_level",
|
||||
"tracing/max_level_trace",
|
||||
"tracing/release_max_level_info",
|
||||
"log/max_level_trace",
|
||||
"log/release_max_level_info",
|
||||
]
|
||||
sentry_telemetry = [
|
||||
"conduwuit-core/sentry_telemetry",
|
||||
"dep:sentry",
|
||||
"dep:sentry-tracing",
|
||||
"dep:sentry-tower",
|
||||
]
|
||||
systemd = [
|
||||
@@ -110,17 +108,9 @@ http.workspace = true
|
||||
http-body-util.workspace = true
|
||||
hyper.workspace = true
|
||||
hyper-util.workspace = true
|
||||
log.workspace = true
|
||||
opentelemetry-instrumentation-tower.workspace = true
|
||||
ruma.workspace = true
|
||||
rustls.workspace = true
|
||||
rustls.optional = true
|
||||
sentry.optional = true
|
||||
sentry.workspace = true
|
||||
sentry-tower.optional = true
|
||||
sentry-tower.workspace = true
|
||||
sentry-tracing.optional = true
|
||||
sentry-tracing.workspace = true
|
||||
sentry-tower = { workspace = true, optional = true }
|
||||
serde_json.workspace = true
|
||||
tokio.workspace = true
|
||||
tower.workspace = true
|
||||
|
||||
@@ -25,7 +25,7 @@ http.workspace = true
|
||||
ruma.workspace = true
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
wildmatch = "2.6.1"
|
||||
wildmatch = "2.7.0"
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
|
||||
@@ -16,6 +16,12 @@ crate-type = [
|
||||
]
|
||||
|
||||
[features]
|
||||
bindgen-runtime = [
|
||||
"conduwuit-database/bindgen-runtime"
|
||||
]
|
||||
bindgen-static = [
|
||||
"conduwuit-database/bindgen-static"
|
||||
]
|
||||
brotli_compression = [
|
||||
"conduwuit-core/brotli_compression",
|
||||
"reqwest/brotli",
|
||||
@@ -29,6 +35,9 @@ gzip_compression = [
|
||||
"conduwuit-core/gzip_compression",
|
||||
"reqwest/gzip",
|
||||
]
|
||||
http3 = [
|
||||
"reqwest/http3"
|
||||
]
|
||||
io_uring = [
|
||||
"conduwuit-database/io_uring",
|
||||
]
|
||||
@@ -122,6 +131,9 @@ lettre.workspace = true
|
||||
resolvematrix.workspace = true
|
||||
serde_urlencoded.workspace = true
|
||||
openidconnect.workspace = true
|
||||
# We use this to set TLS backend features on the outdated reqwest bundled by openidconnect,
|
||||
# which is necessary to call `danger_accept_invalid_certs`.
|
||||
reqwest_0_12.workspace = true
|
||||
rand.workspace = true
|
||||
|
||||
[target.'cfg(all(unix, target_os = "linux"))'.dependencies]
|
||||
@@ -130,3 +142,10 @@ sd-notify.optional = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[package.metadata.cargo-shear]
|
||||
ignored = ["reqwest_0_12"]
|
||||
|
||||
[dev-dependencies]
|
||||
opentelemetry.workspace = true
|
||||
rustls = { workspace = true, features = ["ring"] }
|
||||
@@ -0,0 +1,61 @@
|
||||
use std::{
|
||||
net::{IpAddr, SocketAddr},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use hickory_resolver::{Resolver, net::runtime::TokioRuntimeProvider};
|
||||
use reqwest::dns::{Addrs, Resolving};
|
||||
|
||||
/// A simple struct to implement reqwest::dns::Resolve, as that is what's
|
||||
/// required by the reqwest client builder. Most code is based on
|
||||
/// reqwest::dns::HickoryDnsResolver, which we here have to almost re-create
|
||||
/// because it's pub(crate) instead of pub:
|
||||
pub struct DnsResolver {
|
||||
resolver: Arc<TokioResolver>,
|
||||
}
|
||||
|
||||
type TokioResolver = Resolver<TokioRuntimeProvider>;
|
||||
|
||||
impl DnsResolver {
|
||||
pub(crate) fn new(resolver: Arc<TokioResolver>) -> Self { Self { resolver } }
|
||||
}
|
||||
|
||||
struct SocketAddrs {
|
||||
iter: std::vec::IntoIter<IpAddr>,
|
||||
}
|
||||
|
||||
impl Iterator for SocketAddrs {
|
||||
type Item = SocketAddr;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
self.iter.next().map(|ip_addr| SocketAddr::new(ip_addr, 0))
|
||||
}
|
||||
}
|
||||
|
||||
impl reqwest::dns::Resolve for DnsResolver {
|
||||
fn resolve(&self, name: reqwest::dns::Name) -> Resolving {
|
||||
let resolver = self.resolver.clone();
|
||||
Box::pin(async move {
|
||||
let lookup = resolver.lookup_ip(name.as_str()).await?;
|
||||
let addrs: Addrs = Box::new(SocketAddrs {
|
||||
iter: lookup.iter().collect::<Vec<_>>().into_iter(),
|
||||
});
|
||||
Ok(addrs)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// openidconnect is weird and vendors reqwest (?), therefore we have to
|
||||
// completely re-implement Resolve with different types
|
||||
impl openidconnect::reqwest::dns::Resolve for DnsResolver {
|
||||
fn resolve(&self, name: openidconnect::reqwest::dns::Name) -> Resolving {
|
||||
let resolver = self.resolver.clone();
|
||||
Box::pin(async move {
|
||||
let lookup = resolver.lookup_ip(name.as_str()).await?;
|
||||
let addrs: Addrs = Box::new(SocketAddrs {
|
||||
iter: lookup.iter().collect::<Vec<_>>().into_iter(),
|
||||
});
|
||||
Ok(addrs)
|
||||
})
|
||||
}
|
||||
}
|
||||
+76
-42
@@ -1,26 +1,39 @@
|
||||
mod dns_resolver;
|
||||
|
||||
use std::{sync::Arc, time::Duration};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use conduwuit::{Config, Result, Server, err, trace, utils::response::LimitReadExt, warn};
|
||||
use conduwuit::{
|
||||
Config, Result, Server, debug, err, info, trace, utils::response::LimitReadExt, warn,
|
||||
};
|
||||
pub(crate) use dns_resolver::DnsResolver;
|
||||
use either::Either;
|
||||
use hickory_resolver::{
|
||||
TokioResolver,
|
||||
config::{ConnectionConfig, NameServerConfig},
|
||||
config::{ConnectionConfig, NameServerConfig, ResolverConfig},
|
||||
net::runtime::TokioRuntimeProvider,
|
||||
proto::rr::IntoName,
|
||||
};
|
||||
use ipaddress::IPAddress;
|
||||
use reqwest::redirect;
|
||||
use reqwest::{dns::Resolve, redirect};
|
||||
use resolvematrix::server::{MatrixResolver, MatrixResolverBuilder};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::service;
|
||||
|
||||
pub struct Service {
|
||||
pub matrix_resolver: Arc<MatrixResolver>,
|
||||
/// Regular DNS resolver
|
||||
pub dns_resolver: Arc<TokioResolver>,
|
||||
|
||||
pub dns: reqwest::Client,
|
||||
/// Tokio system resolver wrapped
|
||||
pub reqwest_resolver: Arc<DnsResolver>,
|
||||
|
||||
/// Matrix server resolver according to server resolution spec
|
||||
pub matrix_resolver: Arc<MatrixResolver>,
|
||||
|
||||
/// HTTP client used for fetching files during server resolution
|
||||
pub matrix_http_client: reqwest::Client,
|
||||
|
||||
pub url_preview: reqwest::Client,
|
||||
pub external_resource: reqwest::Client,
|
||||
pub federation: reqwest::Client,
|
||||
@@ -38,9 +51,18 @@ impl crate::Service for Service {
|
||||
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
|
||||
let config = &args.server.config;
|
||||
|
||||
let dns_resolver = get_dns_resolver(args.server)?;
|
||||
// Regular DNS resolver
|
||||
let tokio_dns_resolver = get_dns_resolver(args.server)?;
|
||||
|
||||
let dns_client = base(&args.server.config)?
|
||||
// More different DNS resolver that also implements
|
||||
// reqwest::dns::Resolve (which is required for reqwest to use it).
|
||||
// Don't ask me, I just work here. - @silversys
|
||||
let reqwest_dns_resolver = Arc::new(DnsResolver::new(tokio_dns_resolver.clone()));
|
||||
|
||||
// Regular HTTP client that does regular HTTP requests with regular DNS
|
||||
// resolution, but with timeouts for /.well-known/matrix/* files
|
||||
// according to c10y config.
|
||||
let matrix_http_client = base(&args.server.config, reqwest_dns_resolver.clone())?
|
||||
.connect_timeout(Duration::from_secs(args.server.config.well_known_conn_timeout))
|
||||
.read_timeout(Duration::from_secs(args.server.config.well_known_timeout))
|
||||
.timeout(Duration::from_secs(args.server.config.well_known_timeout))
|
||||
@@ -48,12 +70,17 @@ impl crate::Service for Service {
|
||||
.redirect(redirect::Policy::limited(4))
|
||||
.build()?;
|
||||
|
||||
// Resolves hostnames into ip+port or hostname+port server combinations
|
||||
// according to the server resolution spec
|
||||
let matrix_resolver = Arc::new(MatrixResolverBuilder::new()
|
||||
.dangerous_tls_accept_invalid_certs(args.server.config.allow_invalid_tls_certificates_yes_i_know_what_the_fuck_i_am_doing_with_this_and_i_know_this_is_insecure)
|
||||
.http_client(dns_client.clone())
|
||||
.dns_resolver(dns_resolver.clone())
|
||||
.build()?);
|
||||
let matrix_dns_resolver = matrix_resolver.create_dns_resolver();
|
||||
.dangerous_tls_accept_invalid_certs(args.server.config.allow_invalid_tls_certificates_yes_i_know_what_the_fuck_i_am_doing_with_this_and_i_know_this_is_insecure)
|
||||
.http_client(matrix_http_client.clone())
|
||||
.dns_resolver(tokio_dns_resolver.clone())
|
||||
.build()?);
|
||||
// Does the same as the above, but acts as a DNS resolver for reqwest
|
||||
// (implementing caching and following the matrix server resolution
|
||||
// spec)
|
||||
let matrix_dns_resolver = Arc::new(matrix_resolver.create_dns_resolver());
|
||||
|
||||
let url_preview_bind_addr = config
|
||||
.url_preview_bound_interface
|
||||
@@ -72,11 +99,12 @@ impl crate::Service for Service {
|
||||
|
||||
Ok(Arc::new(Self {
|
||||
matrix_resolver,
|
||||
dns_resolver,
|
||||
matrix_http_client,
|
||||
reqwest_resolver: reqwest_dns_resolver.clone(),
|
||||
|
||||
dns: dns_client,
|
||||
dns_resolver: tokio_dns_resolver,
|
||||
|
||||
url_preview: base(config)
|
||||
url_preview: base(config, reqwest_dns_resolver.clone())
|
||||
.and_then(|builder| {
|
||||
builder_interface(builder, url_preview_bind_iface.as_deref())
|
||||
})?
|
||||
@@ -86,12 +114,11 @@ impl crate::Service for Service {
|
||||
.user_agent(url_preview_user_agent)
|
||||
.build()?,
|
||||
|
||||
external_resource: base(config)?
|
||||
external_resource: base(config, reqwest_dns_resolver.clone())?
|
||||
.redirect(redirect::Policy::limited(3))
|
||||
.build()?,
|
||||
|
||||
federation: base(config)?
|
||||
.dns_resolver(matrix_dns_resolver.clone())
|
||||
federation: base(config, matrix_dns_resolver.clone())?
|
||||
.connect_timeout(Duration::from_secs(config.federation_conn_timeout))
|
||||
.read_timeout(Duration::from_secs(config.federation_timeout))
|
||||
.timeout(Duration::from_secs(
|
||||
@@ -104,8 +131,7 @@ impl crate::Service for Service {
|
||||
.redirect(redirect::Policy::limited(3))
|
||||
.build()?,
|
||||
|
||||
federation_slow: base(config)?
|
||||
.dns_resolver(matrix_dns_resolver.clone())
|
||||
federation_slow: base(config, matrix_dns_resolver.clone())?
|
||||
.connect_timeout(Duration::from_secs(config.federation_conn_timeout))
|
||||
.read_timeout(Duration::from_secs(config.federation_timeout.saturating_mul(6)))
|
||||
.timeout(Duration::from_secs(
|
||||
@@ -118,8 +144,7 @@ impl crate::Service for Service {
|
||||
.redirect(redirect::Policy::limited(3))
|
||||
.build()?,
|
||||
|
||||
sender: base(config)?
|
||||
.dns_resolver(matrix_dns_resolver.clone())
|
||||
sender: base(config, matrix_dns_resolver)?
|
||||
.connect_timeout(Duration::from_secs(config.federation_conn_timeout))
|
||||
.read_timeout(Duration::from_secs(config.sender_timeout))
|
||||
.timeout(Duration::from_secs(config.sender_timeout))
|
||||
@@ -128,8 +153,7 @@ impl crate::Service for Service {
|
||||
.redirect(redirect::Policy::limited(2))
|
||||
.build()?,
|
||||
|
||||
appservice: base(config)?
|
||||
.dns_resolver(matrix_dns_resolver)
|
||||
appservice: base(config, reqwest_dns_resolver.clone())?
|
||||
.connect_timeout(Duration::from_secs(5))
|
||||
.read_timeout(Duration::from_secs(config.appservice_timeout))
|
||||
.timeout(Duration::from_secs(config.appservice_timeout))
|
||||
@@ -138,7 +162,7 @@ impl crate::Service for Service {
|
||||
.redirect(redirect::Policy::limited(2))
|
||||
.build()?,
|
||||
|
||||
pusher: base(config)?
|
||||
pusher: base(config, reqwest_dns_resolver.clone())?
|
||||
.connect_timeout(Duration::from_secs(config.pusher_conn_timeout))
|
||||
.timeout(Duration::from_secs(config.pusher_timeout))
|
||||
.pool_max_idle_per_host(1)
|
||||
@@ -148,7 +172,7 @@ impl crate::Service for Service {
|
||||
|
||||
// MSC4174 recommends against following redirects, since the
|
||||
// destination is only checked before the request is sent.
|
||||
webpush: base(config)?
|
||||
webpush: base(config, reqwest_dns_resolver)?
|
||||
.connect_timeout(Duration::from_secs(config.pusher_conn_timeout))
|
||||
.timeout(Duration::from_secs(config.pusher_timeout))
|
||||
.pool_max_idle_per_host(1)
|
||||
@@ -221,18 +245,21 @@ impl Service {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn base(config: &Config) -> Result<reqwest::ClientBuilder> {
|
||||
pub(crate) fn base(
|
||||
config: &Config,
|
||||
resolver: Arc<dyn Resolve>,
|
||||
) -> Result<reqwest::ClientBuilder> {
|
||||
let mut builder = reqwest::Client::builder()
|
||||
.hickory_dns(true)
|
||||
.connect_timeout(Duration::from_secs(config.request_conn_timeout))
|
||||
.read_timeout(Duration::from_secs(config.request_timeout))
|
||||
.timeout(Duration::from_secs(config.request_total_timeout))
|
||||
.pool_idle_timeout(Duration::from_secs(config.request_idle_timeout))
|
||||
.pool_max_idle_per_host(config.request_idle_per_host.into())
|
||||
.user_agent(conduwuit::user_agent())
|
||||
.redirect(redirect::Policy::limited(6))
|
||||
.dns_resolver(resolver)
|
||||
.connect_timeout(Duration::from_secs(config.request_conn_timeout))
|
||||
.read_timeout(Duration::from_secs(config.request_timeout))
|
||||
.timeout(Duration::from_secs(config.request_total_timeout))
|
||||
.pool_idle_timeout(Duration::from_secs(config.request_idle_timeout))
|
||||
.pool_max_idle_per_host(config.request_idle_per_host.into())
|
||||
.user_agent(conduwuit::user_agent())
|
||||
.redirect(redirect::Policy::limited(6))
|
||||
.danger_accept_invalid_certs(config.allow_invalid_tls_certificates_yes_i_know_what_the_fuck_i_am_doing_with_this_and_i_know_this_is_insecure)
|
||||
.connection_verbose(cfg!(debug_assertions));
|
||||
.connection_verbose(cfg!(debug_assertions));
|
||||
|
||||
#[cfg(feature = "gzip_compression")]
|
||||
{
|
||||
@@ -310,19 +337,21 @@ fn builder_interface(
|
||||
|
||||
fn get_dns_resolver(server: &Arc<Server>) -> Result<Arc<TokioResolver>> {
|
||||
let config = &server.config;
|
||||
let (sys_conf, mut opts) = hickory_resolver::system_conf::read_system_conf()
|
||||
|
||||
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 mut conf = hickory_resolver::config::ResolverConfig::default();
|
||||
let mut conf = ResolverConfig::from_name_servers(vec![]);
|
||||
|
||||
if let Some(domain) = sys_conf.domain() {
|
||||
// Set domain and search domains from system config (/etc/resolv.conf)
|
||||
if let Some(domain) = system_resolver_config.domain() {
|
||||
conf.set_domain(domain.clone());
|
||||
}
|
||||
|
||||
for sys_conf in sys_conf.search() {
|
||||
for sys_conf in system_resolver_config.search() {
|
||||
conf.add_search(sys_conf.clone());
|
||||
}
|
||||
|
||||
// Read nameservers from c10y config file
|
||||
let config_nameservers: Vec<NameServerConfig> = server
|
||||
.config
|
||||
.dns_servers
|
||||
@@ -330,11 +359,16 @@ fn get_dns_resolver(server: &Arc<Server>) -> Result<Arc<TokioResolver>> {
|
||||
.filter_map(IntoName::to_ip)
|
||||
.map(NameServerConfig::udp_and_tcp)
|
||||
.collect();
|
||||
let system_nameservers = system_resolver_config.name_servers().to_vec();
|
||||
|
||||
let nameservers = if !config_nameservers.is_empty() {
|
||||
debug!("Using DNS nameservers from config file");
|
||||
config_nameservers
|
||||
} else {
|
||||
sys_conf.name_servers().to_vec()
|
||||
debug!("Using DNS nameservers from /etc/resolv.conf");
|
||||
system_nameservers
|
||||
};
|
||||
info!(?nameservers, "Resolved nameservers for DNS client");
|
||||
|
||||
for sys_conf in nameservers {
|
||||
let mut ns = sys_conf.clone();
|
||||
|
||||
@@ -32,7 +32,7 @@ use tokio::{runtime, sync::SetOnce};
|
||||
use url::Url;
|
||||
|
||||
use crate::{
|
||||
Dep, config, globals, media,
|
||||
Dep, client, config, globals, media,
|
||||
oauth::grant::AuthorizationCodeResponse,
|
||||
threepid,
|
||||
users::{self, AccountStatus, ProfileFieldChange},
|
||||
@@ -163,6 +163,7 @@ impl crate::Service for Service {
|
||||
machine: SetOnce::new(),
|
||||
// This isn't in the client service because it has to use the `reqwest` shipped by `openidconnect`
|
||||
client: reqwest::ClientBuilder::new()
|
||||
.dns_resolver(args.depend::<client::Service>("client").reqwest_resolver.clone())
|
||||
.connect_timeout(Duration::from_secs(args.server.config.request_conn_timeout))
|
||||
.read_timeout(Duration::from_secs(args.server.config.request_timeout))
|
||||
.timeout(Duration::from_secs(args.server.config.request_total_timeout))
|
||||
|
||||
@@ -8,7 +8,7 @@ use conduwuit_database::Database;
|
||||
use p256::{
|
||||
SecretKey,
|
||||
ecdsa::{Signature, SigningKey, signature::Signer},
|
||||
elliptic_curve::sec1::ToEncodedPoint,
|
||||
elliptic_curve::sec1::ToSec1Point,
|
||||
};
|
||||
use serde_json::json;
|
||||
|
||||
@@ -48,7 +48,7 @@ impl Vapid {
|
||||
};
|
||||
|
||||
let public_key =
|
||||
URL_SAFE_NO_PAD.encode(secret.public_key().to_encoded_point(false).as_bytes());
|
||||
URL_SAFE_NO_PAD.encode(secret.public_key().to_sec1_point(false).as_bytes());
|
||||
|
||||
Ok(Self {
|
||||
secret,
|
||||
|
||||
@@ -159,15 +159,9 @@ impl super::Service {
|
||||
ready(auth_events_by_key.get(&key).map(ToOwned::to_owned))
|
||||
};
|
||||
|
||||
state_res::event_auth::auth_check(
|
||||
room_version_rules,
|
||||
pdu,
|
||||
None, // TODO: third party invite
|
||||
state_fetch,
|
||||
create_event,
|
||||
)
|
||||
.await
|
||||
.map_err(|e| err!("Event self-authentication failed: {e:?}"))
|
||||
state_res::event_auth::auth_check(room_version_rules, pdu, state_fetch, create_event)
|
||||
.await
|
||||
.map_err(|e| err!("Event self-authentication failed: {e:?}"))
|
||||
}
|
||||
|
||||
/// Checks that the event passes PDU check 5, which ensures that the event
|
||||
@@ -241,7 +235,6 @@ impl super::Service {
|
||||
let auth_check = state_res::event_auth::auth_check(
|
||||
room_version_rules,
|
||||
incoming_pdu,
|
||||
None, // TODO: third party invite
|
||||
|ty, sk| state_fetch(ty.clone(), sk.into()),
|
||||
create_event.as_pdu(),
|
||||
)
|
||||
@@ -291,7 +284,6 @@ impl super::Service {
|
||||
state_res::event_auth::auth_check(
|
||||
room_version_rules,
|
||||
incoming_pdu,
|
||||
None, // third-party invite
|
||||
state_fetch,
|
||||
create_event.as_pdu(),
|
||||
)
|
||||
|
||||
@@ -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,275 @@
|
||||
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
|
||||
}))
|
||||
.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)
|
||||
}
|
||||
@@ -617,7 +617,6 @@ impl Service {
|
||||
let auth_check = state_res::event_auth::auth_check(
|
||||
&room_version.rules().unwrap(),
|
||||
&parsed_join_pdu,
|
||||
None, // TODO: third party invite
|
||||
|k, s| state_fetch(k.clone(), s.into()),
|
||||
&create_event,
|
||||
)
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
use conduwuit::{Event, PduEvent, Result, err};
|
||||
use conduwuit::{
|
||||
Event, PduEvent, Result, err,
|
||||
matrix::{PduCount, event::relation_type},
|
||||
utils::ReadyExt,
|
||||
};
|
||||
use ruma::{
|
||||
UserId,
|
||||
api::Direction,
|
||||
events::relation::{BundledMessageLikeRelations, BundledReference, ReferenceChunk},
|
||||
events::relation::{
|
||||
BundledMessageLikeRelations, BundledReference, ReferenceChunk, RelationType,
|
||||
},
|
||||
};
|
||||
|
||||
use crate::rooms::timeline::PdusIterItem;
|
||||
|
||||
const MAX_BUNDLED_RELATIONS: usize = 50;
|
||||
|
||||
impl super::Service {
|
||||
/// Gets bundled aggregations for an event according to the Matrix
|
||||
/// specification.
|
||||
@@ -26,52 +28,24 @@ impl super::Service {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let relations = self
|
||||
.get_relations(
|
||||
user_id,
|
||||
&pdu.room_id_or_hash(),
|
||||
pdu.event_id(),
|
||||
conduwuit::PduCount::max(),
|
||||
MAX_BUNDLED_RELATIONS,
|
||||
0,
|
||||
Direction::Backward,
|
||||
)
|
||||
let Some((room_id, target)) = self
|
||||
.relation_target(&pdu.room_id_or_hash(), pdu.event_id())
|
||||
.await
|
||||
else {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
let mut replace_events = Vec::new();
|
||||
let mut reference_events = Vec::new();
|
||||
self.db
|
||||
.get_relations(room_id, target, PduCount::max(), Direction::Backward)
|
||||
.ready_for_each(|(_, relation)| match relation_type(&relation) {
|
||||
| Some(RelationType::Replacement) => replace_events.push(relation),
|
||||
| Some(RelationType::Reference) => reference_events.push(relation),
|
||||
| _ => {},
|
||||
})
|
||||
.await;
|
||||
|
||||
// The relations database code still handles the basic unsigned data
|
||||
// We don't want to recursively fetch relations
|
||||
|
||||
if relations.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
// Partition relations by type
|
||||
let (replace_events, reference_events): (Vec<_>, Vec<_>) = relations
|
||||
.iter()
|
||||
.filter_map(|relation| {
|
||||
let pdu = &relation.1;
|
||||
let content = pdu.get_content_as_value();
|
||||
|
||||
content
|
||||
.get("m.relates_to")
|
||||
.and_then(|relates_to| relates_to.get("rel_type"))
|
||||
.and_then(|rel_type| rel_type.as_str())
|
||||
.and_then(|rel_type_str| match rel_type_str {
|
||||
| "m.replace" => Some(RelationType::Replace(relation)),
|
||||
| "m.reference" => Some(RelationType::Reference(relation)),
|
||||
| _ => None, /* Ignore other relation types (threads are in DB but not
|
||||
* handled here) */
|
||||
})
|
||||
})
|
||||
.fold((Vec::new(), Vec::new()), |(mut replaces, mut references), rel_type| {
|
||||
match rel_type {
|
||||
| RelationType::Replace(r) => replaces.push(r),
|
||||
| RelationType::Reference(r) => references.push(r),
|
||||
}
|
||||
(replaces, references)
|
||||
});
|
||||
|
||||
// If no relations to bundle, return None
|
||||
if replace_events.is_empty() && reference_events.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
@@ -85,7 +59,9 @@ impl super::Service {
|
||||
.find_most_recent_valid_replacement(user_id, pdu, &replace_events)
|
||||
.await?
|
||||
{
|
||||
bundled.replace = Some(Self::serialize_replacement(replacement)?);
|
||||
bundled.replace = Some(Self::serialize_replacement(
|
||||
&self.with_unsigned(user_id, replacement.clone()).await,
|
||||
)?);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +69,7 @@ impl super::Service {
|
||||
if !reference_events.is_empty() {
|
||||
let reference_chunk: Vec<_> = reference_events
|
||||
.into_iter()
|
||||
.map(|relation| BundledReference::new(relation.1.event_id().to_owned()))
|
||||
.map(|relation| BundledReference::new(relation.event_id().to_owned()))
|
||||
.collect();
|
||||
|
||||
if !reference_chunk.is_empty() {
|
||||
@@ -123,14 +99,12 @@ impl super::Service {
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
original_event: &PduEvent,
|
||||
replacement_events: &[&'a PdusIterItem],
|
||||
replacement_events: &'a [PduEvent],
|
||||
) -> Result<Option<&'a PduEvent>> {
|
||||
// Filter valid replacements and find the maximum in a single pass
|
||||
let mut result: Option<&PduEvent> = None;
|
||||
|
||||
for relation in replacement_events {
|
||||
let pdu = &relation.1;
|
||||
|
||||
for pdu in replacement_events {
|
||||
// Validate replacement
|
||||
if !Self::is_valid_replacement_event(original_event, pdu).await? {
|
||||
continue;
|
||||
@@ -245,12 +219,7 @@ impl super::Service {
|
||||
/// Check if an event is itself a replacement
|
||||
#[inline]
|
||||
fn is_replacement_event(event: &PduEvent) -> bool {
|
||||
event
|
||||
.get_content_as_value()
|
||||
.get("m.relates_to")
|
||||
.and_then(|relates_to| relates_to.get("rel_type"))
|
||||
.and_then(|rel_type| rel_type.as_str())
|
||||
.is_some_and(|rel_type| rel_type == "m.replace")
|
||||
relation_type(event) == Some(RelationType::Replacement)
|
||||
}
|
||||
|
||||
/// Check if event has m.new_content or is encrypted (where m.new_content
|
||||
@@ -262,12 +231,6 @@ impl super::Service {
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper enum for partitioning relations
|
||||
enum RelationType<'a> {
|
||||
Replace(&'a PdusIterItem),
|
||||
Reference(&'a PdusIterItem),
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use conduwuit_core::pdu::{EventHash, PduEvent};
|
||||
|
||||
@@ -2,8 +2,7 @@ use std::{mem::size_of, sync::Arc};
|
||||
|
||||
use conduwuit::{
|
||||
arrayvec::ArrayVec,
|
||||
matrix::PduCount,
|
||||
result::LogErr,
|
||||
matrix::{PduCount, PduEvent},
|
||||
utils::{
|
||||
ReadyExt,
|
||||
stream::{TryIgnore, WidebandExt},
|
||||
@@ -12,14 +11,14 @@ use conduwuit::{
|
||||
};
|
||||
use database::Map;
|
||||
use futures::{Stream, StreamExt};
|
||||
use ruma::{EventId, UserId, api::Direction};
|
||||
use ruma::{EventId, RoomId, api::Direction};
|
||||
|
||||
use crate::{
|
||||
Dep,
|
||||
rooms::{
|
||||
self,
|
||||
short::{ShortEventId, ShortRoomId},
|
||||
timeline::{PduId, PdusIterItem, RawPduId},
|
||||
short::ShortRoomId,
|
||||
timeline::{PduId, RawPduId},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -27,6 +26,7 @@ pub(super) struct Data {
|
||||
tofrom_relation: Arc<Map>,
|
||||
softfailedeventids: Arc<Map>,
|
||||
rejectedeventids: Arc<Map>,
|
||||
referencedevents: Arc<Map>,
|
||||
services: Services,
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ impl Data {
|
||||
tofrom_relation: db["tofrom_relation"].clone(),
|
||||
softfailedeventids: db["softfailedeventids"].clone(),
|
||||
rejectedeventids: db["rejectedeventids"].clone(),
|
||||
referencedevents: db["referencedevents"].clone(),
|
||||
services: Services {
|
||||
timeline: args.depend::<rooms::timeline::Service>("rooms::timeline"),
|
||||
},
|
||||
@@ -54,54 +55,54 @@ impl Data {
|
||||
self.tofrom_relation.aput_raw::<BUFSIZE, _, _>(key, []);
|
||||
}
|
||||
|
||||
pub(super) fn get_relations<'a>(
|
||||
&'a self,
|
||||
user_id: &'a UserId,
|
||||
pub(super) fn get_relations(
|
||||
&self,
|
||||
shortroomid: ShortRoomId,
|
||||
target: ShortEventId,
|
||||
target: u64,
|
||||
from: PduCount,
|
||||
dir: Direction,
|
||||
) -> impl Stream<Item = PdusIterItem> + Send + 'a {
|
||||
// Query from exact position then filter excludes it (saturating_inc
|
||||
// could skip events at min/max boundaries)
|
||||
let from_unsigned = from.into_unsigned();
|
||||
let mut current = ArrayVec::<u8, 16>::new();
|
||||
current.extend(target.to_be_bytes());
|
||||
current.extend(from_unsigned.to_be_bytes());
|
||||
let current = current.as_slice();
|
||||
) -> impl Stream<Item = (u64, PduEvent)> + Send + '_ {
|
||||
self.relation_counts(target, from, dir)
|
||||
.wide_filter_map(move |count| self.get_relation_pdu(shortroomid, count))
|
||||
}
|
||||
|
||||
/// The counts of the direct relations of `target`, in the order of `dir`,
|
||||
/// starting after `from`.
|
||||
pub(super) fn relation_counts(
|
||||
&self,
|
||||
target: u64,
|
||||
from: PduCount,
|
||||
dir: Direction,
|
||||
) -> impl Stream<Item = u64> + Send + '_ {
|
||||
let start_count = match from {
|
||||
| PduCount::Normal(count) => count,
|
||||
| PduCount::Backfilled(_) => 0,
|
||||
};
|
||||
let mut start = ArrayVec::<u8, 16>::new();
|
||||
start.extend(target.to_be_bytes());
|
||||
start.extend(start_count.to_be_bytes());
|
||||
let start = start.as_slice();
|
||||
match dir {
|
||||
| Direction::Forward => self.tofrom_relation.raw_keys_from(current).boxed(),
|
||||
| Direction::Backward => self.tofrom_relation.rev_raw_keys_from(current).boxed(),
|
||||
| Direction::Forward => self.tofrom_relation.raw_keys_from(start).boxed(),
|
||||
| Direction::Backward => self.tofrom_relation.rev_raw_keys_from(start).boxed(),
|
||||
}
|
||||
.ignore_err()
|
||||
.ready_take_while(move |key| key.starts_with(&target.to_be_bytes()))
|
||||
.map(|to_from| u64_from_u8(&to_from[8..16]))
|
||||
.map(PduCount::from_unsigned)
|
||||
.ready_filter(move |count| {
|
||||
if from == PduCount::min() || from == PduCount::max() {
|
||||
true
|
||||
} else {
|
||||
let count_unsigned = count.into_unsigned();
|
||||
match dir {
|
||||
| Direction::Forward => count_unsigned > from_unsigned,
|
||||
| Direction::Backward => count_unsigned < from_unsigned,
|
||||
}
|
||||
}
|
||||
})
|
||||
.wide_filter_map(move |shorteventid| async move {
|
||||
let pdu_id: RawPduId = PduId { shortroomid, shorteventid }.into();
|
||||
// The scan includes `from` itself, which should be skipped
|
||||
.ready_filter(move |&count| PduCount::Normal(count).is_after(from, dir))
|
||||
}
|
||||
|
||||
let mut pdu = self.services.timeline.get_pdu_from_id(&pdu_id).await.ok()?;
|
||||
pub(super) async fn get_relation_pdu(
|
||||
&self,
|
||||
shortroomid: ShortRoomId,
|
||||
count: u64,
|
||||
) -> Option<(u64, PduEvent)> {
|
||||
let shorteventid = PduCount::Normal(count);
|
||||
let pdu_id: RawPduId = PduId { shortroomid, shorteventid }.into();
|
||||
let pdu = self.services.timeline.get_pdu_from_id(&pdu_id).await.ok()?;
|
||||
|
||||
let ctx = self
|
||||
.services
|
||||
.timeline
|
||||
.get_unsigned_context(&pdu, Some(user_id))
|
||||
.await;
|
||||
pdu.set_unsigned(Some(ctx)).log_err().ok();
|
||||
|
||||
Some((shorteventid, pdu))
|
||||
})
|
||||
Some((count, pdu))
|
||||
}
|
||||
|
||||
pub(super) fn mark_event_soft_failed(&self, event_id: &EventId) {
|
||||
@@ -133,4 +134,16 @@ impl Data {
|
||||
self.unmark_event_rejected(event_id);
|
||||
self.unmark_event_soft_failed(event_id);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(super) fn mark_as_referenced(&self, room_id: &RoomId, event_id: &EventId) {
|
||||
let key = (room_id, event_id);
|
||||
self.referencedevents.put_raw(key, []);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(super) async fn is_event_referenced(&self, room_id: &RoomId, event_id: &EventId) -> bool {
|
||||
let key = (room_id, event_id);
|
||||
self.referencedevents.qry(&key).await.is_ok()
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,20 @@
|
||||
mod bundled_aggregations;
|
||||
mod data;
|
||||
use std::sync::Arc;
|
||||
use std::{collections::HashSet, sync::Arc};
|
||||
|
||||
use conduwuit::{Result, matrix::PduCount};
|
||||
use futures::{StreamExt, future::try_join};
|
||||
use conduwuit::{
|
||||
Result,
|
||||
matrix::{PduCount, PduEvent},
|
||||
result::LogErr,
|
||||
utils::{IterStream, ReadyExt, stream::WidebandExt},
|
||||
};
|
||||
use futures::{Stream, StreamExt, future::try_join};
|
||||
use ruma::{EventId, RoomId, UserId, api::Direction};
|
||||
|
||||
use self::data::Data;
|
||||
use crate::{
|
||||
Dep,
|
||||
rooms::{self, timeline::PdusIterItem},
|
||||
rooms::{self, short::ShortRoomId, timeline::PdusIterItem},
|
||||
};
|
||||
|
||||
pub struct Service {
|
||||
@@ -51,7 +56,7 @@ impl Service {
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn get_relations<'a>(
|
||||
pub async fn get_relations<'a, F>(
|
||||
&'a self,
|
||||
user_id: &'a UserId,
|
||||
room_id: &'a RoomId,
|
||||
@@ -60,59 +65,130 @@ impl Service {
|
||||
limit: usize,
|
||||
max_depth: u8,
|
||||
dir: Direction,
|
||||
) -> Vec<PdusIterItem> {
|
||||
let room_id = self.services.short.get_shortroomid(room_id);
|
||||
|
||||
let target = self.services.timeline.get_pdu_count(target);
|
||||
|
||||
let Ok((room_id, target)) = try_join(room_id, target).await else {
|
||||
matches: F,
|
||||
) -> Vec<PdusIterItem>
|
||||
where
|
||||
F: Fn(&PduEvent) -> bool + Send + Sync,
|
||||
{
|
||||
let Some((room_id, target)) = self.relation_target(room_id, target).await else {
|
||||
return Vec::new();
|
||||
};
|
||||
|
||||
let target = match target {
|
||||
| PduCount::Normal(c) => c,
|
||||
// TODO: Support backfilled relations
|
||||
| _ => 0, // This will result in an empty iterator
|
||||
// Direct relations are already in order
|
||||
if max_depth == 0 {
|
||||
let counts = self.db.relation_counts(target, from, dir);
|
||||
return self
|
||||
.load_relations(user_id, room_id, counts, limit, &matches)
|
||||
.await;
|
||||
}
|
||||
|
||||
let scan_from = match dir {
|
||||
| Direction::Forward => PduCount::min(),
|
||||
| Direction::Backward => from,
|
||||
};
|
||||
|
||||
let mut pdus: Vec<_> = self
|
||||
// An event can relate to two others in the tree, like a thread reply
|
||||
// that also replies to another reply in the thread, so it's only kept
|
||||
// and looked through the first time it's found
|
||||
let mut seen = HashSet::new();
|
||||
let mut counts = Vec::new();
|
||||
let mut level: Vec<_> = self
|
||||
.db
|
||||
.get_relations(user_id, room_id, target, from, dir)
|
||||
.relation_counts(target, scan_from, dir)
|
||||
.collect()
|
||||
.await;
|
||||
seen.extend(level.iter().copied());
|
||||
for _ in 0..max_depth {
|
||||
if level.is_empty() {
|
||||
break;
|
||||
}
|
||||
|
||||
let mut stack: Vec<_> = pdus
|
||||
.iter()
|
||||
.filter(|_| max_depth > 0)
|
||||
.map(|pdu| (pdu.clone(), 1))
|
||||
.collect();
|
||||
|
||||
'limit: while let Some(stack_pdu) = stack.pop() {
|
||||
let target = match stack_pdu.0.0 {
|
||||
| PduCount::Normal(c) => c,
|
||||
// TODO: Support backfilled relations
|
||||
| PduCount::Backfilled(_) => 0, // This will result in an empty iterator
|
||||
};
|
||||
|
||||
let relations: Vec<_> = self
|
||||
.db
|
||||
.get_relations(user_id, room_id, target, from, dir)
|
||||
let next: Vec<Vec<_>> = level
|
||||
.iter()
|
||||
.copied()
|
||||
.stream()
|
||||
.wide_then(|target| {
|
||||
self.db
|
||||
.relation_counts(target, scan_from, dir)
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
.collect()
|
||||
.await;
|
||||
|
||||
for relation in relations {
|
||||
if stack_pdu.1 < max_depth {
|
||||
stack.push((relation.clone(), stack_pdu.1.saturating_add(1)));
|
||||
}
|
||||
|
||||
pdus.push(relation);
|
||||
if pdus.len() >= limit {
|
||||
break 'limit;
|
||||
}
|
||||
}
|
||||
counts.append(&mut level);
|
||||
level = next
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.filter(|&count| seen.insert(count))
|
||||
.collect();
|
||||
}
|
||||
counts.append(&mut level);
|
||||
|
||||
pdus
|
||||
counts.retain(|&count| PduCount::Normal(count).is_after(from, dir));
|
||||
counts.sort_unstable_by(|a, b| match dir {
|
||||
| Direction::Forward => a.cmp(b),
|
||||
| Direction::Backward => b.cmp(a),
|
||||
});
|
||||
|
||||
self.load_relations(user_id, room_id, counts.into_iter().stream(), limit, &matches)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Loads the pdus of relations in the order of `counts`
|
||||
async fn load_relations<S, F>(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
room_id: ShortRoomId,
|
||||
counts: S,
|
||||
limit: usize,
|
||||
matches: &F,
|
||||
) -> Vec<PdusIterItem>
|
||||
where
|
||||
S: Stream<Item = u64> + Send,
|
||||
F: Fn(&PduEvent) -> bool + Send + Sync,
|
||||
{
|
||||
counts
|
||||
.wide_filter_map(|count| self.db.get_relation_pdu(room_id, count))
|
||||
.ready_filter(|(_, pdu)| matches(pdu))
|
||||
.take(limit)
|
||||
.wide_then(|relation| self.finish_relation(user_id, relation))
|
||||
.collect()
|
||||
.await
|
||||
}
|
||||
|
||||
/// The short room ID and count of `target`
|
||||
async fn relation_target(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
target: &EventId,
|
||||
) -> Option<(ShortRoomId, u64)> {
|
||||
let room_id = self.services.short.get_shortroomid(room_id);
|
||||
let target = self.services.timeline.get_pdu_count(target);
|
||||
|
||||
match try_join(room_id, target).await {
|
||||
| Ok((room_id, PduCount::Normal(target))) => Some((room_id, target)),
|
||||
// TODO: Support backfilled relations
|
||||
| _ => None,
|
||||
}
|
||||
}
|
||||
|
||||
async fn finish_relation(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
(count, pdu): (u64, PduEvent),
|
||||
) -> PdusIterItem {
|
||||
(PduCount::Normal(count), self.with_unsigned(user_id, pdu).await)
|
||||
}
|
||||
|
||||
async fn with_unsigned(&self, user_id: &UserId, mut pdu: PduEvent) -> PduEvent {
|
||||
let ctx = self
|
||||
.services
|
||||
.timeline
|
||||
.get_unsigned_context(&pdu, Some(user_id))
|
||||
.await;
|
||||
pdu.set_unsigned(Some(ctx)).log_err().ok();
|
||||
|
||||
pdu
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -131,6 +207,14 @@ impl Service {
|
||||
self.db.is_event_rejected(event_id).await
|
||||
}
|
||||
|
||||
pub async fn is_event_referenced(&self, room_id: &RoomId, event_id: &EventId) -> bool {
|
||||
self.db.is_event_referenced(room_id, event_id).await
|
||||
}
|
||||
|
||||
pub fn mark_as_referenced(&self, room_id: &RoomId, event_id: &EventId) {
|
||||
self.db.mark_as_referenced(room_id, event_id);
|
||||
}
|
||||
|
||||
pub fn mark_event_rejected(&self, event_id: &EventId) {
|
||||
self.db.mark_event_rejected(event_id);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,10 @@ use database::{Deserialized, Json, Map};
|
||||
use futures::{Stream, StreamExt};
|
||||
use ruma::{
|
||||
CanonicalJsonObject, OwnedRoomId, OwnedUserId, RoomId, UserId,
|
||||
events::{AnySyncEphemeralRoomEvent, receipt::ReceiptEvent},
|
||||
events::{
|
||||
AnySyncEphemeralRoomEvent,
|
||||
receipt::{ReceiptEvent, ReceiptType},
|
||||
},
|
||||
serde::Raw,
|
||||
};
|
||||
|
||||
@@ -45,20 +48,57 @@ impl Data {
|
||||
user_id: &UserId,
|
||||
room_id: &RoomId,
|
||||
event: &ReceiptEvent,
|
||||
) {
|
||||
// Remove old entry
|
||||
) -> bool {
|
||||
let Some((new_event, new_receipt)) =
|
||||
event.content.user_receipt(user_id, ReceiptType::Read)
|
||||
else {
|
||||
return false;
|
||||
};
|
||||
|
||||
// Find old entries for this user in this room
|
||||
let last_possible_key = (room_id, u64::MAX);
|
||||
let mut old_entries = Vec::new();
|
||||
self.readreceiptid_readreceipt
|
||||
.rev_keys_from_raw(&last_possible_key)
|
||||
.rev_stream_from_raw(&last_possible_key)
|
||||
.ignore_err()
|
||||
.ready_take_while(|key| key.starts_with(room_id.as_bytes()))
|
||||
.ready_filter_map(|key| key.ends_with(user_id.as_bytes()).then_some(key))
|
||||
.ready_for_each(|key| self.readreceiptid_readreceipt.del(key))
|
||||
.ready_take_while(|(key, _)| key.starts_with(room_id.as_bytes()))
|
||||
.ready_filter_map(|(key, val)| {
|
||||
key.ends_with(user_id.as_bytes())
|
||||
.then(|| (key.to_vec(), serde_json::from_slice::<ReceiptEvent>(val).ok()))
|
||||
})
|
||||
.ready_for_each(|entry| old_entries.push(entry))
|
||||
.await;
|
||||
|
||||
let mut to_del = Vec::new();
|
||||
|
||||
for (key, existing) in old_entries {
|
||||
let Some(existing) = existing else {
|
||||
to_del.push(key);
|
||||
continue;
|
||||
};
|
||||
let Some((old_event, old_receipt)) =
|
||||
existing.content.user_receipt(user_id, ReceiptType::Read)
|
||||
else {
|
||||
to_del.push(key);
|
||||
continue;
|
||||
};
|
||||
|
||||
if old_receipt.thread == new_receipt.thread {
|
||||
if old_event == new_event {
|
||||
return false;
|
||||
}
|
||||
to_del.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
for key in to_del {
|
||||
self.readreceiptid_readreceipt.del(&key);
|
||||
}
|
||||
|
||||
let count = self.services.globals.next_count().unwrap();
|
||||
let latest_id = (room_id, count, user_id);
|
||||
self.readreceiptid_readreceipt.put(latest_id, Json(event));
|
||||
true
|
||||
}
|
||||
|
||||
pub(super) fn readreceipts_since<'a>(
|
||||
@@ -86,12 +126,28 @@ impl Data {
|
||||
.ignore_err()
|
||||
}
|
||||
|
||||
pub(super) fn private_read_set(&self, room_id: &RoomId, user_id: &UserId, pdu_count: u64) {
|
||||
pub(super) async fn private_read_set(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
user_id: &UserId,
|
||||
pdu_count: u64,
|
||||
) -> bool {
|
||||
let key = (room_id, user_id);
|
||||
let next_count = self.services.globals.next_count().unwrap();
|
||||
if let Ok(current) = self
|
||||
.roomuserid_privateread
|
||||
.qry(&key)
|
||||
.await
|
||||
.deserialized::<u64>()
|
||||
{
|
||||
if current == pdu_count {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
let next_count = self.services.globals.next_count().unwrap();
|
||||
self.roomuserid_privateread.put(key, pdu_count);
|
||||
self.roomuserid_lastprivatereadupdate.put(key, next_count);
|
||||
true
|
||||
}
|
||||
|
||||
pub(super) async fn private_read_get_count(
|
||||
|
||||
@@ -65,7 +65,10 @@ impl Service {
|
||||
room_id: &RoomId,
|
||||
event: ReceiptEvent,
|
||||
) {
|
||||
self.db.readreceipt_update(user_id, room_id, &event).await;
|
||||
if !self.db.readreceipt_update(user_id, room_id, &event).await {
|
||||
return;
|
||||
}
|
||||
|
||||
self.services.sync.wake_all_joined(room_id).await;
|
||||
// update appservices
|
||||
let edu = EphemeralData::Receipt(event);
|
||||
@@ -93,7 +96,7 @@ impl Service {
|
||||
});
|
||||
|
||||
let (pdu_count, shortroomid) = try_join!(pdu_count, shortroomid)?;
|
||||
let shorteventid = PduCount::Normal(pdu_count);
|
||||
let shorteventid = PduCount::from_unsigned(pdu_count);
|
||||
let pdu_id: RawPduId = PduId { shortroomid, shorteventid }.into();
|
||||
let pdu = self.services.timeline.get_pdu_from_id(&pdu_id).await?;
|
||||
|
||||
@@ -101,8 +104,7 @@ impl Service {
|
||||
let user_id: OwnedUserId = user_id.to_owned();
|
||||
|
||||
let mut receipt = ruma::events::receipt::Receipt::default();
|
||||
// TODO: start storing the timestamp so we can return one
|
||||
receipt.ts = None;
|
||||
receipt.ts = Some(pdu.origin_server_ts());
|
||||
receipt.thread = ruma::events::receipt::ReceiptThread::Unthreaded;
|
||||
|
||||
let content: BTreeMap<OwnedEventId, Receipts> = BTreeMap::from_iter([(
|
||||
@@ -143,7 +145,9 @@ impl Service {
|
||||
event_id: &EventId,
|
||||
count: u64,
|
||||
) {
|
||||
self.db.private_read_set(room_id, user_id, count);
|
||||
if !self.db.private_read_set(room_id, user_id, count).await {
|
||||
return;
|
||||
}
|
||||
|
||||
// update appservices matching the user's namespace (MSC2409)
|
||||
let receipt_content = [(
|
||||
@@ -267,4 +271,54 @@ mod tests {
|
||||
assert!(users.contains_key(user_id!("@alice:example.org")));
|
||||
assert!(users.contains_key(user_id!("@bob:example.org")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pack_receipts_merges_threaded_and_private_receipts() {
|
||||
let event_a: OwnedEventId = "$event_a:example.org".try_into().expect("valid event ID");
|
||||
let event_b: OwnedEventId = "$event_b:example.org".try_into().expect("valid event ID");
|
||||
|
||||
let mut public_threaded_receipt = Receipt::default();
|
||||
public_threaded_receipt.thread = ruma::events::receipt::ReceiptThread::Main;
|
||||
|
||||
let r1_content = ReceiptEventContent::from_iter([(
|
||||
event_a.clone(),
|
||||
BTreeMap::from([(
|
||||
ReceiptType::Read,
|
||||
BTreeMap::from([(
|
||||
user_id!("@alice:example.org").to_owned(),
|
||||
public_threaded_receipt,
|
||||
)]),
|
||||
)]),
|
||||
)]);
|
||||
let r1: Raw<AnySyncEphemeralRoomEvent> = Raw::from_json(
|
||||
serde_json::value::to_raw_value(&SyncEphemeralRoomEvent::new(r1_content)).unwrap(),
|
||||
);
|
||||
|
||||
let mut private_receipt = Receipt::default();
|
||||
private_receipt.thread = ruma::events::receipt::ReceiptThread::Unthreaded;
|
||||
let r2_content = ReceiptEventContent::from_iter([(
|
||||
event_b.clone(),
|
||||
BTreeMap::from([(
|
||||
ReceiptType::ReadPrivate,
|
||||
BTreeMap::from([(user_id!("@alice:example.org").to_owned(), private_receipt)]),
|
||||
)]),
|
||||
)]);
|
||||
let r2: Raw<AnySyncEphemeralRoomEvent> = Raw::from_json(
|
||||
serde_json::value::to_raw_value(&SyncEphemeralRoomEvent::new(r2_content)).unwrap(),
|
||||
);
|
||||
|
||||
let packed = pack_receipts([r1, r2].into_iter());
|
||||
let packed: SyncEphemeralRoomEvent<ReceiptEventContent> =
|
||||
serde_json::from_str(packed.json().get()).expect("packed receipt is valid");
|
||||
|
||||
assert_eq!(
|
||||
packed.content[&event_a][&ReceiptType::Read][user_id!("@alice:example.org")].thread,
|
||||
ruma::events::receipt::ReceiptThread::Main
|
||||
);
|
||||
assert_eq!(
|
||||
packed.content[&event_b][&ReceiptType::ReadPrivate][user_id!("@alice:example.org")]
|
||||
.thread,
|
||||
ruma::events::receipt::ReceiptThread::Unthreaded
|
||||
);
|
||||
}
|
||||
}
|
||||
Loaded 100 of 110 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user