mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-26 18:37:35 +00:00
Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e06b8ae11 | ||
|
|
5773914c9d | ||
|
|
4ac23d8649 | ||
|
|
0e5c7cc640 | ||
|
|
7577c9f001 | ||
|
|
bdc06d8135 | ||
|
|
9bc58d34bf | ||
|
|
06a2e73e8a | ||
|
|
693f80eeb2 | ||
|
|
1666993187 | ||
|
|
dbcc0e0d31 | ||
|
|
a535604a27 | ||
|
|
2f82475811 | ||
|
|
b651fbd088 | ||
|
|
5de3d74436 | ||
|
|
4f128af921 | ||
|
|
a748115ab5 | ||
|
|
84d4c1c19e | ||
|
|
7871ce9190 |
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@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4
|
||||
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # 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@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4
|
||||
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # 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@b5ae5b4541ed5fb0f616e3cb616bf213fefa1c40 # v1
|
||||
uses: https://git.tomfos.tr/tom/sccache-action@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@d39555789fed25b8eb8e086d9f199c514dfa311e # v1
|
||||
uses: https://git.tomfos.tr/actions/detect-versions@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@d39555789fed25b8eb8e086d9f199c514dfa311e # v1
|
||||
uses: https://git.tomfos.tr/actions/detect-versions@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@b5ae5b4541ed5fb0f616e3cb616bf213fefa1c40 # v1
|
||||
uses: https://git.tomfos.tr/tom/sccache-action@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@cfdb7ed4ccc7c7dce37759eae89dc5674b469b39 # v2
|
||||
uses: https://github.com/taiki-e/install-action@5488ac5a951645ce95062214902ac4b6bc1a1037 # v2
|
||||
with:
|
||||
tool: git-warp-time,timelord-cli@3.0.1
|
||||
|
||||
|
||||
@@ -4,6 +4,11 @@ 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@b5ae5b4541ed5fb0f616e3cb616bf213fefa1c40 # v1
|
||||
uses: https://git.tomfos.tr/tom/sccache-action@v1
|
||||
|
||||
- name: Configure sccache environment
|
||||
run: |
|
||||
|
||||
@@ -54,6 +54,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- build
|
||||
permissions:
|
||||
contents: write
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
steps:
|
||||
- name: Download binary artifacts
|
||||
@@ -63,7 +65,7 @@ jobs:
|
||||
path: binaries
|
||||
merge-multiple: true
|
||||
- name: Create Release and Upload
|
||||
uses: https://github.com/softprops/action-gh-release@8a0cd651e5b2365bd640854a3fa5dfc70e4875f3 # v3
|
||||
uses: https://github.com/softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3
|
||||
with:
|
||||
draft: true
|
||||
files: binaries/*
|
||||
@@ -4,6 +4,11 @@ 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@d39555789fed25b8eb8e086d9f199c514dfa311e # v1
|
||||
uses: https://git.tomfos.tr/actions/detect-versions@v1
|
||||
|
||||
- name: Setup Node.js
|
||||
if: steps.runner-env.outputs.node_major == '' || steps.runner-env.outputs.node_major < '20'
|
||||
|
||||
@@ -7,6 +7,10 @@ on:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
|
||||
jobs:
|
||||
fast-checks:
|
||||
name: Pre-commit & Formatting
|
||||
|
||||
@@ -31,6 +31,11 @@ jobs:
|
||||
build-release:
|
||||
name: "Build ${{ matrix.slug }} (release)"
|
||||
runs-on: dind
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
attestations: write
|
||||
id-token: write
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
@@ -79,7 +84,6 @@ 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
|
||||
@@ -113,6 +117,11 @@ 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:
|
||||
@@ -163,7 +172,6 @@ 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
|
||||
@@ -199,6 +207,8 @@ jobs:
|
||||
needs:
|
||||
- build-release
|
||||
- build-maxperf
|
||||
permissions:
|
||||
contents: write
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
steps:
|
||||
- name: Download binary artifacts
|
||||
@@ -208,7 +218,7 @@ jobs:
|
||||
path: binaries
|
||||
merge-multiple: true
|
||||
- name: Create Release and Upload
|
||||
uses: https://github.com/softprops/action-gh-release@8a0cd651e5b2365bd640854a3fa5dfc70e4875f3 # v3
|
||||
uses: https://github.com/softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3
|
||||
with:
|
||||
draft: true
|
||||
files: binaries/*
|
||||
|
||||
@@ -43,7 +43,7 @@ jobs:
|
||||
name: Renovate
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ghcr.io/renovatebot/renovate:44.210.1@sha256:45cc73346c44a9afe037f2d19766f2b545b59b2ed31b937b5b09017d2958e45f
|
||||
image: ghcr.io/renovatebot/renovate:44.190.1@sha256:1b1306e7f1f0bafc56f6c471b6c309760ab990e9a60901623bcd14016717a528
|
||||
options: --tmpfs /tmp:exec
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
||||
@@ -32,7 +32,7 @@ repos:
|
||||
stages: [ commit-msg ]
|
||||
|
||||
- repo: https://github.com/crate-ci/committed
|
||||
rev: v1.1.12
|
||||
rev: v1.1.11
|
||||
hooks:
|
||||
- id: committed
|
||||
|
||||
|
||||
Generated
+571
-584
File diff suppressed because it is too large.
Load diff
+66
-80
@@ -18,11 +18,11 @@ version = "26.9.1"
|
||||
name = "conduwuit"
|
||||
|
||||
[workspace.dependencies.arrayvec]
|
||||
version = "0.7.8"
|
||||
version = "0.7.6"
|
||||
features = ["serde"]
|
||||
|
||||
[workspace.dependencies.smallvec]
|
||||
version = "1.16.5"
|
||||
version = "1.14.0"
|
||||
features = [
|
||||
"const_generics",
|
||||
"const_new",
|
||||
@@ -39,10 +39,10 @@ features = ["ffi", "std", "union"]
|
||||
version = "1.1.0"
|
||||
|
||||
[workspace.dependencies.ctor]
|
||||
version = "1.0.13"
|
||||
version = "1.0.6"
|
||||
|
||||
[workspace.dependencies.dtor]
|
||||
version = "1.0.6"
|
||||
version = "1.0.0"
|
||||
|
||||
[workspace.dependencies.cargo_toml]
|
||||
version = "1.0"
|
||||
@@ -50,7 +50,7 @@ default-features = false
|
||||
features = ["features"]
|
||||
|
||||
[workspace.dependencies.toml]
|
||||
version = "1.2.1"
|
||||
version = "1.1.2"
|
||||
default-features = false
|
||||
features = ["parse", "serde"]
|
||||
|
||||
@@ -58,7 +58,7 @@ features = ["parse", "serde"]
|
||||
version = "0.6.0"
|
||||
|
||||
[workspace.dependencies.base64]
|
||||
version = "0.23.1"
|
||||
version = "0.23.0"
|
||||
default-features = false
|
||||
|
||||
# used for TURN server authentication
|
||||
@@ -71,40 +71,39 @@ version = "0.5.0"
|
||||
default-features = false
|
||||
|
||||
[workspace.dependencies.p256]
|
||||
version = "0.14.0"
|
||||
version = "0.13.2"
|
||||
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.11"
|
||||
version = "0.2.0"
|
||||
|
||||
[workspace.dependencies.rand]
|
||||
version = "0.10.3"
|
||||
version = "0.10.1"
|
||||
|
||||
# Used for the http request / response body type for Ruma endpoints used with reqwest
|
||||
[workspace.dependencies.bytes]
|
||||
version = "1.12.1"
|
||||
version = "1.10.1"
|
||||
|
||||
[workspace.dependencies.http-body-util]
|
||||
version = "0.1.5"
|
||||
version = "0.1.3"
|
||||
|
||||
[workspace.dependencies.http]
|
||||
version = "1.5.0"
|
||||
version = "1.3.1"
|
||||
|
||||
# parses the HTTP-date form of Retry-After
|
||||
[workspace.dependencies.httpdate]
|
||||
version = "1.0.3"
|
||||
|
||||
[workspace.dependencies.regex]
|
||||
version = "1.13.1"
|
||||
version = "1.11.1"
|
||||
|
||||
[workspace.dependencies.axum]
|
||||
version = "0.8.9"
|
||||
version = "0.8.8"
|
||||
default-features = false
|
||||
features = [
|
||||
"form",
|
||||
"query",
|
||||
"http1",
|
||||
"http2",
|
||||
"json",
|
||||
@@ -114,7 +113,7 @@ features = [
|
||||
]
|
||||
|
||||
[workspace.dependencies.axum-extra]
|
||||
version = "0.12.6"
|
||||
version = "0.12.0"
|
||||
default-features = false
|
||||
features = ["typed-header", "tracing", "cookie"]
|
||||
|
||||
@@ -133,12 +132,12 @@ default-features = false
|
||||
version = "0.2"
|
||||
|
||||
[workspace.dependencies.tower]
|
||||
version = "0.5.3"
|
||||
version = "0.5.2"
|
||||
default-features = false
|
||||
features = ["util"]
|
||||
|
||||
[workspace.dependencies.tower-http]
|
||||
version = "0.7.1"
|
||||
version = "0.7.0"
|
||||
default-features = false
|
||||
features = [
|
||||
"add-extension",
|
||||
@@ -152,46 +151,38 @@ features = [
|
||||
]
|
||||
|
||||
[workspace.dependencies.rustls]
|
||||
version = "0.23.46"
|
||||
version = "0.23.25"
|
||||
default-features = false
|
||||
|
||||
[workspace.dependencies.reqwest]
|
||||
version = "0.13.5"
|
||||
version = "0.13.2"
|
||||
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.229"
|
||||
version = "1.0.219"
|
||||
default-features = false
|
||||
features = ["rc"]
|
||||
|
||||
[workspace.dependencies.serde_json]
|
||||
version = "1.0.154"
|
||||
version = "1.0.140"
|
||||
default-features = false
|
||||
features = ["raw_value"]
|
||||
|
||||
# Used for appservice registration files
|
||||
[workspace.dependencies.serde-saphyr]
|
||||
version = "2.1.1"
|
||||
version = "1.0.0"
|
||||
|
||||
# Used to load forbidden room/user regex from config
|
||||
[workspace.dependencies.serde_regex]
|
||||
version = "1.2.0"
|
||||
version = "1.1.0"
|
||||
|
||||
# Used for password hashing
|
||||
[workspace.dependencies.argon2]
|
||||
@@ -201,7 +192,7 @@ default-features = false
|
||||
|
||||
# Used to generate thumbnails for images
|
||||
[workspace.dependencies.image]
|
||||
version = "0.25.10"
|
||||
version = "0.25.5"
|
||||
default-features = false
|
||||
features = [
|
||||
"jpeg",
|
||||
@@ -212,29 +203,29 @@ features = [
|
||||
|
||||
# logging
|
||||
[workspace.dependencies.log]
|
||||
version = "0.4.35"
|
||||
version = "0.4.27"
|
||||
default-features = false
|
||||
[workspace.dependencies.tracing]
|
||||
version = "0.1.44"
|
||||
version = "0.1.41"
|
||||
default-features = false
|
||||
[workspace.dependencies.tracing-subscriber]
|
||||
version = "0.3.23"
|
||||
version = "0.3.20"
|
||||
default-features = false
|
||||
features = ["env-filter", "std", "tracing", "tracing-log", "ansi", "fmt"]
|
||||
[workspace.dependencies.tracing-journald]
|
||||
version = "0.3.2"
|
||||
version = "0.3.1"
|
||||
[workspace.dependencies.tracing-core]
|
||||
version = "0.1.36"
|
||||
version = "0.1.34"
|
||||
default-features = false
|
||||
|
||||
# for URL previews
|
||||
[workspace.dependencies.webpage]
|
||||
version = "2.1.0"
|
||||
version = "2.0.1"
|
||||
default-features = false
|
||||
|
||||
# used for conduwuit's CLI and admin room command parsing
|
||||
[workspace.dependencies.clap]
|
||||
version = "4.6.7"
|
||||
version = "4.5.35"
|
||||
default-features = false
|
||||
features = [
|
||||
"derive",
|
||||
@@ -247,12 +238,12 @@ features = [
|
||||
]
|
||||
|
||||
[workspace.dependencies.futures]
|
||||
version = "0.3.34"
|
||||
version = "0.3.31"
|
||||
default-features = false
|
||||
features = ["std", "async-await"]
|
||||
|
||||
[workspace.dependencies.tokio]
|
||||
version = "1.54.1"
|
||||
version = "1.44.2"
|
||||
default-features = false
|
||||
features = [
|
||||
"fs",
|
||||
@@ -267,25 +258,25 @@ features = [
|
||||
]
|
||||
|
||||
[workspace.dependencies.tokio-metrics]
|
||||
version = "0.5.2"
|
||||
version = "0.5.0"
|
||||
|
||||
[workspace.dependencies.libloading]
|
||||
version = "0.9.0"
|
||||
|
||||
# Validating urls in config, was already a transitive dependency
|
||||
[workspace.dependencies.url]
|
||||
version = "2.5.8"
|
||||
version = "2.5.4"
|
||||
default-features = false
|
||||
features = ["serde"]
|
||||
|
||||
# standard date and time tools
|
||||
[workspace.dependencies.chrono]
|
||||
version = "0.4.45"
|
||||
version = "0.4.38"
|
||||
features = ["alloc", "std"]
|
||||
default-features = false
|
||||
|
||||
[workspace.dependencies.hyper]
|
||||
version = "1.12.0"
|
||||
version = "1.6.0"
|
||||
default-features = false
|
||||
features = [
|
||||
"server",
|
||||
@@ -304,7 +295,7 @@ features = [
|
||||
|
||||
# to support multiple variations of setting a config option
|
||||
[workspace.dependencies.either]
|
||||
version = "1.19.0"
|
||||
version = "1.15.0"
|
||||
default-features = false
|
||||
features = ["serde"]
|
||||
|
||||
@@ -315,7 +306,7 @@ default-features = false
|
||||
features = ["env", "toml"]
|
||||
|
||||
[workspace.dependencies.hickory-resolver]
|
||||
version = "0.26.3"
|
||||
version = "0.26.0"
|
||||
default-features = false
|
||||
features = [
|
||||
"serde",
|
||||
@@ -325,7 +316,7 @@ features = [
|
||||
|
||||
# Used for conduwuit::Error type
|
||||
[workspace.dependencies.thiserror]
|
||||
version = "2.0.21"
|
||||
version = "2.0.12"
|
||||
default-features = false
|
||||
|
||||
# Used to make working with iterators easier, was already a transitive depdendency
|
||||
@@ -346,7 +337,7 @@ version = "0.6.0"
|
||||
version = "2.5.0"
|
||||
|
||||
[workspace.dependencies.async-trait]
|
||||
version = "0.1.92"
|
||||
version = "0.1.88"
|
||||
|
||||
[workspace.dependencies.lru-cache]
|
||||
version = "0.1.2"
|
||||
@@ -357,7 +348,7 @@ version = "1.1.1"
|
||||
# Used for matrix spec type definitions and helpers
|
||||
[workspace.dependencies.ruma]
|
||||
git = "https://github.com/ruma/ruma.git"
|
||||
rev = "0ed7fba34213f18a628a56f527c6cc795cd7eef5"
|
||||
rev = "e03080c0790ba7b24ea37f9fd11794678cc975b0"
|
||||
features = [
|
||||
"appservice-api-c",
|
||||
"client-api",
|
||||
@@ -403,7 +394,7 @@ features = [
|
||||
|
||||
[workspace.dependencies.rust-rocksdb]
|
||||
git = "https://forgejo.ellis.link/continuwuation/rust-rocksdb-zaidoon1"
|
||||
rev = "6021299f3e0e9455dc3f2e39c65e1dc217be8903"
|
||||
rev = "0a25ff92f7c09b55eec496b9c192c7d5136ab2b8"
|
||||
default-features = false
|
||||
features = [
|
||||
"multi-threaded-cf",
|
||||
@@ -414,7 +405,7 @@ features = [
|
||||
]
|
||||
|
||||
[workspace.dependencies.sha2]
|
||||
version = "0.11.1"
|
||||
version = "0.11.0"
|
||||
default-features = false
|
||||
|
||||
[workspace.dependencies.sha1]
|
||||
@@ -422,13 +413,11 @@ version = "0.11.0"
|
||||
default-features = false
|
||||
|
||||
[workspace.dependencies.openidconnect]
|
||||
version = "4.1.0"
|
||||
default-features = false
|
||||
features = ["reqwest"]
|
||||
version = "4.0.1"
|
||||
|
||||
# optional opentelemetry, performance measurements, flamegraphs, etc for performance measurements and monitoring
|
||||
[workspace.dependencies.opentelemetry]
|
||||
version = "0.33.1"
|
||||
version = "0.33.0"
|
||||
|
||||
[workspace.dependencies.opentelemetry-instrumentation-tower]
|
||||
version = "0.19.0"
|
||||
@@ -436,7 +425,7 @@ default-features = false
|
||||
features = ["axum"]
|
||||
|
||||
[workspace.dependencies.opentelemetry-semantic-conventions]
|
||||
version = "0.33.1"
|
||||
version = "0.33.0"
|
||||
features = ["semconv_experimental"]
|
||||
|
||||
[workspace.dependencies.tracing-flame]
|
||||
@@ -446,25 +435,25 @@ version = "0.2.0"
|
||||
version = "0.34.0"
|
||||
|
||||
[workspace.dependencies.opentelemetry_sdk]
|
||||
version = "0.33.1"
|
||||
version = "0.33.0"
|
||||
features = ["rt-tokio"]
|
||||
|
||||
[workspace.dependencies.opentelemetry-prometheus]
|
||||
version = "0.33.1"
|
||||
version = "0.33.0"
|
||||
|
||||
[workspace.dependencies.prometheus]
|
||||
version = "0.14.0"
|
||||
default-features = false
|
||||
|
||||
[workspace.dependencies.opentelemetry-otlp]
|
||||
version = "0.33.1"
|
||||
version = "0.33.0"
|
||||
features = ["http", "grpc-tonic", "trace", "logs", "metrics"]
|
||||
|
||||
|
||||
|
||||
# optional sentry metrics for crash/panic reporting
|
||||
[workspace.dependencies.sentry]
|
||||
version = "0.49.5"
|
||||
version = "0.49.0"
|
||||
default-features = false
|
||||
features = [
|
||||
"backtrace",
|
||||
@@ -479,14 +468,14 @@ features = [
|
||||
]
|
||||
|
||||
[workspace.dependencies.sentry-tracing]
|
||||
version = "0.49.5"
|
||||
version = "0.49.0"
|
||||
[workspace.dependencies.sentry-tower]
|
||||
version = "0.49.5"
|
||||
version = "0.49.0"
|
||||
|
||||
# jemalloc usage
|
||||
[workspace.dependencies.tikv-jemalloc-sys]
|
||||
git = "https://forgejo.ellis.link/continuwuation/jemallocator"
|
||||
rev = "ac4d4861b335b199f812807996e8c9166961041a"
|
||||
rev = "df86ff89d4b1e223b9f7d2dd2fbb7f202da7f554"
|
||||
default-features = false
|
||||
features = [
|
||||
"background_threads_runtime_support",
|
||||
@@ -494,7 +483,7 @@ features = [
|
||||
]
|
||||
[workspace.dependencies.tikv-jemallocator]
|
||||
git = "https://forgejo.ellis.link/continuwuation/jemallocator"
|
||||
rev = "ac4d4861b335b199f812807996e8c9166961041a"
|
||||
rev = "df86ff89d4b1e223b9f7d2dd2fbb7f202da7f554"
|
||||
default-features = false
|
||||
features = [
|
||||
"background_threads_runtime_support",
|
||||
@@ -502,7 +491,7 @@ features = [
|
||||
]
|
||||
[workspace.dependencies.tikv-jemalloc-ctl]
|
||||
git = "https://forgejo.ellis.link/continuwuation/jemallocator"
|
||||
rev = "ac4d4861b335b199f812807996e8c9166961041a"
|
||||
rev = "df86ff89d4b1e223b9f7d2dd2fbb7f202da7f554"
|
||||
default-features = false
|
||||
features = ["use_std"]
|
||||
|
||||
@@ -510,7 +499,7 @@ features = ["use_std"]
|
||||
version = "0.5"
|
||||
|
||||
[workspace.dependencies.nix]
|
||||
version = "0.31.3"
|
||||
version = "0.31.0"
|
||||
default-features = false
|
||||
features = ["resource"]
|
||||
|
||||
@@ -532,7 +521,7 @@ version = "0.4.9"
|
||||
default-features = false
|
||||
|
||||
[workspace.dependencies.termimad]
|
||||
version = "0.35.5"
|
||||
version = "0.35.0"
|
||||
default-features = false
|
||||
|
||||
[workspace.dependencies.checked_ops]
|
||||
@@ -558,7 +547,7 @@ features = ["hardware-lock-elision", "deadlock_detection"] # TODO: Check if dead
|
||||
version = "0.5.0"
|
||||
|
||||
[workspace.dependencies.bytesize]
|
||||
version = "2.7"
|
||||
version = "2.0"
|
||||
|
||||
[workspace.dependencies.core_affinity]
|
||||
version = "0.8.3"
|
||||
@@ -570,11 +559,11 @@ version = "0.2"
|
||||
version = "0.2"
|
||||
|
||||
[workspace.dependencies.minicbor]
|
||||
version = "2.3.1"
|
||||
version = "2.1.1"
|
||||
features = ["std"]
|
||||
|
||||
[workspace.dependencies.minicbor-serde]
|
||||
version = "0.7.2"
|
||||
version = "0.7.0"
|
||||
features = ["std"]
|
||||
|
||||
[workspace.dependencies.maplit]
|
||||
@@ -584,10 +573,10 @@ version = "1.0.2"
|
||||
version = "1.0.1"
|
||||
|
||||
[workspace.dependencies.askama]
|
||||
version = "0.16.1"
|
||||
version = "0.16.0"
|
||||
|
||||
[workspace.dependencies.lettre]
|
||||
version = "0.11.23"
|
||||
version = "0.11.19"
|
||||
default-features = false
|
||||
features = ["smtp-transport", "pool", "hostname", "builder", "rustls", "rustls-native-certs", "tokio1", "rustls-no-provider", "tokio1-rustls", "tracing", "serde"]
|
||||
|
||||
@@ -600,7 +589,7 @@ features = ["std"]
|
||||
version = "0.3.0"
|
||||
|
||||
[workspace.dependencies.resolvematrix]
|
||||
version = "1.4.0"
|
||||
version = "1.3.0"
|
||||
|
||||
[workspace.dependencies.serde_urlencoded]
|
||||
version = "0.7.1"
|
||||
@@ -1020,7 +1009,4 @@ collapsible_if = "allow"
|
||||
cognitive_complexity = "allow"
|
||||
|
||||
[workspace.metadata.cargo-shear]
|
||||
# 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"]
|
||||
ignored = ["const-str", "ctor", "dtor"]
|
||||
+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 -p conduwuit --features openreg`. Only the debug binary is used.
|
||||
# after running `cargo build`. 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 --features openreg && docker build -t $COMPLEMENT_BASE_IMAGE -f docker/complement.Dockerfile ."
|
||||
echo "Build it with: cargo build -p conduwuit && docker build -t $COMPLEMENT_BASE_IMAGE -f docker/complement.Dockerfile ."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Upgraded rocksdb from 11.1.1 to 11.12.0 and jemalloc to 5.4.0.
|
||||
@@ -1 +0,0 @@
|
||||
Fix new devices sometimes never reaching other users' device lists. Contributed by @eleboucher.
|
||||
@@ -1 +0,0 @@
|
||||
The documentation now refers to the Continuwuity Docker service as `continuwuity` instead of `homeserver`.
|
||||
@@ -1 +0,0 @@
|
||||
Fix gap filling skipping outlier events that are missing their previous events. Contributed by @eleboucher.
|
||||
@@ -1 +0,0 @@
|
||||
Fix incoming federation events losing state changes when predecessors share the same state-before snapshot. Contributed by @eleboucher.
|
||||
@@ -1 +0,0 @@
|
||||
Fix to-device messages, including room keys, sometimes being lost before delivery. Contributed by @eleboucher.
|
||||
@@ -1 +0,0 @@
|
||||
Redirect URIs in OAuth clients' metadata are now properly validated to be on a subdomain of the OAuth issuer URL domain. Contributed by @ginger.
|
||||
@@ -1 +0,0 @@
|
||||
Fix v12 rooms created by the same user in the same millisecond ending up as the same room. Contributed by @eleboucher.
|
||||
@@ -1 +0,0 @@
|
||||
Client-server API endpoints are now properly ratelimited for unauthenticated requests. Contributed by @ginger.
|
||||
@@ -1 +0,0 @@
|
||||
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`.
|
||||
@@ -1 +0,0 @@
|
||||
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.
|
||||
@@ -1 +0,0 @@
|
||||
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`.
|
||||
@@ -1 +0,0 @@
|
||||
Setting `m.fully_read` via the account data endpoints now returns 405 `M_BAD_JSON` as required by the spec, instead of 400.
|
||||
@@ -1 +0,0 @@
|
||||
The `m.forget_forced_upon_leave` capability now reflects the `forget_forced_upon_leave` config option instead of always being advertised as enabled.
|
||||
@@ -1 +0,0 @@
|
||||
Fixed push notifications for membership events setting `user_is_target` based on the sender rather than the user being notified.
|
||||
@@ -1 +0,0 @@
|
||||
Ensure HTTP clients actually follow the `dns_servers` config option. Contributed by @silversys
|
||||
@@ -1 +0,0 @@
|
||||
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).
|
||||
@@ -1 +0,0 @@
|
||||
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,13 +685,6 @@
|
||||
# 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.2
|
||||
ENV BINSTALL_VERSION=1.26.1
|
||||
# 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
|
||||
xx-cargo build --locked --profile ${RUST_PROFILE} \
|
||||
CARGO_LOG=debug 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.2
|
||||
ENV BINSTALL_VERSION=1.26.1
|
||||
# renovate: datasource=github-releases depName=psastras/sbom-rs
|
||||
ENV CARGO_SBOM_VERSION=0.9.1
|
||||
# renovate: datasource=crate depName=lddtree
|
||||
|
||||
+1
-1
@@ -348,7 +348,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-configuring-coturn).
|
||||
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).
|
||||
:::
|
||||
|
||||
If you prefer static username/password credentials instead of shared secrets:
|
||||
|
||||
@@ -69,7 +69,7 @@ Docker's default DNS resolver is known to [**cause timeout issues**](../troubles
|
||||
|
||||
```yaml title='docker-compose.yml'
|
||||
services:
|
||||
continuwuity:
|
||||
homeserver:
|
||||
# ...
|
||||
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://continuwuity:8008
|
||||
reverse_proxy http://homeserver:8008
|
||||
}
|
||||
```
|
||||
|
||||
@@ -297,7 +297,7 @@ For Docker Compose deployments this means adding `stdin_open: true` and `tty: tr
|
||||
|
||||
```yaml
|
||||
services:
|
||||
continuwuity:
|
||||
homeserver:
|
||||
stdin_open: true
|
||||
tty: true
|
||||
# ...
|
||||
|
||||
@@ -12,14 +12,11 @@ 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 --features openreg
|
||||
cargo build -p conduwuit
|
||||
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://continuwuity:8008
|
||||
reverse_proxy http://homeserver:8008
|
||||
}
|
||||
https://example.com:443 {
|
||||
reverse_proxy /.well-known/matrix* http://continuwuity:8008
|
||||
reverse_proxy /.well-known/matrix* http://homeserver:8008
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ networks:
|
||||
- subnet: "10.10.10.0/24"
|
||||
|
||||
services:
|
||||
continuwuity:
|
||||
homeserver:
|
||||
# ...
|
||||
volume:
|
||||
- ./continuwuity-resolv.conf:/etc/resolv.conf:ro
|
||||
|
||||
@@ -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
|
||||
- deleting media (see [the media section](#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:
|
||||
continuwuity:
|
||||
homeserver:
|
||||
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/* continuwuity:8008
|
||||
caddy.reverse_proxy: /.well-known/matrix/* homeserver:8008
|
||||
|
||||
continuwuity:
|
||||
homeserver:
|
||||
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
|
||||
|
||||
continuwuity:
|
||||
homeserver:
|
||||
image: "forgejo.ellis.link/continuwuation/continuwuity:latest"
|
||||
restart: unless-stopped
|
||||
command: /sbin/conduwuit
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Continuwuity - With Traefik Reverse Proxy
|
||||
|
||||
services:
|
||||
continuwuity:
|
||||
homeserver:
|
||||
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/* continuwuity:8008
|
||||
# caddy.reverse_proxy: /.well-known/matrix/* homeserver: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"
|
||||
|
||||
continuwuity:
|
||||
homeserver:
|
||||
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:
|
||||
continuwuity:
|
||||
homeserver:
|
||||
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:
|
||||
continuwuity:
|
||||
homeserver:
|
||||
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
|
||||
|
||||
continuwuity:
|
||||
homeserver:
|
||||
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
|
||||
|
||||
continuwuity:
|
||||
homeserver:
|
||||
image: "forgejo.ellis.link/continuwuation/continuwuity:latest"
|
||||
restart: unless-stopped
|
||||
command: /sbin/conduwuit
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Continuwuity - With Traefik Reverse Proxy
|
||||
|
||||
services:
|
||||
continuwuity:
|
||||
homeserver:
|
||||
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": 1793979272,
|
||||
"narHash": "sha256-oUcBtPbtS7PlEMuSrgTAN4wv49cXYbwKbQqhH2pah5w=",
|
||||
"lastModified": 1789329924,
|
||||
"narHash": "sha256-mykGMFabQ7yP6G373M3VHkrac9PJPKJstrhQz2D/Rdc=",
|
||||
"owner": "rustsec",
|
||||
"repo": "advisory-db",
|
||||
"rev": "309392b18f6b17022f82c701f300433126901068",
|
||||
"rev": "455fd4bac659b5f1fca3810661c2d8b3c25dad05",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -18,11 +18,11 @@
|
||||
},
|
||||
"crane": {
|
||||
"locked": {
|
||||
"lastModified": 1793836618,
|
||||
"narHash": "sha256-TREenflwEjxOSq292FYwbc3kEm7TDRtXCZRNWEdjBmg=",
|
||||
"lastModified": 1788465171,
|
||||
"narHash": "sha256-Y1/TTVXjYXGF068IThQH9fPSZ0SIE74PABlUxnWTUH0=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "79fd63528501446749c09f08cad486a58c7d173e",
|
||||
"rev": "eb35abda9f232cc6610b1d1e3200d15c49b7ac54",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -39,11 +39,11 @@
|
||||
"rust-analyzer-src": "rust-analyzer-src"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1794142885,
|
||||
"narHash": "sha256-xWFSr7q8IerDAVRk4W7/CgTmi05hMy2qjZ0z3VYpOVk=",
|
||||
"lastModified": 1789298866,
|
||||
"narHash": "sha256-6eaV5+MdWy1tAlN4HAFr64pTnYc9jiKGXBsu18cyVjE=",
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"rev": "f7d416b5073152c7f2e4de1a28d1a4330dd30a26",
|
||||
"rev": "1fc6f36a23fa16e3740987957266f6e4b915c3cd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -74,11 +74,11 @@
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1793576659,
|
||||
"narHash": "sha256-V1h85lUaJBQoHFrB2vpXZOE0Ju1MYSnIpsehoVZYlDo=",
|
||||
"lastModified": 1788450739,
|
||||
"narHash": "sha256-glZLQlzIn1fXH6PazR2iUmTo7kzzyYSshrWhLS9TqCU=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "ea2630b7470978622c7689a1ff75d2b389175399",
|
||||
"rev": "31729ca8cbdb4fa927b34e5f4353e6a83f39e993",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -89,11 +89,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1794042290,
|
||||
"narHash": "sha256-ziZn2PvCJE5JEEpqTdxXwJpPB+L3YqoCpTAMCzyaP3U=",
|
||||
"lastModified": 1789149629,
|
||||
"narHash": "sha256-H6GwaZzZf+4npqv0tph94w9tZddSjFjmQrVsW0z78uk=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "f4a03c008967841f2a0b3cb7c436fc6fc31671f6",
|
||||
"rev": "eaad089433ca2bb662274377d33df3d0e51ef28b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -105,11 +105,11 @@
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1793504054,
|
||||
"narHash": "sha256-ThkfL3D/FhCiZFc9+3BtxwuMmpuK+/bGtXCSo1+yVew=",
|
||||
"lastModified": 1788057806,
|
||||
"narHash": "sha256-DTQSMxzDWmT0zhguthvegnVkn7CFqGCv4IHCzk5ZUpM=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "7851ba61fd862b277cb6a9cef37394bc18bb94e4",
|
||||
"rev": "596e2e3940e09b2abbeb03f75fa1828c57fcd72c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -132,11 +132,11 @@
|
||||
"rust-analyzer-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1794096810,
|
||||
"narHash": "sha256-dWC+YtMX+cwH3e9ndiFB77ijTsKtO5I2OxfcvUY4j3k=",
|
||||
"lastModified": 1789128286,
|
||||
"narHash": "sha256-KRxxgHiKIBp7R2n41IJuE5K4IUiLOpg47EEi3AxuSp8=",
|
||||
"owner": "rust-lang",
|
||||
"repo": "rust-analyzer",
|
||||
"rev": "03ae6be57aa063bb373f69eead3b8e15168a45d2",
|
||||
"rev": "6aeeb8cf02741e5da07a1615a05faa506cecb21a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -153,11 +153,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1791885023,
|
||||
"narHash": "sha256-C3alQ2MEt0zVrUSho5NUDo3jmhbff72++bfwoqT9Omo=",
|
||||
"lastModified": 1786901030,
|
||||
"narHash": "sha256-WSFCsDSE5ffgD2MqzkM2CYjeFiKhRF/dJUN8uedb6YE=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "0d6d739a833ba9a9c93034862e4a7b061a062a1c",
|
||||
"rev": "27b3b12a8e6375f28ebe122f07d230ca5459bbfa",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -42,12 +42,7 @@ let
|
||||
|
||||
env = {
|
||||
CARGO_PROFILE = profile;
|
||||
# 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 ]
|
||||
);
|
||||
RUSTFLAGS = rustflags;
|
||||
GIT_COMMIT_HASH = self.rev or self.dirtyRev or "";
|
||||
GIT_COMMIT_HASH_SHORT = self.shortRev or self.dirtyShortRev or "";
|
||||
}
|
||||
@@ -65,6 +60,18 @@ 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,23 +18,6 @@
|
||||
{
|
||||
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
|
||||
@@ -95,7 +78,6 @@
|
||||
import inputs.nixpkgs {
|
||||
localSystem = system;
|
||||
crossSystem = "x86_64-unknown-linux-musl";
|
||||
overlays = [ muslOverlay ];
|
||||
}
|
||||
)
|
||||
))
|
||||
@@ -104,7 +86,6 @@
|
||||
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-11-08";
|
||||
version = "continuwuity-v0.5.0-unstable-2026-05-19";
|
||||
src = fetchFromGitea {
|
||||
domain = "forgejo.ellis.link";
|
||||
owner = "continuwuation";
|
||||
repo = "rocksdb";
|
||||
rev = "722fa3219df4169610fda8962221a1ff74026fdb";
|
||||
hash = "sha256-ZuXXp83Hgj0B5v499CNxa9oNQUS/ZKYOAZEhmarUifc=";
|
||||
rev = "3756b2b905e13216d8b56bcc783d814e7b073aff";
|
||||
hash = "sha256-rSv4fr2bf9JJwdodgeuPCuceeh7k97KVxrAOC0wyPQY=";
|
||||
};
|
||||
|
||||
# We have this already at https://forgejo.ellis.link/continuwuation/rocksdb/commit/a935c0273e1ba44eacf88ce3685a9b9831486155
|
||||
|
||||
Generated
+335
-372
File diff suppressed because it is too large.
Load diff
@@ -62,6 +62,8 @@ 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",
|
||||
@@ -82,6 +84,7 @@ 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
|
||||
|
||||
+5
-1093
File diff suppressed because it is too large.
Load diff
@@ -1,12 +1,8 @@
|
||||
mod commands;
|
||||
pub(crate) mod tester;
|
||||
|
||||
use clap::Subcommand;
|
||||
use conduwuit::Result;
|
||||
use ruma::{OwnedEventId, OwnedRoomId, OwnedRoomOrAliasId, OwnedServerName};
|
||||
use service::rooms::short::{ShortEventId, ShortRoomId};
|
||||
|
||||
use self::tester::TesterCommand;
|
||||
use crate::admin_command_dispatch;
|
||||
|
||||
#[admin_command_dispatch]
|
||||
@@ -17,177 +13,6 @@ pub enum DebugCommand {
|
||||
message: Vec<String>,
|
||||
},
|
||||
|
||||
/// Loads the auth_chain of a PDU, reporting how long it took.
|
||||
GetAuthChain {
|
||||
/// An event ID (the $ character followed by the base64 reference hash)
|
||||
event_id: OwnedEventId,
|
||||
},
|
||||
|
||||
/// Walks & displays the auth_chain of a PDU in a mermaid graph format.
|
||||
///
|
||||
/// This is useless to basically anyone but developers, and is also probably
|
||||
/// slow and memory hungry.
|
||||
ShowAuthChain {
|
||||
/// The root event ID to start walking back from.
|
||||
event_id: OwnedEventId,
|
||||
},
|
||||
|
||||
/// Parse and print a PDU from a JSON
|
||||
///
|
||||
/// The PDU event is only checked for validity and is not added to the
|
||||
/// database.
|
||||
///
|
||||
/// This command needs a JSON blob provided in a Markdown code block below
|
||||
/// the command.
|
||||
ParsePdu,
|
||||
|
||||
/// Retrieve and print a PDU by EventID from the Continuwuity database
|
||||
GetPdu {
|
||||
/// An event ID (a $ followed by the base64 reference hash)
|
||||
event_id: OwnedEventId,
|
||||
},
|
||||
|
||||
/// Retrieve and print a PDU by PduId from the Continuwuity database
|
||||
GetShortPdu {
|
||||
/// Shortroomid integer
|
||||
shortroomid: ShortRoomId,
|
||||
|
||||
/// Shorteventid integer
|
||||
shorteventid: ShortEventId,
|
||||
},
|
||||
|
||||
/// Attempts to retrieve a PDU from a remote server. **Does not** insert
|
||||
/// it into the database
|
||||
/// or persist it anywhere.
|
||||
GetRemotePdu {
|
||||
/// An event ID (a $ followed by the base64 reference hash)
|
||||
event_id: OwnedEventId,
|
||||
|
||||
/// Argument for us to attempt to fetch the event from the
|
||||
/// specified remote server.
|
||||
server: OwnedServerName,
|
||||
},
|
||||
|
||||
/// Same as `get-remote-pdu` but accepts a codeblock newline delimited
|
||||
/// list of PDUs and a single server to fetch from
|
||||
GetRemotePduList {
|
||||
/// Argument for us to attempt to fetch all the events from the
|
||||
/// specified remote server.
|
||||
server: OwnedServerName,
|
||||
|
||||
/// If set, ignores errors, else stops at the first error/failure.
|
||||
#[arg(short, long)]
|
||||
force: bool,
|
||||
},
|
||||
|
||||
/// Gets all the room state events for the specified room.
|
||||
///
|
||||
/// This is functionally equivalent to `GET
|
||||
/// /_matrix/client/v3/rooms/{roomid}/state`, except the admin command does
|
||||
/// *not* check if the sender user is allowed to see state events. This is
|
||||
/// done because it's implied that server admins here have database access
|
||||
/// and can see/get room info themselves anyways if they were malicious
|
||||
/// admins.
|
||||
///
|
||||
/// Of course the check is still done on the actual client API.
|
||||
GetRoomState {
|
||||
/// Room ID
|
||||
room_id: OwnedRoomOrAliasId,
|
||||
},
|
||||
|
||||
/// Gets all the room state events at the specified event.
|
||||
///
|
||||
/// State at event might not be available for some PDUs, such as rejected
|
||||
/// ones.
|
||||
GetStateAt {
|
||||
event_id: OwnedEventId,
|
||||
},
|
||||
|
||||
/// Sends a federation request to the remote server's
|
||||
/// `/_matrix/federation/v1/version` endpoint and measures the latency it
|
||||
/// took for the server to respond
|
||||
Ping {
|
||||
server: OwnedServerName,
|
||||
},
|
||||
|
||||
/// Forces device lists for all local and remote users to be updated (as
|
||||
/// having new keys available)
|
||||
ForceDeviceListUpdates,
|
||||
|
||||
/// Change tracing log level/filter on the fly
|
||||
///
|
||||
/// This accepts the same format as the `log` config option.
|
||||
ChangeLogLevel {
|
||||
/// Log level/filter
|
||||
filter: Option<String>,
|
||||
|
||||
/// Resets the log level/filter to the one in your config
|
||||
#[arg(short, long)]
|
||||
reset: bool,
|
||||
},
|
||||
|
||||
/// Verify JSON signatures
|
||||
///
|
||||
/// This command needs a JSON blob provided in a Markdown code block below
|
||||
/// the command.
|
||||
VerifyJson,
|
||||
|
||||
/// Verify PDU
|
||||
///
|
||||
/// This re-verifies a PDU existing in the database found by ID.
|
||||
VerifyPdu {
|
||||
event_id: OwnedEventId,
|
||||
},
|
||||
|
||||
/// Prints the very first PDU in the specified room (typically
|
||||
/// m.room.create)
|
||||
FirstPduInRoom {
|
||||
/// The room ID
|
||||
room_id: OwnedRoomId,
|
||||
},
|
||||
|
||||
/// Prints the latest ("last") PDU in the specified room (typically a
|
||||
/// message)
|
||||
LatestPduInRoom {
|
||||
/// The room ID
|
||||
room_id: OwnedRoomId,
|
||||
},
|
||||
|
||||
/// Forcefully replaces the room state of our local copy of the specified
|
||||
/// room, with the copy (auth chain and room state events) the specified
|
||||
/// remote server says.
|
||||
///
|
||||
/// A common desire for room deletion is to simply "reset" our copy of the
|
||||
/// room. While this admin command is not a replacement for that, if you
|
||||
/// know you have split/broken room state and you know another server in the
|
||||
/// room that has the best/working room state, this command can let you use
|
||||
/// their room state. Such example is your server saying users are in a
|
||||
/// room, but other servers are saying they're not in the room in question.
|
||||
///
|
||||
/// This command will get the latest PDU in the room we know about, and
|
||||
/// request the room state at that point in time via
|
||||
/// `/_matrix/federation/v1/state/{roomId}`.
|
||||
ForceSetRoomStateFromServer {
|
||||
/// The impacted room ID
|
||||
room_id: OwnedRoomId,
|
||||
/// The server we will use to query the room state for
|
||||
server_name: OwnedServerName,
|
||||
/// The event ID of the latest known PDU in the room. Will be found
|
||||
/// automatically if not provided.
|
||||
event_id: Option<OwnedEventId>,
|
||||
},
|
||||
|
||||
/// Runs a server name through Continuwuity's true destination resolution
|
||||
/// process
|
||||
///
|
||||
/// Useful for debugging well-known issues
|
||||
ResolveTrueDestination {
|
||||
server_name: OwnedServerName,
|
||||
|
||||
#[arg(short, long)]
|
||||
no_cache: bool,
|
||||
},
|
||||
|
||||
/// Print extended memory usage
|
||||
///
|
||||
/// Optional argument is a character mask (a sequence of characters in any
|
||||
@@ -204,9 +29,6 @@ pub enum DebugCommand {
|
||||
/// invocation.
|
||||
RuntimeInterval,
|
||||
|
||||
/// Print the current time
|
||||
Time,
|
||||
|
||||
/// Get database statistics
|
||||
DatabaseStats {
|
||||
property: Option<String>,
|
||||
@@ -233,28 +55,4 @@ pub enum DebugCommand {
|
||||
RoomsByExtremityCount {
|
||||
page: Option<usize>,
|
||||
},
|
||||
|
||||
RoomExtremities {
|
||||
room_id: OwnedRoomId,
|
||||
},
|
||||
|
||||
/// Lists remote servers that are currently in a "backoff" state.
|
||||
///
|
||||
/// Servers in this list will not be contacted until the retry time elapses,
|
||||
/// or they make contact first.
|
||||
///
|
||||
/// "Stale" indicates that routing information may be out of date, and the
|
||||
/// remote will be re-resolved immediately before the next contact attempt.
|
||||
ServersInBackoff {
|
||||
#[arg(short, long, alias = "room")]
|
||||
room_id: Option<OwnedRoomId>,
|
||||
#[arg(short, long)]
|
||||
name: Option<OwnedServerName>,
|
||||
},
|
||||
|
||||
/// Developer test stubs
|
||||
#[command(subcommand)]
|
||||
#[allow(non_snake_case)]
|
||||
#[clap(hide(true))]
|
||||
Tester(TesterCommand),
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
use conduwuit::{Err, Result};
|
||||
|
||||
use crate::admin_command_dispatch;
|
||||
|
||||
#[admin_command_dispatch]
|
||||
#[derive(Debug, clap::Subcommand)]
|
||||
pub enum TesterCommand {
|
||||
Panic,
|
||||
Failure,
|
||||
Tester,
|
||||
Timer,
|
||||
}
|
||||
|
||||
#[allow(clippy::unused_async_trait_impl)]
|
||||
impl crate::Context<'_> {
|
||||
#[rustfmt::skip]
|
||||
async fn panic(&self) -> Result {
|
||||
panic!("panicked")
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
async fn failure(&self) -> Result {
|
||||
Err!("failed")
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
#[rustfmt::skip]
|
||||
async fn tester(&self) -> Result {
|
||||
self.write_str("Ok").await
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
#[rustfmt::skip]
|
||||
async fn timer(&self) -> Result {
|
||||
let started = std::time::Instant::now();
|
||||
timed(self.body);
|
||||
|
||||
let elapsed = started.elapsed();
|
||||
self.write_str(&format!("completed in {elapsed:#?}")).await
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
#[rustfmt::skip]
|
||||
#[allow(unused_variables)]
|
||||
fn timed(body: &[&str]) {
|
||||
|
||||
}
|
||||
@@ -1,20 +1,23 @@
|
||||
use std::fmt::Write;
|
||||
|
||||
use conduwuit::{Err, Result, utils::response::LimitReadExt};
|
||||
use futures::StreamExt;
|
||||
use ruma::{MilliSecondsSinceUnixEpoch, OwnedRoomId, OwnedServerName, OwnedUserId};
|
||||
|
||||
use crate::get_room_info;
|
||||
use resolvematrix::{
|
||||
resolution::ResolvedDestination,
|
||||
server::{MatrixResolver, MatrixResolverBuilder},
|
||||
};
|
||||
use ruma::{MilliSecondsSinceUnixEpoch, OwnedRoomOrAliasId, OwnedServerName};
|
||||
|
||||
impl crate::Context<'_> {
|
||||
pub(super) async fn disable_room(&self, room_id: OwnedRoomId) -> Result {
|
||||
pub(super) async fn disable_room(&self, room: OwnedRoomOrAliasId) -> Result {
|
||||
self.bail_restricted()?;
|
||||
let room_id = self.services.rooms.alias.resolve(&room).await?;
|
||||
self.services.rooms.metadata.disable_room(&room_id, true);
|
||||
self.write_str("Room disabled.").await
|
||||
}
|
||||
|
||||
pub(super) async fn enable_room(&self, room_id: OwnedRoomId) -> Result {
|
||||
pub(super) async fn enable_room(&self, room: OwnedRoomOrAliasId) -> Result {
|
||||
self.bail_restricted()?;
|
||||
let room_id = self.services.rooms.alias.resolve(&room).await?;
|
||||
self.services.rooms.metadata.disable_room(&room_id, false);
|
||||
self.write_str("Room enabled.").await
|
||||
}
|
||||
@@ -33,13 +36,13 @@ impl crate::Context<'_> {
|
||||
map.len(),
|
||||
self.services.transactions.txn_active_handle_count()
|
||||
);
|
||||
for (r, (e, i)) in map.iter() {
|
||||
let elapsed = i.elapsed();
|
||||
for (room_id, (event_id, started_at)) in map.iter() {
|
||||
let elapsed = started_at.elapsed();
|
||||
writeln!(
|
||||
msg,
|
||||
"{} {}: {}m{}s",
|
||||
r,
|
||||
e,
|
||||
room_id,
|
||||
event_id,
|
||||
elapsed.as_secs() / 60,
|
||||
elapsed.as_secs() % 60
|
||||
)?;
|
||||
@@ -50,7 +53,7 @@ impl crate::Context<'_> {
|
||||
self.write_str(&msg).await
|
||||
}
|
||||
|
||||
pub(super) async fn fetch_support_well_known(&self, server_name: OwnedServerName) -> Result {
|
||||
pub(super) async fn fetch_support(&self, server_name: OwnedServerName) -> Result {
|
||||
let response = self
|
||||
.services
|
||||
.client
|
||||
@@ -97,41 +100,6 @@ impl crate::Context<'_> {
|
||||
.await
|
||||
}
|
||||
|
||||
pub(super) async fn remote_user_in_rooms(&self, user_id: OwnedUserId) -> Result {
|
||||
if user_id.server_name() == self.services.server.name {
|
||||
return Err!(
|
||||
"User belongs to our server, please use `list-joined-rooms` user admin command \
|
||||
instead.",
|
||||
);
|
||||
}
|
||||
|
||||
let mut rooms: Vec<(OwnedRoomId, u64, String)> = self
|
||||
.services
|
||||
.rooms
|
||||
.state_cache
|
||||
.rooms_joined(&user_id)
|
||||
.then(async |room_id| get_room_info(self.services, &room_id).await)
|
||||
.collect()
|
||||
.await;
|
||||
|
||||
if rooms.is_empty() {
|
||||
return Err!("User is not in any rooms.");
|
||||
}
|
||||
|
||||
rooms.sort_by_key(|r| r.1);
|
||||
rooms.reverse();
|
||||
|
||||
let num = rooms.len();
|
||||
let body = rooms
|
||||
.iter()
|
||||
.map(|(id, members, name)| format!("{id} | Members: {members} | Name: {name}"))
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
|
||||
self.write_str(&format!("Rooms {user_id} shares with us ({num}):\n```\n{body}\n```"))
|
||||
.await
|
||||
}
|
||||
|
||||
pub(super) async fn get_signing_keys(&self, server_name: OwnedServerName) -> Result {
|
||||
let response = self
|
||||
.services
|
||||
@@ -157,4 +125,67 @@ impl crate::Context<'_> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) async fn ping(&self, server: OwnedServerName) -> Result {
|
||||
let timer = tokio::time::Instant::now();
|
||||
|
||||
match self
|
||||
.services
|
||||
.sending
|
||||
.send_unauthenticated_request(
|
||||
&server,
|
||||
ruma::api::federation::discovery::get_server_version::v1::Request::new(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
| Err(e) => {
|
||||
return Err!("Failed sending federation request to specified server:\n\n{e}");
|
||||
},
|
||||
| Ok(response) => {
|
||||
let ping_time = timer.elapsed();
|
||||
let json_text_res = serde_json::to_string_pretty(&response.server);
|
||||
|
||||
let out = if let Ok(json) = json_text_res {
|
||||
format!("Got response which took {ping_time:?} time:\n```json\n{json}\n```")
|
||||
} else {
|
||||
format!("Got non-JSON response which took {ping_time:?} time:\n{response:?}")
|
||||
};
|
||||
|
||||
write!(self, "{out}")
|
||||
},
|
||||
}
|
||||
.await
|
||||
}
|
||||
|
||||
pub(super) async fn resolve_true_destination(
|
||||
&self,
|
||||
server_name: OwnedServerName,
|
||||
no_cache: bool,
|
||||
) -> Result {
|
||||
if !self.services.server.config.allow_federation {
|
||||
return Err!("Federation is disabled on this homeserver.",);
|
||||
}
|
||||
|
||||
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())
|
||||
.build()?
|
||||
} else {
|
||||
&self.services.client.matrix_resolver
|
||||
};
|
||||
|
||||
let actual = resolver.resolve_server(server_name.as_str()).await?;
|
||||
|
||||
let destination = match actual.destination {
|
||||
| ResolvedDestination::Literal(addr) => addr.to_string(),
|
||||
| ResolvedDestination::Named(host, port) => format!("{host}:{port}"),
|
||||
};
|
||||
|
||||
let msg = format!(
|
||||
"Destination: {}\nHostname URI (SNI): {}\nIs override?: {}\nResolution step: {}",
|
||||
destination, actual.host, actual.is_override, actual.resolution_step
|
||||
);
|
||||
self.write_str(&msg).await
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use clap::Subcommand;
|
||||
use conduwuit::Result;
|
||||
use conduwuit_macros::admin_command_dispatch;
|
||||
use futures::StreamExt;
|
||||
use ruma::{OwnedRoomOrAliasId, OwnedServerName};
|
||||
|
||||
#[admin_command_dispatch]
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum HealthCommand {
|
||||
/// Lists all servers that are currently marked as unhealthy (i.e. we
|
||||
/// previously failed to establish direct federation and have not succeeded
|
||||
/// since).
|
||||
#[clap(name = "list")]
|
||||
ListUnhealthyServers {
|
||||
/// An optional filter to only check servers that are in a specific room
|
||||
/// (ID or alias).
|
||||
room: Option<OwnedRoomOrAliasId>,
|
||||
},
|
||||
|
||||
/// Displays the current health status of the given remote server.
|
||||
#[clap(name = "status")]
|
||||
ServerHealthStatus {
|
||||
server_name: OwnedServerName,
|
||||
},
|
||||
|
||||
/// Forces the server to consider the remote server healthy.
|
||||
///
|
||||
/// This is generally unnecessary as this already happens when the remote
|
||||
/// server makes contact with this server, or if this server successfully
|
||||
/// makes a request to the remote server after the backoff window.
|
||||
ForceHealthy {
|
||||
server_name: OwnedServerName,
|
||||
},
|
||||
|
||||
/// Forces the server to consider the remote server unhealthy.
|
||||
///
|
||||
/// This is generally unnecessary as this already happens when the remote
|
||||
/// server fails to resolve or connect, or returns unusual errors.
|
||||
/// If you are looking to stop contacting a specific server, take a look at
|
||||
/// the `forbidden_remote_server_names` configuration option.
|
||||
ForceUnhealthy {
|
||||
server_name: OwnedServerName,
|
||||
/// If set, the server will also be marked as having stale routing
|
||||
/// information. This means the address will be re-resolved on the next
|
||||
/// connection attempt.
|
||||
#[arg(long)]
|
||||
stale: bool,
|
||||
},
|
||||
}
|
||||
|
||||
impl crate::Context<'_> {
|
||||
pub(super) async fn list_unhealthy_servers(
|
||||
&self,
|
||||
room: Option<OwnedRoomOrAliasId>,
|
||||
) -> Result {
|
||||
let unhealthy = self.services.federation.remote_health();
|
||||
|
||||
if unhealthy.is_empty() {
|
||||
return self
|
||||
.write_str("No servers are currently tracked as unhealthy.")
|
||||
.await;
|
||||
}
|
||||
|
||||
let stale_destinations = self.services.federation.stale_destinations();
|
||||
|
||||
let mut candidates: Vec<_> = if let Some(room) = room {
|
||||
let room_id = self.services.rooms.alias.resolve(&room).await?;
|
||||
self.services
|
||||
.rooms
|
||||
.state_cache
|
||||
.room_servers(&room_id)
|
||||
.collect()
|
||||
.await
|
||||
} else {
|
||||
unhealthy
|
||||
.keys()
|
||||
.chain(stale_destinations.iter())
|
||||
.cloned()
|
||||
.collect()
|
||||
};
|
||||
candidates.retain(|name| unhealthy.contains_key(name));
|
||||
candidates.sort();
|
||||
candidates.dedup();
|
||||
if candidates.is_empty() {
|
||||
return self
|
||||
.write_str("No servers are currently unhealthy meeting the given criteria.")
|
||||
.await;
|
||||
}
|
||||
for server_name in candidates {
|
||||
let Some((retries, retry_at)) = unhealthy.get(&server_name) else { continue };
|
||||
let is_stale = if stale_destinations.contains(&server_name) {
|
||||
"Yes"
|
||||
} else {
|
||||
"No"
|
||||
};
|
||||
self.write_str(&format!("| {server_name} | {retries} | {retry_at} | {is_stale} |\n"))
|
||||
.await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) async fn server_health_status(&self, server_name: OwnedServerName) -> Result {
|
||||
let stale = self
|
||||
.services
|
||||
.federation
|
||||
.stale_destinations()
|
||||
.contains(&server_name);
|
||||
let Some((retries, retry_at_ts)) = self
|
||||
.services
|
||||
.federation
|
||||
.remote_health()
|
||||
.get(&server_name)
|
||||
.copied()
|
||||
else {
|
||||
return self
|
||||
.write_str(&if stale {
|
||||
format!(
|
||||
"{server_name} is currently healthy, but may have stale routing \
|
||||
information."
|
||||
)
|
||||
} else {
|
||||
format!("{server_name} is currently healthy.")
|
||||
})
|
||||
.await;
|
||||
};
|
||||
|
||||
let state = if stale {
|
||||
"unhealthy with potentially stale routing information"
|
||||
} else {
|
||||
"unhealthy"
|
||||
};
|
||||
self.write_str(&format!(
|
||||
"{server_name} is currently {state}: {retries} consecutive connections have \
|
||||
failed,and no new connection will be attempted for another {}.",
|
||||
conduwuit::utils::time::pretty(Duration::from_millis(retry_at_ts)),
|
||||
))
|
||||
.await
|
||||
}
|
||||
|
||||
pub(super) async fn force_healthy(&self, server_name: OwnedServerName) -> Result {
|
||||
self.services.federation.mark_healthy(&server_name);
|
||||
self.write_str("Done.").await
|
||||
}
|
||||
|
||||
pub(super) async fn force_unhealthy(
|
||||
&self,
|
||||
server_name: OwnedServerName,
|
||||
stale: bool,
|
||||
) -> Result {
|
||||
if stale {
|
||||
self.services
|
||||
.federation
|
||||
.mark_destination_stale(&server_name);
|
||||
}
|
||||
self.services.federation.hit_unhealthy(server_name);
|
||||
self.write_str("Done.").await
|
||||
}
|
||||
}
|
||||
+35
-16
@@ -1,47 +1,66 @@
|
||||
mod commands;
|
||||
mod health;
|
||||
|
||||
use clap::Subcommand;
|
||||
use conduwuit::Result;
|
||||
use ruma::{OwnedRoomId, OwnedServerName, OwnedUserId};
|
||||
use ruma::{OwnedRoomOrAliasId, OwnedServerName};
|
||||
|
||||
use crate::admin_command_dispatch;
|
||||
use crate::{admin_command_dispatch, federation::health::HealthCommand};
|
||||
|
||||
#[admin_command_dispatch]
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum FederationCommand {
|
||||
/// List all rooms we are currently handling an incoming pdu from
|
||||
#[clap(name = "incoming", alias = "inbound")]
|
||||
IncomingFederation,
|
||||
|
||||
/// Disables incoming federation handling for a room.
|
||||
///
|
||||
/// The room can still be used locally, but events from other servers will
|
||||
/// stop being received.
|
||||
DisableRoom {
|
||||
room_id: OwnedRoomId,
|
||||
room: OwnedRoomOrAliasId,
|
||||
},
|
||||
|
||||
/// Enables incoming federation handling for a room again.
|
||||
///
|
||||
/// This does not unban the room if it was banned, it only re-enables
|
||||
/// incoming events.
|
||||
EnableRoom {
|
||||
room_id: OwnedRoomId,
|
||||
room: OwnedRoomOrAliasId,
|
||||
},
|
||||
|
||||
/// Fetch `/.well-known/matrix/support` from the specified server
|
||||
/// Fetch support details from the given server.
|
||||
///
|
||||
/// Despite the name, this is not a federation endpoint and does not go
|
||||
/// through the federation / server resolution process as per-spec this is
|
||||
/// supposed to be served at the server_name.
|
||||
///
|
||||
/// Respecting homeservers put this file here for listing administration,
|
||||
/// moderation, and security inquiries. This command provides a way to
|
||||
/// easily fetch that information.
|
||||
FetchSupportWellKnown {
|
||||
/// This makes a request to `https://<server_name>/.well-known/matrix/support`. Many servers do not advertise support information, but those that do usually provide a way to contact homeserver administrators.
|
||||
FetchSupport {
|
||||
server_name: OwnedServerName,
|
||||
},
|
||||
|
||||
/// Lists all the rooms we share/track with the specified *remote* user
|
||||
RemoteUserInRooms {
|
||||
user_id: OwnedUserId,
|
||||
/// Runs a server name through Continuwuity's server-to-server address
|
||||
/// resolution process.
|
||||
#[clap(name = "resolve")]
|
||||
ResolveTrueDestination {
|
||||
server_name: OwnedServerName,
|
||||
|
||||
#[arg(short, long)]
|
||||
skip_cache: bool,
|
||||
},
|
||||
|
||||
/// Queries the remote server for their current signing keys.
|
||||
GetSigningKeys {
|
||||
server_name: OwnedServerName,
|
||||
},
|
||||
|
||||
/// Makes a federation request to the remote server, to test connectivity.
|
||||
///
|
||||
/// The request is made to the federation version endpoint, which if
|
||||
/// successful, will also reveal how long the request took and what the
|
||||
/// remote server's software is.
|
||||
Ping {
|
||||
server_name: OwnedServerName,
|
||||
},
|
||||
|
||||
#[command(subcommand)]
|
||||
Health(HealthCommand),
|
||||
}
|
||||
@@ -0,0 +1,401 @@
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
fmt::Write,
|
||||
};
|
||||
|
||||
use clap::Subcommand;
|
||||
use conduwuit::{Err, Event, PduEvent, Result, err, utils::stream::BroadbandExt};
|
||||
use conduwuit_macros::admin_command_dispatch;
|
||||
use futures::StreamExt;
|
||||
use ruma::{EventId, OwnedEventId, OwnedRoomId, OwnedRoomOrAliasId, OwnedServerName, UInt};
|
||||
|
||||
#[admin_command_dispatch]
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum GraphCommand {
|
||||
/// Lists all forward extremities in a room.
|
||||
ListExtremities {
|
||||
room: OwnedRoomOrAliasId,
|
||||
},
|
||||
|
||||
/// Fetches a PDU (event) by its event ID, as stored in the database. Also
|
||||
/// includes details about the PDU state.
|
||||
GetPDU {
|
||||
event_id: OwnedEventId,
|
||||
},
|
||||
|
||||
/// Fetches a PDU over federation. Does not store the result.
|
||||
FetchPDU {
|
||||
event_id: OwnedEventId,
|
||||
server_name: OwnedServerName,
|
||||
},
|
||||
|
||||
/// Yields the first PDU we became aware of in a room.
|
||||
/// This is always the room's create event for local rooms, or the first
|
||||
/// membership event that introduced us to the remote room.
|
||||
#[clap(name = "first-pdu")]
|
||||
FirstPduInRoom {
|
||||
room_id: OwnedRoomId,
|
||||
},
|
||||
|
||||
/// Yields the most recent PDU in a room.
|
||||
#[clap(name = "latest-pdu")]
|
||||
LatestPduInRoom {
|
||||
room_id: OwnedRoomId,
|
||||
},
|
||||
|
||||
/// Draws a mermaid graph of the auth chain for an event.
|
||||
ShowAuthChain {
|
||||
event_id: OwnedEventId,
|
||||
},
|
||||
}
|
||||
|
||||
impl crate::Context<'_> {
|
||||
pub(super) async fn list_extremities(&self, room: OwnedRoomOrAliasId) -> Result {
|
||||
let room_id = self.services.rooms.alias.resolve(&room).await?;
|
||||
let mut extremities = self
|
||||
.services
|
||||
.rooms
|
||||
.state
|
||||
.get_forward_extremities(&room_id)
|
||||
.broad_filter_map(|event_id| async move {
|
||||
self.services.rooms.timeline.get_pdu(&event_id).await.ok()
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.await;
|
||||
extremities.sort_by_key(|pdu| (pdu.depth, pdu.origin_server_ts));
|
||||
if extremities.is_empty() {
|
||||
return Err!("No room extremities.");
|
||||
}
|
||||
self.write_str("| Event ID | Type | Sender | Timestamp | Depth |\n")
|
||||
.await?;
|
||||
self.write_str("| -------- | ---- | ------ | --------- | ----- |\n")
|
||||
.await?;
|
||||
for pdu in extremities {
|
||||
let url = format!(
|
||||
"https://matrix.to/#/{}/{}?via={}",
|
||||
room_id,
|
||||
pdu.event_id(),
|
||||
self.services.server.name
|
||||
);
|
||||
self.write_str(&format!(
|
||||
"| [`{}`]({url}) | `{}` | `{}` | `{}` | `{}` |\n",
|
||||
pdu.event_id(),
|
||||
pdu.kind(),
|
||||
pdu.sender(),
|
||||
pdu.origin_server_ts,
|
||||
pdu.depth
|
||||
))
|
||||
.await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) async fn get_pdu(&self, event_id: OwnedEventId) -> Result {
|
||||
let mut outlier = false;
|
||||
let mut pdu_json = self
|
||||
.services
|
||||
.rooms
|
||||
.timeline
|
||||
.get_non_outlier_pdu_json(&event_id)
|
||||
.await;
|
||||
|
||||
if pdu_json.is_err() {
|
||||
outlier = true;
|
||||
pdu_json = self.services.rooms.timeline.get_pdu_json(&event_id).await;
|
||||
}
|
||||
let rejected = self
|
||||
.services
|
||||
.rooms
|
||||
.pdu_metadata
|
||||
.is_event_rejected(&event_id)
|
||||
.await;
|
||||
let soft_failed = self
|
||||
.services
|
||||
.rooms
|
||||
.pdu_metadata
|
||||
.is_event_soft_failed(&event_id)
|
||||
.await;
|
||||
|
||||
match pdu_json {
|
||||
| Err(_) => return Err!("PDU not found locally."),
|
||||
| Ok(json) => {
|
||||
let text = serde_json::to_string_pretty(&json)?;
|
||||
let msg = if rejected {
|
||||
"Rejected PDU:"
|
||||
} else if soft_failed {
|
||||
"Soft-failed PDU:"
|
||||
} else if outlier {
|
||||
"Outlier PDU:"
|
||||
} else {
|
||||
"Timeline PDU:"
|
||||
};
|
||||
write!(self, "{msg}\n```json\n{text}\n```")
|
||||
},
|
||||
}
|
||||
.await
|
||||
}
|
||||
|
||||
pub(super) async fn fetch_pdu(
|
||||
&self,
|
||||
event_id: OwnedEventId,
|
||||
server: OwnedServerName,
|
||||
) -> Result {
|
||||
let response = self
|
||||
.services
|
||||
.sending
|
||||
.send_federation_request(
|
||||
&server,
|
||||
ruma::api::federation::event::get_event::v1::Request::new(event_id.clone()),
|
||||
)
|
||||
.await?;
|
||||
let (real_event_id, room_id, pdu_json) = self
|
||||
.services
|
||||
.rooms
|
||||
.event_handler
|
||||
.parse_incoming_pdu(&response.pdu, None)
|
||||
.await?;
|
||||
self.write_str(&format!(
|
||||
"Event ID: {real_event_id}\nRoom ID: {room_id}\nPDU:\n```json\n{}\n```",
|
||||
serde_json::to_string_pretty(&pdu_json)?
|
||||
))
|
||||
.await
|
||||
}
|
||||
|
||||
pub(super) async fn first_pdu_in_room(&self, room_id: OwnedRoomId) -> Result {
|
||||
self.bail_restricted()?;
|
||||
|
||||
let first_pdu = self
|
||||
.services
|
||||
.rooms
|
||||
.timeline
|
||||
.first_pdu_in_room(&room_id)
|
||||
.await
|
||||
.map(Event::into_canonical_object)
|
||||
.and_then(|v| serde_json::to_string_pretty(&v).map_err(Into::into))
|
||||
.map_err(|e| err!(Database("Failed to find the first PDU in database: {e:?}")))?;
|
||||
|
||||
let out = format!("```json\n{first_pdu}\n```");
|
||||
self.write_str(&out).await
|
||||
}
|
||||
|
||||
pub(super) async fn latest_pdu_in_room(&self, room_id: OwnedRoomId) -> Result {
|
||||
self.bail_restricted()?;
|
||||
|
||||
let latest_pdu = self
|
||||
.services
|
||||
.rooms
|
||||
.timeline
|
||||
.latest_pdu_in_room(&room_id)
|
||||
.await
|
||||
.map(Event::into_canonical_object)
|
||||
.and_then(|v| serde_json::to_string_pretty(&v).map_err(Into::into))
|
||||
.map_err(|e| err!(Database("Failed to find the latest PDU in database: {e:?}")))?;
|
||||
|
||||
let out = format!("```json\n{latest_pdu}\n```");
|
||||
self.write_str(&out).await
|
||||
}
|
||||
|
||||
pub(super) async fn show_auth_chain(&self, event_id: OwnedEventId) -> Result {
|
||||
// TODO: This command sucks and really needs to elide redundant auth
|
||||
// edges.
|
||||
let node_status = async |event_id: &EventId, missing: bool| -> NodeStatus {
|
||||
if self
|
||||
.services
|
||||
.rooms
|
||||
.pdu_metadata
|
||||
.is_event_rejected(event_id)
|
||||
.await
|
||||
{
|
||||
NodeStatus::Rejected(missing)
|
||||
} else if self
|
||||
.services
|
||||
.rooms
|
||||
.pdu_metadata
|
||||
.is_event_soft_failed(event_id)
|
||||
.await
|
||||
{
|
||||
NodeStatus::SoftFailed(missing)
|
||||
} else {
|
||||
NodeStatus::Normal(missing)
|
||||
}
|
||||
};
|
||||
|
||||
let Ok(root) = self.services.rooms.timeline.get_pdu(&event_id).await else {
|
||||
return Err!("Event not found.");
|
||||
};
|
||||
|
||||
let mut graph = String::from(
|
||||
"```mermaid\n%% This is a mermaid graph. You can plug this output into\n\
|
||||
%% https://mermaid.live/edit to visualise it on-the-fly.\nflowchart TD\n\
|
||||
classDef rejected fill:#ffe5e5,stroke:#cc0000,stroke-width:2px,color:#000;\n\
|
||||
classDef soft_failed fill:#fff6cc,stroke:#c9a400,stroke-width:2px,color:#000;\n"
|
||||
);
|
||||
|
||||
let mut node_ids: HashMap<OwnedEventId, String> = HashMap::new();
|
||||
let mut cached_events: HashMap<OwnedEventId, PduEvent> =
|
||||
HashMap::from([(event_id.clone(), root.clone())]);
|
||||
let mut scheduled: HashSet<OwnedEventId> = HashSet::from([event_id.clone()]);
|
||||
let mut visited: HashSet<OwnedEventId> = HashSet::new();
|
||||
let mut stack = vec![root];
|
||||
let mut next_node_id = 0_usize;
|
||||
|
||||
let node_id_for = |event_id: &OwnedEventId,
|
||||
node_ids: &mut HashMap<OwnedEventId, String>,
|
||||
next_node_id: &mut usize| {
|
||||
node_ids
|
||||
.entry(event_id.clone())
|
||||
.or_insert_with(|| {
|
||||
let id = format!("n{}", *next_node_id);
|
||||
*next_node_id = next_node_id.saturating_add(1);
|
||||
id
|
||||
})
|
||||
.clone()
|
||||
};
|
||||
let node_name = |e: &PduEvent| {
|
||||
if let Some(state_key) = e.state_key() {
|
||||
format!("{},'{}'", e.event_type(), state_key)
|
||||
} else {
|
||||
format!("{}", e.event_type())
|
||||
}
|
||||
};
|
||||
|
||||
while let Some(event) = stack.pop() {
|
||||
let current_event_id = event.event_id().to_owned();
|
||||
if !visited.insert(current_event_id.clone()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let current_node_id =
|
||||
node_id_for(¤t_event_id, &mut node_ids, &mut next_node_id);
|
||||
let current_status = node_status(¤t_event_id, false).await;
|
||||
|
||||
render_node(
|
||||
&mut graph,
|
||||
¤t_node_id,
|
||||
¤t_event_id,
|
||||
&node_name(&event),
|
||||
current_status,
|
||||
)?;
|
||||
|
||||
let mut children = Vec::with_capacity(event.auth_events.len());
|
||||
for auth_event_id in event.auth_events().rev() {
|
||||
let auth_event_id = auth_event_id.to_owned();
|
||||
let auth_node_id = node_id_for(&auth_event_id, &mut node_ids, &mut next_node_id);
|
||||
writeln!(graph, "{current_node_id} --> {auth_node_id}")?;
|
||||
|
||||
let first_seen = scheduled.insert(auth_event_id.clone());
|
||||
let auth_pdu = if let Some(auth_pdu) = cached_events.get(&auth_event_id) {
|
||||
// NOTE: events might be referenced multiple times (like the
|
||||
// create event) so this saves some cheeky db lookup
|
||||
// time
|
||||
Some(auth_pdu.clone())
|
||||
} else if first_seen {
|
||||
match self.services.rooms.timeline.get_pdu(&auth_event_id).await {
|
||||
| Ok(auth_event) => {
|
||||
cached_events.insert(auth_event_id.clone(), auth_event.clone());
|
||||
Some(auth_event)
|
||||
},
|
||||
| Err(_) => None,
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
// NOTE: Depth is used as the primary sorting key here, even
|
||||
// though it has no bearing on state resolution or anything.
|
||||
// Timestamp is used as a tiebreaker, failing back to
|
||||
// lexicographical comparison.
|
||||
let (depth, ts) = auth_pdu
|
||||
.as_ref()
|
||||
.map_or((UInt::MAX, UInt::MAX), |pdu| (pdu.depth, pdu.origin_server_ts));
|
||||
|
||||
children.push(AuthChild {
|
||||
node_id: auth_node_id,
|
||||
event_id: auth_event_id,
|
||||
depth,
|
||||
ts,
|
||||
first_seen,
|
||||
pdu: auth_pdu,
|
||||
});
|
||||
}
|
||||
|
||||
children.sort_by(|a, b| {
|
||||
a.depth
|
||||
.cmp(&b.depth)
|
||||
.then(a.ts.cmp(&b.ts))
|
||||
.then(a.event_id.as_str().cmp(b.event_id.as_str()))
|
||||
});
|
||||
|
||||
for child in children.into_iter().rev() {
|
||||
if !child.first_seen {
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Some(child_pdu) = child.pdu {
|
||||
// We have this PDU so will want to traverse it.
|
||||
stack.push(child_pdu);
|
||||
} else {
|
||||
// We don't have this PDU locally so we can't traverse its
|
||||
// auth events, but we can still render it as a node.
|
||||
render_node(
|
||||
&mut graph,
|
||||
&child.node_id,
|
||||
&child.event_id,
|
||||
"",
|
||||
node_status(&child.event_id, true).await,
|
||||
)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
graph.push_str("```\n");
|
||||
self.write_str(&graph).await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||
enum NodeStatus {
|
||||
Normal(bool),
|
||||
SoftFailed(bool),
|
||||
Rejected(bool),
|
||||
}
|
||||
|
||||
struct AuthChild {
|
||||
node_id: String,
|
||||
event_id: OwnedEventId,
|
||||
depth: UInt,
|
||||
ts: UInt,
|
||||
first_seen: bool,
|
||||
pdu: Option<PduEvent>,
|
||||
}
|
||||
|
||||
fn render_node(
|
||||
graph: &mut String,
|
||||
node_id: &str,
|
||||
event_id: &EventId,
|
||||
name: &str,
|
||||
status: NodeStatus,
|
||||
) -> Result {
|
||||
let evt_str = event_id.to_string();
|
||||
|
||||
let status_label = match status {
|
||||
| NodeStatus::Normal(false) => format!("{evt_str}: {name}"),
|
||||
| NodeStatus::Normal(true) => format!("{evt_str}: {name} (missing locally)"),
|
||||
| NodeStatus::SoftFailed(false) => format!("{evt_str}: {name} (soft-failed)"),
|
||||
| NodeStatus::SoftFailed(true) =>
|
||||
format!("{evt_str}: {name} (soft-failed & missing locally)"),
|
||||
| NodeStatus::Rejected(false) => format!("{evt_str}: {name} (rejected)"),
|
||||
| NodeStatus::Rejected(true) => format!("{evt_str}: {name} (rejected & missing locally)"),
|
||||
};
|
||||
|
||||
writeln!(graph, "{node_id}[\"{}\"]", status_label.as_str())?;
|
||||
|
||||
match status {
|
||||
| NodeStatus::Rejected(_) => writeln!(graph, "class {node_id} rejected;")?,
|
||||
| NodeStatus::SoftFailed(_) => writeln!(graph, "class {node_id} soft_failed;")?,
|
||||
| NodeStatus::Normal(_) => {},
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
use std::hash::RandomState;
|
||||
|
||||
use clap::Subcommand;
|
||||
use conduwuit::{Err, Result, info};
|
||||
use conduwuit_macros::admin_command_dispatch;
|
||||
use futures::StreamExt;
|
||||
use ruma::{OwnedRoomOrAliasId, OwnedServerName, OwnedUserId};
|
||||
|
||||
#[admin_command_dispatch]
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum RoomMembershipCommands {
|
||||
/// Make a local user join a room.
|
||||
#[clap(name = "join")]
|
||||
JoinRoom {
|
||||
/// The user to make join the room. Must be a local user.
|
||||
user_id: OwnedUserId,
|
||||
/// The room (ID or alias) to join.
|
||||
room: OwnedRoomOrAliasId,
|
||||
/// The server to join through, if a remote room.
|
||||
///
|
||||
/// Residents returned after resolving an alias override this option.
|
||||
#[arg(long)]
|
||||
via: Option<OwnedServerName>,
|
||||
},
|
||||
|
||||
/// Makes all local users join the designated room.
|
||||
JoinAllLocalUsers {
|
||||
/// The room (ID or alias) to join.
|
||||
room: OwnedRoomOrAliasId,
|
||||
},
|
||||
|
||||
/// Make a local user leave a room or reject an invite.
|
||||
#[clap(name = "leave", alias = "reject-invite")]
|
||||
LeaveRoom {
|
||||
/// The user to make leave the room. Must be a local user.
|
||||
user_id: OwnedUserId,
|
||||
/// The room (ID or alias) to leave.
|
||||
room: OwnedRoomOrAliasId,
|
||||
/// The server to leave through, if a room we are not a member of (e.g.
|
||||
/// an invite).
|
||||
///
|
||||
/// Residents returned after resolving an alias override this option.
|
||||
#[arg(long)]
|
||||
via: Option<OwnedServerName>,
|
||||
},
|
||||
}
|
||||
|
||||
impl crate::Context<'_> {
|
||||
pub(super) async fn join_room(
|
||||
&self,
|
||||
user_id: OwnedUserId,
|
||||
room: OwnedRoomOrAliasId,
|
||||
via: Option<OwnedServerName>,
|
||||
) -> Result {
|
||||
self.bail_restricted()?;
|
||||
if !self.services.globals.user_is_local(&user_id) {
|
||||
return Err!("User {user_id:?} does not belong to our server.");
|
||||
}
|
||||
let (room_id, residents) = self
|
||||
.services
|
||||
.rooms
|
||||
.alias
|
||||
.resolve_with_servers(&room, via.map(|v| vec![v]))
|
||||
.await?;
|
||||
self.services
|
||||
.rooms
|
||||
.membership
|
||||
.join_room(&user_id, &room_id, None, &residents)
|
||||
.await?;
|
||||
self.write_str(&format!("Successfully joined {room_id} as {user_id}."))
|
||||
.await
|
||||
}
|
||||
|
||||
pub(super) async fn join_all_local_users(&self, room: OwnedRoomOrAliasId) -> Result {
|
||||
self.bail_restricted()?;
|
||||
let (room_id, residents) = self
|
||||
.services
|
||||
.rooms
|
||||
.alias
|
||||
.resolve_with_servers(&room, None)
|
||||
.await?;
|
||||
if !self
|
||||
.services
|
||||
.rooms
|
||||
.state_cache
|
||||
.is_joined(
|
||||
self.sender
|
||||
.expect("This command must be executed by a user"),
|
||||
&room_id,
|
||||
)
|
||||
.await
|
||||
{
|
||||
return Err!("You must be a member of the room you want to join everyone to.");
|
||||
}
|
||||
let mut success = 0_usize;
|
||||
let mut failed = 0_usize;
|
||||
let mut local_users = self.services.users.stream_local_users();
|
||||
while let Some(user_id) = local_users.next().await {
|
||||
if self
|
||||
.services
|
||||
.rooms
|
||||
.membership
|
||||
.join_room(&user_id, &room_id, None, &residents)
|
||||
.await
|
||||
.is_ok()
|
||||
{
|
||||
success = success.saturating_add(1);
|
||||
} else {
|
||||
failed = failed.saturating_add(1);
|
||||
}
|
||||
}
|
||||
self.write_str(&format!("Done: {success} successful joins, {failed} failed."))
|
||||
.await
|
||||
}
|
||||
|
||||
pub(super) async fn leave_room(
|
||||
&self,
|
||||
user_id: OwnedUserId,
|
||||
room: OwnedRoomOrAliasId,
|
||||
via: Option<OwnedServerName>,
|
||||
) -> Result {
|
||||
self.bail_restricted()?;
|
||||
if !self.services.globals.user_is_local(&user_id) {
|
||||
return Err!("User {user_id:?} does not belong to our server.");
|
||||
}
|
||||
let no_explicit_via = via.is_none();
|
||||
let (room_id, residents) = self
|
||||
.services
|
||||
.rooms
|
||||
.alias
|
||||
.resolve_with_servers(&room, via.map(|v| vec![v]))
|
||||
.await?;
|
||||
if no_explicit_via
|
||||
|| self
|
||||
.services
|
||||
.rooms
|
||||
.state_cache
|
||||
.server_in_room(self.services.globals.server_name(), &room_id)
|
||||
.await
|
||||
{
|
||||
if !self
|
||||
.services
|
||||
.rooms
|
||||
.state_cache
|
||||
.is_joined(&user_id, &room_id)
|
||||
.await
|
||||
{
|
||||
return Err!("User {user_id:?} is not a member of room {room_id:?}.");
|
||||
}
|
||||
|
||||
info!("Leaving room locally...");
|
||||
conduwuit_api::client::leave_room(self.services, &user_id, &room_id, None).await?;
|
||||
} else {
|
||||
info!("Leaving room remotely...");
|
||||
conduwuit_api::client::remote_leave_room::<RandomState>(
|
||||
self.services,
|
||||
&user_id,
|
||||
&room_id,
|
||||
None,
|
||||
residents.into_iter().collect(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
self.write_str(&format!("Successfully made {user_id} leave {room_id}."))
|
||||
.await
|
||||
}
|
||||
}
|
||||
+22
-6
@@ -1,16 +1,20 @@
|
||||
mod alias;
|
||||
mod commands;
|
||||
mod directory;
|
||||
mod graph;
|
||||
mod info;
|
||||
mod membership;
|
||||
mod moderation;
|
||||
mod state;
|
||||
|
||||
use clap::Subcommand;
|
||||
use conduwuit::Result;
|
||||
use ruma::OwnedRoomId;
|
||||
|
||||
use self::{
|
||||
alias::RoomAliasCommand, directory::RoomDirectoryCommand, info::RoomInfoCommand,
|
||||
moderation::RoomModerationCommand,
|
||||
alias::RoomAliasCommand, directory::RoomDirectoryCommand, graph::GraphCommand,
|
||||
info::RoomInfoCommand, membership::RoomMembershipCommands, moderation::RoomModerationCommand,
|
||||
state::RoomStateCommand,
|
||||
};
|
||||
use crate::admin_command_dispatch;
|
||||
|
||||
@@ -40,22 +44,34 @@ pub enum RoomCommand {
|
||||
no_details: bool,
|
||||
},
|
||||
|
||||
#[command(subcommand)]
|
||||
/// View information about a room we know about
|
||||
#[command(subcommand)]
|
||||
Info(RoomInfoCommand),
|
||||
|
||||
#[command(subcommand)]
|
||||
/// Manage moderation of remote or local rooms
|
||||
#[command(subcommand)]
|
||||
Moderation(RoomModerationCommand),
|
||||
|
||||
#[command(subcommand)]
|
||||
/// Manage rooms' aliases
|
||||
#[command(subcommand)]
|
||||
Alias(RoomAliasCommand),
|
||||
|
||||
#[command(subcommand)]
|
||||
/// Manage the room directory
|
||||
#[command(subcommand)]
|
||||
Directory(RoomDirectoryCommand),
|
||||
|
||||
/// Manage room memberships (join, leave, invite, etc.) for local users.
|
||||
#[command(subcommand)]
|
||||
Membership(RoomMembershipCommands),
|
||||
|
||||
/// Interface with room graphs directly (advanced).
|
||||
#[command(subcommand)]
|
||||
Graph(GraphCommand),
|
||||
|
||||
/// Interface with room state directly (advanced).
|
||||
#[command(subcommand)]
|
||||
State(RoomStateCommand),
|
||||
|
||||
/// Check if we know about a room
|
||||
Exists {
|
||||
room_id: OwnedRoomId,
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use clap::Subcommand;
|
||||
use conduwuit::{Err, Event, PduEvent, Result, debug_error, err, info, warn};
|
||||
use conduwuit_macros::admin_command_dispatch;
|
||||
use futures::StreamExt;
|
||||
#[allow(unused_imports)]
|
||||
// necessary to stop RustRover from importing this trait for some reason
|
||||
use ruma::state_res::Event as _;
|
||||
use ruma::{
|
||||
OwnedEventId, OwnedRoomOrAliasId, OwnedServerName, api::federation::event::get_room_state,
|
||||
};
|
||||
use service::rooms::state_compressor::HashSetCompressStateEvent;
|
||||
|
||||
#[admin_command_dispatch]
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum RoomStateCommand {
|
||||
/// Exports the room's current state as a JSON file.
|
||||
/// If an event ID is supplied, the state at that event (the state preceding
|
||||
/// it, plus any change made by the named event) is returned instead, if it
|
||||
/// is known.
|
||||
#[clap(name = "export")]
|
||||
ExportState {
|
||||
/// The room ID or alias to get the state for.
|
||||
room: OwnedRoomOrAliasId,
|
||||
/// The event ID to get the state at, if any.
|
||||
event_id: Option<OwnedEventId>,
|
||||
},
|
||||
|
||||
/// Downloads the current state of a room from a remote server, and replaces
|
||||
/// the local copy of the room's state with it.
|
||||
///
|
||||
/// If you're reading this, this command does not do what you think it does.
|
||||
Transplant {
|
||||
/// The room ID or alias to replace the current state of.
|
||||
room: OwnedRoomOrAliasId,
|
||||
/// The server name to fetch the state from. Make sure this is a trusted
|
||||
/// server, as the result will be implicitly trusted.
|
||||
server_name: OwnedServerName,
|
||||
/// The latest event ID in the room to use as the "latest event".
|
||||
/// Calculated by default.
|
||||
at_event: Option<OwnedEventId>,
|
||||
/// Try to force the state even if the server thinks it isn't in the
|
||||
/// target room.
|
||||
///
|
||||
/// Using this on rooms the server has never joined may break
|
||||
/// everything.
|
||||
#[arg(long)]
|
||||
force: bool,
|
||||
// (the "may break everything" part isn't necessarily true, but it is highly likely that
|
||||
// things will actually break in an unrecoverable way, so being dramatic gets the main
|
||||
// point across)
|
||||
},
|
||||
}
|
||||
|
||||
impl crate::Context<'_> {
|
||||
pub(super) async fn export_state(
|
||||
&self,
|
||||
room: OwnedRoomOrAliasId,
|
||||
event_id: Option<OwnedEventId>,
|
||||
) -> Result {
|
||||
self.bail_restricted()?;
|
||||
|
||||
let room_id = self.services.rooms.alias.resolve(&room).await?;
|
||||
let shortstatehash = match &event_id {
|
||||
| Some(event_id) =>
|
||||
self.services
|
||||
.rooms
|
||||
.state_accessor
|
||||
.pdu_shortstatehash(event_id)
|
||||
.await?,
|
||||
| None =>
|
||||
self.services
|
||||
.rooms
|
||||
.state
|
||||
.get_room_shortstatehash(&room_id)
|
||||
.await?,
|
||||
};
|
||||
let mut state_at: Vec<_> = self
|
||||
.services
|
||||
.rooms
|
||||
.state_accessor
|
||||
.state_full_pdus(shortstatehash)
|
||||
.map(Event::into_pdu)
|
||||
.collect()
|
||||
.await;
|
||||
|
||||
if let Some(event_id) = event_id {
|
||||
let pdu = self.services.rooms.timeline.get_pdu(&event_id).await?;
|
||||
if let Some(state_key) = pdu.state_key() {
|
||||
state_at.retain(|p| p.kind() != pdu.kind() || p.state_key() != Some(state_key));
|
||||
state_at.push(pdu);
|
||||
}
|
||||
}
|
||||
|
||||
if state_at.is_empty() {
|
||||
return Err!(Request(NotFound("No state found.")));
|
||||
}
|
||||
|
||||
let json = serde_json::to_string_pretty(&state_at).map_err(|e| {
|
||||
err!(Database(
|
||||
"Failed to convert room state events to pretty JSON, possible invalid room \
|
||||
state events in the database: {e:?}",
|
||||
))
|
||||
})?;
|
||||
|
||||
self.write_str(&format!("```json\n{json}\n```")).await
|
||||
}
|
||||
|
||||
pub(super) async fn transplant(
|
||||
&self,
|
||||
room: OwnedRoomOrAliasId,
|
||||
server_name: OwnedServerName,
|
||||
latest_event: Option<OwnedEventId>,
|
||||
force: bool,
|
||||
) -> Result {
|
||||
self.bail_restricted()?;
|
||||
let room_id = self.services.rooms.alias.resolve(&room).await?;
|
||||
|
||||
if !force
|
||||
&& !self
|
||||
.services
|
||||
.rooms
|
||||
.state_cache
|
||||
.server_in_room(&self.services.server.name, &room_id)
|
||||
.await
|
||||
{
|
||||
return Err!(
|
||||
"We are not participating in the room / we don't know about the room ID."
|
||||
);
|
||||
}
|
||||
|
||||
let at_event_id = match latest_event {
|
||||
| Some(event_id) => event_id,
|
||||
| None => self
|
||||
.services
|
||||
.rooms
|
||||
.timeline
|
||||
.latest_pdu_in_room(&room_id)
|
||||
.await
|
||||
.map_err(|_| err!(Database("Failed to find the latest PDU in database")))?
|
||||
.event_id()
|
||||
.to_owned(),
|
||||
};
|
||||
|
||||
let room_version = self.services.rooms.state.get_room_version(&room_id).await?;
|
||||
let room_version_rules = room_version.rules().unwrap();
|
||||
|
||||
let mut state: HashMap<u64, OwnedEventId> = HashMap::new();
|
||||
|
||||
let state_lock = self.services.rooms.state.mutex.lock(&*room_id).await;
|
||||
|
||||
// TODO: Use /state_ids and fetch events we're missing atomically,
|
||||
// instead of /state, which is very large and frequently times out.
|
||||
let remote_state_response = self
|
||||
.services
|
||||
.sending
|
||||
.send_federation_request(
|
||||
&server_name,
|
||||
get_room_state::v1::Request::new(at_event_id.clone(), room_id.clone()),
|
||||
)
|
||||
.await?;
|
||||
|
||||
for pdu in remote_state_response.pdus.clone() {
|
||||
match self
|
||||
.services
|
||||
.rooms
|
||||
.event_handler
|
||||
.parse_incoming_pdu(&pdu, Some(&room_version_rules))
|
||||
.await
|
||||
{
|
||||
| Ok(t) => t,
|
||||
| Err(e) => {
|
||||
warn!("Could not parse PDU, ignoring: {e}");
|
||||
continue;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
info!("Going through room_state response PDUs");
|
||||
for result in remote_state_response.pdus.iter().map(|pdu| {
|
||||
self.services
|
||||
.server_keys
|
||||
.verify_event_json_no_fetch_add_event_id(pdu, &room_version_rules)
|
||||
}) {
|
||||
let Ok((event_id, value)) = result.await else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let pdu = PduEvent::from_id_val(&event_id, value.clone()).map_err(|e| {
|
||||
debug_error!(
|
||||
"Invalid PDU in fetching remote room state PDUs response: {value:#?}"
|
||||
);
|
||||
err!(BadServerResponse(debug_error!("Invalid PDU in send_join response: {e:?}")))
|
||||
})?;
|
||||
|
||||
self.services
|
||||
.rooms
|
||||
.outlier
|
||||
.add_pdu_outlier(&event_id, &value);
|
||||
|
||||
if let Some(state_key) = &pdu.state_key {
|
||||
let shortstatekey = self
|
||||
.services
|
||||
.rooms
|
||||
.short
|
||||
.get_or_create_shortstatekey(&pdu.kind.to_string().into(), state_key)
|
||||
.await;
|
||||
|
||||
state.insert(shortstatekey, pdu.event_id.clone());
|
||||
self.services
|
||||
.rooms
|
||||
.pdu_metadata
|
||||
.clear_pdu_markers(pdu.event_id());
|
||||
}
|
||||
}
|
||||
|
||||
info!("Going through auth_chain response");
|
||||
for result in remote_state_response.auth_chain.iter().map(|pdu| {
|
||||
self.services
|
||||
.server_keys
|
||||
.verify_event_json_no_fetch_add_event_id(pdu, &room_version_rules)
|
||||
}) {
|
||||
let Ok((event_id, value)) = result.await else {
|
||||
continue;
|
||||
};
|
||||
|
||||
self.services
|
||||
.rooms
|
||||
.outlier
|
||||
.add_pdu_outlier(&event_id, &value);
|
||||
self.services
|
||||
.rooms
|
||||
.pdu_metadata
|
||||
.clear_pdu_markers(&event_id);
|
||||
}
|
||||
|
||||
info!("Resolving new room state");
|
||||
let new_room_state = self
|
||||
.services
|
||||
.rooms
|
||||
.event_handler
|
||||
.resolve_state(&room_id, &room_version_rules, state)
|
||||
.await?;
|
||||
|
||||
info!("Compressing new room state");
|
||||
let HashSetCompressStateEvent {
|
||||
shortstatehash: short_state_hash,
|
||||
added,
|
||||
removed,
|
||||
} = self
|
||||
.services
|
||||
.rooms
|
||||
.state_compressor
|
||||
.save_state(room_id.clone().as_ref(), new_room_state)
|
||||
.await?;
|
||||
|
||||
info!("Forcing new room state");
|
||||
self.services
|
||||
.rooms
|
||||
.state
|
||||
.force_state(room_id.clone().as_ref(), short_state_hash, added, removed, &state_lock)
|
||||
.await?;
|
||||
|
||||
info!("Replacing forward extremities");
|
||||
self.services
|
||||
.rooms
|
||||
.state
|
||||
.replace_forward_extremities(
|
||||
&room_id,
|
||||
std::iter::once(at_event_id.as_ref()),
|
||||
&state_lock,
|
||||
)
|
||||
.await;
|
||||
|
||||
info!("Updating joined counts for room");
|
||||
self.services
|
||||
.rooms
|
||||
.state_cache
|
||||
.update_joined_count(&room_id)
|
||||
.await;
|
||||
|
||||
self.write_str("Successfully forced the room state from the requested remote server.")
|
||||
.await
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
use std::{fmt::Write, path::PathBuf, sync::Arc};
|
||||
|
||||
use conduwuit::{
|
||||
Err, Result,
|
||||
Err, Result, err,
|
||||
utils::{stream::IterStream, time},
|
||||
warn,
|
||||
};
|
||||
use futures::TryStreamExt;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
impl crate::Context<'_> {
|
||||
pub(super) async fn uptime(&self) -> Result {
|
||||
@@ -234,4 +235,37 @@ impl crate::Context<'_> {
|
||||
|
||||
self.write_str(&info).await
|
||||
}
|
||||
|
||||
pub(super) async fn change_log_level(&self, filter: Option<String>, reset: bool) -> Result {
|
||||
let handles = &["console"];
|
||||
|
||||
if reset {
|
||||
let old_filter_layer = EnvFilter::try_new(&self.services.server.config.log)
|
||||
.map_err(|e| err!("Log level from config appears to be invalid now: {e}"))?;
|
||||
self.services
|
||||
.server
|
||||
.log
|
||||
.reload
|
||||
.reload(&old_filter_layer, Some(handles))
|
||||
.map_err(|e| {
|
||||
err!("Failed to modify and reload the global tracing log level: {e}")
|
||||
})?;
|
||||
self.write_str("Successfully changed log level back to config value")
|
||||
.await
|
||||
} else {
|
||||
let filter = filter.ok_or_else(|| err!("No log level was specified."))?;
|
||||
let new_filter_layer = EnvFilter::try_new(filter)
|
||||
.map_err(|e| err!("Invalid log level filter specified: {e}"))?;
|
||||
self.services
|
||||
.server
|
||||
.log
|
||||
.reload
|
||||
.reload(&new_filter_layer, Some(handles))
|
||||
.map_err(|e| {
|
||||
err!("Failed to modify and reload the global tracing log level: {e}")
|
||||
})?;
|
||||
self.write_str("Successfully changed log level back to config value")
|
||||
.await
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,4 +58,16 @@ pub enum ServerCommand {
|
||||
|
||||
/// Build information
|
||||
BuildInfo,
|
||||
|
||||
/// Change tracing log level/filter on the fly
|
||||
///
|
||||
/// This accepts the same format as the `log` config option.
|
||||
ChangeLogLevel {
|
||||
/// Log level/filter
|
||||
filter: Option<String>,
|
||||
|
||||
/// Resets the log level/filter to the one in your config
|
||||
#[arg(short, long)]
|
||||
reset: bool,
|
||||
},
|
||||
}
|
||||
+5
-315
@@ -1,19 +1,16 @@
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use api::client::{
|
||||
full_user_deactivate, leave_room, recreate_push_rules_and_return, remote_leave_room,
|
||||
};
|
||||
use api::client::{full_user_deactivate, leave_room, recreate_push_rules_and_return};
|
||||
use conduwuit::{
|
||||
Err, Result, debug_warn, info,
|
||||
Err, Result, info,
|
||||
matrix::{Event, pdu::PartialPdu},
|
||||
utils::{self, ReadyExt},
|
||||
utils::{self},
|
||||
warn,
|
||||
};
|
||||
use futures::{FutureExt, StreamExt};
|
||||
use lettre::Address;
|
||||
use ruma::{
|
||||
OwnedEventId, OwnedRoomId, OwnedRoomOrAliasId, OwnedServerName, OwnedUserId, ServerName,
|
||||
UserId, assign,
|
||||
OwnedEventId, OwnedRoomId, OwnedRoomOrAliasId, OwnedUserId, UserId, assign,
|
||||
events::{
|
||||
RoomAccountDataEventType,
|
||||
room::{power_levels::RoomPowerLevelsEventContent, redaction::RoomRedactionEventContent},
|
||||
@@ -28,7 +25,6 @@ use crate::{
|
||||
};
|
||||
|
||||
const AUTO_GEN_PASSWORD_LENGTH: usize = 25;
|
||||
const BULK_JOIN_REASON: &str = "Bulk force joining this room as initiated by the server admin.";
|
||||
|
||||
impl crate::Context<'_> {
|
||||
pub(super) async fn list_users(
|
||||
@@ -464,272 +460,6 @@ impl crate::Context<'_> {
|
||||
.await
|
||||
}
|
||||
|
||||
pub(super) async fn force_join_list_of_local_users(
|
||||
&self,
|
||||
room_id: OwnedRoomOrAliasId,
|
||||
yes_i_want_to_do_this: bool,
|
||||
) -> Result {
|
||||
if self.body.len() < 2
|
||||
|| !self.body[0].trim().starts_with("```")
|
||||
|| self.body.last().unwrap_or(&"").trim() != "```"
|
||||
{
|
||||
return Err!("Expected code block in command body. Add --help for details.",);
|
||||
}
|
||||
|
||||
if !yes_i_want_to_do_this {
|
||||
return Err!(
|
||||
"You must pass the --yes-i-want-to-do-this-flag to ensure you really want to \
|
||||
force bulk join all specified local users.",
|
||||
);
|
||||
}
|
||||
|
||||
let server_admins = self.services.admin.get_admins().await;
|
||||
|
||||
if server_admins.is_empty() {
|
||||
return Err!("There are no admins set for this server.");
|
||||
}
|
||||
|
||||
let (room_id, servers) = self
|
||||
.services
|
||||
.rooms
|
||||
.alias
|
||||
.resolve_with_servers(&room_id, None)
|
||||
.await?;
|
||||
|
||||
if !self
|
||||
.services
|
||||
.rooms
|
||||
.state_cache
|
||||
.server_in_room(self.services.globals.server_name(), &room_id)
|
||||
.await
|
||||
{
|
||||
return Err!("We are not joined in this room.");
|
||||
}
|
||||
|
||||
if !self
|
||||
.services
|
||||
.rooms
|
||||
.state_cache
|
||||
.room_members(&room_id)
|
||||
.ready_any(|user_id| server_admins.contains(&user_id))
|
||||
.await
|
||||
{
|
||||
return Err!("There is not a single server admin in the room.",);
|
||||
}
|
||||
|
||||
let usernames = self
|
||||
.body
|
||||
.to_vec()
|
||||
.drain(1..self.body.len().saturating_sub(1))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let mut user_ids: Vec<OwnedUserId> = Vec::with_capacity(usernames.len());
|
||||
|
||||
for username in usernames {
|
||||
match parse_active_local_user_id(self.services, username).await {
|
||||
| Ok(user_id) => {
|
||||
// don't make the server service account join
|
||||
if user_id == self.services.globals.server_user {
|
||||
self.services
|
||||
.admin
|
||||
.send_text(&format!(
|
||||
"{username} is the server service account, skipping over"
|
||||
))
|
||||
.await;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
user_ids.push(user_id);
|
||||
},
|
||||
| Err(e) => {
|
||||
self.services
|
||||
.admin
|
||||
.send_text(&format!(
|
||||
"{username} is not a valid username, skipping over: {e}"
|
||||
))
|
||||
.await;
|
||||
|
||||
continue;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
let mut failed_joins: usize = 0;
|
||||
let mut successful_joins: usize = 0;
|
||||
|
||||
for user_id in user_ids {
|
||||
match self
|
||||
.services
|
||||
.rooms
|
||||
.membership
|
||||
.join_room(&user_id, &room_id, Some(String::from(BULK_JOIN_REASON)), &servers)
|
||||
.await
|
||||
{
|
||||
| Ok(_res) => {
|
||||
successful_joins = successful_joins.saturating_add(1);
|
||||
},
|
||||
| Err(e) => {
|
||||
debug_warn!(
|
||||
"Failed force joining {user_id} to {room_id} during bulk join: {e}"
|
||||
);
|
||||
failed_joins = failed_joins.saturating_add(1);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
self.write_str(&format!(
|
||||
"{successful_joins} local users have been joined to {room_id}. {failed_joins} joins \
|
||||
failed.",
|
||||
))
|
||||
.await
|
||||
}
|
||||
|
||||
pub(super) async fn force_join_all_local_users(
|
||||
&self,
|
||||
room_id: OwnedRoomOrAliasId,
|
||||
yes_i_want_to_do_this: bool,
|
||||
) -> Result {
|
||||
if !yes_i_want_to_do_this {
|
||||
return Err!(
|
||||
"You must pass the --yes-i-want-to-do-this-flag to ensure you really want to \
|
||||
force bulk join all local users.",
|
||||
);
|
||||
}
|
||||
|
||||
let server_admins = self.services.admin.get_admins().await;
|
||||
|
||||
if server_admins.is_empty() {
|
||||
return Err!("There are no admins set for this server.");
|
||||
}
|
||||
|
||||
let (room_id, servers) = self
|
||||
.services
|
||||
.rooms
|
||||
.alias
|
||||
.resolve_with_servers(&room_id, None)
|
||||
.await?;
|
||||
|
||||
if !self
|
||||
.services
|
||||
.rooms
|
||||
.state_cache
|
||||
.server_in_room(self.services.globals.server_name(), &room_id)
|
||||
.await
|
||||
{
|
||||
return Err!("We are not joined in this room.");
|
||||
}
|
||||
|
||||
if !self
|
||||
.services
|
||||
.rooms
|
||||
.state_cache
|
||||
.room_members(&room_id)
|
||||
.ready_any(|user_id| server_admins.contains(&user_id))
|
||||
.await
|
||||
{
|
||||
return Err!("There is not a single server admin in the room.",);
|
||||
}
|
||||
|
||||
let mut failed_joins: usize = 0;
|
||||
let mut successful_joins: usize = 0;
|
||||
|
||||
for user_id in &self
|
||||
.services
|
||||
.users
|
||||
.stream_local_users()
|
||||
.collect::<Vec<_>>()
|
||||
.await
|
||||
{
|
||||
match self
|
||||
.services
|
||||
.rooms
|
||||
.membership
|
||||
.join_room(user_id, &room_id, Some(String::from(BULK_JOIN_REASON)), &servers)
|
||||
.await
|
||||
{
|
||||
| Ok(_res) => {
|
||||
successful_joins = successful_joins.saturating_add(1);
|
||||
},
|
||||
| Err(e) => {
|
||||
debug_warn!(
|
||||
"Failed force joining {user_id} to {room_id} during bulk join: {e}"
|
||||
);
|
||||
failed_joins = failed_joins.saturating_add(1);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
self.write_str(&format!(
|
||||
"{successful_joins} local users have been joined to {room_id}. {failed_joins} joins \
|
||||
failed.",
|
||||
))
|
||||
.await
|
||||
}
|
||||
|
||||
pub(super) async fn force_join_room(
|
||||
&self,
|
||||
user_id: String,
|
||||
room_id: OwnedRoomOrAliasId,
|
||||
via: Option<String>,
|
||||
) -> Result {
|
||||
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||
let (room_id, mut servers) = self
|
||||
.services
|
||||
.rooms
|
||||
.alias
|
||||
.resolve_with_servers(&room_id, None)
|
||||
.await?;
|
||||
if let Some(via) = via.map(ServerName::parse).transpose()? {
|
||||
servers.retain(|n| *n != via);
|
||||
servers.insert(0, via);
|
||||
}
|
||||
|
||||
assert!(
|
||||
self.services.globals.user_is_local(&user_id),
|
||||
"Parsed user_id must be a local user"
|
||||
);
|
||||
self.services
|
||||
.rooms
|
||||
.membership
|
||||
.join_room(&user_id, &room_id, None, &servers)
|
||||
.await?;
|
||||
|
||||
self.write_str(&format!("{user_id} has been joined to {room_id}."))
|
||||
.await
|
||||
}
|
||||
|
||||
pub(super) async fn force_leave_room(
|
||||
&self,
|
||||
user_id: String,
|
||||
room_id: OwnedRoomOrAliasId,
|
||||
) -> Result {
|
||||
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||
let room_id = self.services.rooms.alias.resolve(&room_id).await?;
|
||||
|
||||
assert!(
|
||||
self.services.globals.user_is_local(&user_id),
|
||||
"Parsed user_id must be a local user"
|
||||
);
|
||||
|
||||
if !self
|
||||
.services
|
||||
.rooms
|
||||
.state_cache
|
||||
.is_joined(&user_id, &room_id)
|
||||
.await
|
||||
{
|
||||
return Err!("{user_id} is not joined in the room");
|
||||
}
|
||||
|
||||
leave_room(self.services, &user_id, &room_id, None)
|
||||
.boxed()
|
||||
.await?;
|
||||
|
||||
self.write_str(&format!("{user_id} has left {room_id}."))
|
||||
.await
|
||||
}
|
||||
|
||||
pub(super) async fn force_demote(
|
||||
&self,
|
||||
user_id: String,
|
||||
@@ -943,46 +673,6 @@ impl crate::Context<'_> {
|
||||
.await
|
||||
}
|
||||
|
||||
pub(super) async fn force_leave_remote_room(
|
||||
&self,
|
||||
user_id: String,
|
||||
room_id: OwnedRoomOrAliasId,
|
||||
via: Option<String>,
|
||||
) -> Result {
|
||||
let user_id = parse_local_user_id(self.services, &user_id)?;
|
||||
let (room_id, vias_raw) = self
|
||||
.services
|
||||
.rooms
|
||||
.alias
|
||||
.resolve_with_servers(
|
||||
&room_id,
|
||||
if let Some(v) = via.clone() {
|
||||
Some(vec![ServerName::parse(v)?])
|
||||
} else {
|
||||
None
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
assert!(
|
||||
self.services.globals.user_is_local(&user_id),
|
||||
"Parsed user_id must be a local user"
|
||||
);
|
||||
let mut vias: HashSet<OwnedServerName> = HashSet::new();
|
||||
if let Some(via) = via {
|
||||
vias.insert(ServerName::parse(via)?);
|
||||
}
|
||||
for server in vias_raw {
|
||||
vias.insert(server);
|
||||
}
|
||||
remote_leave_room(self.services, &user_id, &room_id, None, vias)
|
||||
.boxed()
|
||||
.await?;
|
||||
|
||||
self.write_str(&format!("{user_id} successfully left {room_id} via remote server."))
|
||||
.await
|
||||
}
|
||||
|
||||
pub(super) async fn lock(&self, user_id: String) -> Result {
|
||||
let user_id = parse_active_local_user_id(self.services, &user_id).await?;
|
||||
|
||||
|
||||
@@ -193,32 +193,6 @@ pub enum UserCommand {
|
||||
user_id: String,
|
||||
},
|
||||
|
||||
/// Manually join a local user to a room.
|
||||
ForceJoinRoom {
|
||||
/// The user to join
|
||||
user_id: String,
|
||||
/// The room to join
|
||||
room_id: OwnedRoomOrAliasId,
|
||||
/// The server name to join via.
|
||||
///
|
||||
/// This server will always be tried first, however if more are
|
||||
/// available, they may be tried after.
|
||||
via: Option<String>,
|
||||
},
|
||||
|
||||
/// Manually leave a local user from a room.
|
||||
ForceLeaveRoom {
|
||||
user_id: String,
|
||||
room_id: OwnedRoomOrAliasId,
|
||||
},
|
||||
|
||||
/// Manually leave a remote room for a local user.
|
||||
ForceLeaveRemoteRoom {
|
||||
user_id: String,
|
||||
room_id: OwnedRoomOrAliasId,
|
||||
via: Option<String>,
|
||||
},
|
||||
|
||||
/// Forces the specified user to drop their power levels to the room
|
||||
/// default, if their permissions allow and the auth check permits
|
||||
ForceDemote {
|
||||
@@ -265,33 +239,6 @@ pub enum UserCommand {
|
||||
event_id: OwnedEventId,
|
||||
},
|
||||
|
||||
/// Force joins a specified list of local users to join the specified
|
||||
/// room.
|
||||
///
|
||||
/// Specify a codeblock of usernames.
|
||||
///
|
||||
/// At least 1 server admin must be in the room to reduce abuse.
|
||||
///
|
||||
/// Requires the `--yes-i-want-to-do-this` flag.
|
||||
ForceJoinListOfLocalUsers {
|
||||
room_id: OwnedRoomOrAliasId,
|
||||
|
||||
#[arg(long)]
|
||||
yes_i_want_to_do_this: bool,
|
||||
},
|
||||
|
||||
/// Force joins all local users to the specified room.
|
||||
///
|
||||
/// At least 1 server admin must be in the room to reduce abuse.
|
||||
///
|
||||
/// Requires the `--yes-i-want-to-do-this` flag.
|
||||
ForceJoinAllLocalUsers {
|
||||
room_id: OwnedRoomOrAliasId,
|
||||
|
||||
#[arg(long)]
|
||||
yes_i_want_to_do_this: bool,
|
||||
},
|
||||
|
||||
/// Resets the push-rules (notification settings) of the target user to the
|
||||
/// server defaults.
|
||||
ResetPushRules {
|
||||
|
||||
@@ -51,6 +51,8 @@ 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",
|
||||
]
|
||||
@@ -78,6 +80,7 @@ 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
|
||||
|
||||
@@ -117,13 +117,10 @@ async fn set_account_data(
|
||||
data: &RawJsonValue,
|
||||
) -> Result {
|
||||
if event_type_s == "m.fully_read" {
|
||||
return Err!(Request(
|
||||
BadJson(
|
||||
"This endpoint cannot be used for marking a room as fully read (setting \
|
||||
m.fully_read)"
|
||||
),
|
||||
METHOD_NOT_ALLOWED
|
||||
));
|
||||
return Err!(Request(BadJson(
|
||||
"This endpoint cannot be used for marking a room as fully read (setting \
|
||||
m.fully_read)"
|
||||
)));
|
||||
}
|
||||
|
||||
let data: serde_json::Value = serde_json::from_str(data.get())
|
||||
|
||||
@@ -46,8 +46,7 @@ pub(crate) async fn get_capabilities_route(
|
||||
capabilities.get_login_token =
|
||||
GetLoginTokenCapability::new(services.server.config.login_via_existing_session);
|
||||
|
||||
capabilities.forget_forced_upon_leave.enabled =
|
||||
services.server.config.forget_forced_upon_leave;
|
||||
capabilities.forget_forced_upon_leave.enabled = true;
|
||||
|
||||
if services.users.is_admin(sender_user).await {
|
||||
capabilities.account_moderation.lock = true;
|
||||
|
||||
+3
-18
@@ -523,22 +523,7 @@ where
|
||||
for (server, response) in futures {
|
||||
match response {
|
||||
| Ok(response) => {
|
||||
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 {
|
||||
for (user, master_key) in response.master_keys {
|
||||
let (master_key_id, mut master_key) = parse_master_key(&user, &master_key)?;
|
||||
|
||||
if let Ok(our_master_key) = services
|
||||
@@ -564,8 +549,8 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
self_signing_keys.extend(filtered_self_signing_keys);
|
||||
device_keys.extend(filtered_device_keys);
|
||||
self_signing_keys.extend(response.self_signing_keys);
|
||||
device_keys.extend(response.device_keys);
|
||||
},
|
||||
| Err(e) => {
|
||||
failures.insert(server.to_string(), json!({ "error": e.to_string() }));
|
||||
|
||||
@@ -214,7 +214,7 @@ pub async fn leave_room(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn remote_leave_room<S: ::std::hash::BuildHasher>(
|
||||
pub async fn remote_leave_room<S: std::hash::BuildHasher>(
|
||||
services: &Services,
|
||||
user_id: &UserId,
|
||||
room_id: &RoomId,
|
||||
|
||||
+21
-18
@@ -22,7 +22,7 @@ use conduwuit_service::{
|
||||
};
|
||||
use futures::{FutureExt, StreamExt, TryFutureExt, future::OptionFuture, pin_mut};
|
||||
use ruma::{
|
||||
EventId, RoomId, UserId,
|
||||
RoomId, UserId,
|
||||
api::{
|
||||
Direction,
|
||||
client::{filter::RoomEventFilter, message::get_message_events},
|
||||
@@ -30,9 +30,8 @@ use ruma::{
|
||||
},
|
||||
assign,
|
||||
events::{
|
||||
AnyStateEvent, StateEventType, SyncEphemeralRoomEvent,
|
||||
AnyStateEvent, StateEventType,
|
||||
TimelineEventType::{self, *},
|
||||
receipt::ReceiptEventContent,
|
||||
},
|
||||
serde::Raw,
|
||||
};
|
||||
@@ -210,32 +209,36 @@ pub(crate) async fn lazy_loading_witness<'a, I>(
|
||||
where
|
||||
I: Iterator<Item = &'a PdusIterItem> + Clone + Send,
|
||||
{
|
||||
let chunk_event_ids: std::collections::HashSet<&EventId> =
|
||||
events.clone().map(|(_, event)| event.event_id()).collect();
|
||||
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 receipts = services
|
||||
.rooms
|
||||
.read_receipt
|
||||
.readreceipts_since(lazy_loading_context.room_id, None);
|
||||
.readreceipts_since(lazy_loading_context.room_id, Some(oldest.into_unsigned()));
|
||||
|
||||
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(receipt_users)
|
||||
.chain(
|
||||
receipts
|
||||
.ready_take_while(|(_, c, _)| *c <= newest.into_unsigned())
|
||||
.map(|(user_id, ..)| user_id),
|
||||
)
|
||||
.collect()
|
||||
.await;
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use axum::extract::State;
|
||||
use conduwuit::{Err, Result, err};
|
||||
use conduwuit::{Err, PduCount, 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, ReceiptThread, ReceiptType},
|
||||
receipt::{Receipt, ReceiptEvent, ReceiptEventContent, ReceiptType},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -27,15 +27,6 @@ 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()));
|
||||
|
||||
@@ -101,8 +92,13 @@ pub(crate) async fn set_read_marker_route(
|
||||
.timeline
|
||||
.get_pdu_count(event)
|
||||
.await
|
||||
.map_err(|_| err!(Request(NotFound("Event not found."))))?
|
||||
.into_unsigned();
|
||||
.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."
|
||||
)));
|
||||
};
|
||||
|
||||
services
|
||||
.rooms
|
||||
@@ -126,26 +122,11 @@ 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
|
||||
@@ -178,41 +159,44 @@ pub(crate) async fn create_receipt_route(
|
||||
)
|
||||
.await?;
|
||||
},
|
||||
| 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(),
|
||||
| create_receipt::v3::ReceiptType::Read => {
|
||||
let receipt_content = [(
|
||||
body.event_id.clone(),
|
||||
BTreeMap::from_iter([(
|
||||
ReceiptType::Read,
|
||||
BTreeMap::from_iter([(
|
||||
ReceiptType::Read,
|
||||
BTreeMap::from_iter([(sender_user.to_owned(), receipt)]),
|
||||
sender_user.to_owned(),
|
||||
Receipt::new(MilliSecondsSinceUnixEpoch::now()),
|
||||
)]),
|
||||
)];
|
||||
)]),
|
||||
)];
|
||||
|
||||
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."))))?
|
||||
.into_unsigned();
|
||||
.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."
|
||||
)));
|
||||
};
|
||||
|
||||
services
|
||||
.rooms
|
||||
|
||||
+38
-46
@@ -2,7 +2,7 @@ use axum::extract::State;
|
||||
use conduwuit::{
|
||||
Err, Result, at, debug_warn, err,
|
||||
matrix::{Event, event::RelationTypeEqual, pdu::PduCount},
|
||||
utils::{IterStream, result::FlatOk, stream::WidebandExt},
|
||||
utils::{IterStream, ReadyExt, result::FlatOk, stream::WidebandExt},
|
||||
};
|
||||
use conduwuit_service::Services;
|
||||
use futures::StreamExt;
|
||||
@@ -98,10 +98,6 @@ 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,
|
||||
@@ -151,49 +147,28 @@ async fn paginate_relations_with_filter(
|
||||
.unwrap_or(30)
|
||||
.min(100);
|
||||
|
||||
let max_depth = if recurse { LEVELS_BELOW } else { 0 };
|
||||
// Spec (v1.10) recommends depth of at least 3
|
||||
let depth: u8 = if recurse { 3 } else { 1 };
|
||||
|
||||
// One more than the limit, to know whether there's another page
|
||||
let mut events = services
|
||||
let events: Vec<_> = services
|
||||
.rooms
|
||||
.pdu_metadata
|
||||
.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
|
||||
.get_relations(sender_user, room_id, target, start, limit, depth, dir)
|
||||
.await
|
||||
.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| {
|
||||
@@ -207,15 +182,32 @@ async fn paginate_relations_with_filter(
|
||||
}
|
||||
pdu
|
||||
})
|
||||
.map(at!(1))
|
||||
.map(Event::into_format)
|
||||
.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();
|
||||
|
||||
Ok(assign!(get_relating_events::v1::Response::new(chunk), {
|
||||
next_batch,
|
||||
prev_batch: from.map(Into::into),
|
||||
recursion_depth: recurse.then_some(RECURSION_DEPTH.into()),
|
||||
recursion_depth: recurse.then_some(depth.into()),
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
use std::{
|
||||
collections::{BTreeMap, BTreeSet, HashSet},
|
||||
sync::atomic::{AtomicU64, Ordering::SeqCst},
|
||||
};
|
||||
use std::collections::{BTreeMap, BTreeSet, HashSet};
|
||||
|
||||
use axum::extract::State;
|
||||
use conduwuit::{
|
||||
Err, Error, Result, debug, debug_info, err, info,
|
||||
matrix::{StateKey, pdu::PartialPdu},
|
||||
trace,
|
||||
utils::{self, to_canonical_object},
|
||||
utils::to_canonical_object,
|
||||
warn,
|
||||
};
|
||||
use conduwuit_service::{Services, appservice::RegistrationInfo};
|
||||
use futures::FutureExt;
|
||||
use ruma::{
|
||||
CanonicalJsonObject, CanonicalJsonValue, Int, MilliSecondsSinceUnixEpoch, OwnedRoomAliasId,
|
||||
OwnedUserId, RoomAliasId, RoomId, UInt,
|
||||
OwnedUserId, RoomAliasId, RoomId,
|
||||
api::{
|
||||
client::room::{
|
||||
self,
|
||||
@@ -49,8 +46,6 @@ use serde_json::value::to_raw_value;
|
||||
|
||||
use crate::{Ruma, client::invite_helper};
|
||||
|
||||
static LAST_CREATE_TS: AtomicU64 = AtomicU64::new(0);
|
||||
|
||||
// We use this to keep around extra data in the `creation_content`
|
||||
// while still parsing and validating keys that we care about.
|
||||
#[derive(Deserialize, Default)]
|
||||
@@ -312,17 +307,6 @@ pub(crate) async fn create_room_route(
|
||||
.map(MilliSecondsSinceUnixEpoch)
|
||||
};
|
||||
|
||||
// v12+ room IDs are the create event's hash, so give each create event a
|
||||
// unique timestamp to avoid collisions.
|
||||
let create_timestamp = custom_origin_server_ts.or_else(|| {
|
||||
room_id.is_none().then(|| {
|
||||
let now = utils::millis_since_unix_epoch();
|
||||
let next = |last: u64| now.max(last.saturating_add(1));
|
||||
let prev = LAST_CREATE_TS.update(SeqCst, SeqCst, next);
|
||||
MilliSecondsSinceUnixEpoch(UInt::new_saturating(next(prev)))
|
||||
})
|
||||
});
|
||||
|
||||
let mut create_event_content = to_canonical_object(create_event_content)
|
||||
.expect("should be able to serialize create event content");
|
||||
|
||||
@@ -338,7 +322,7 @@ pub(crate) async fn create_room_route(
|
||||
event_type: TimelineEventType::RoomCreate,
|
||||
content: to_raw_value(&create_event_content)?,
|
||||
state_key: Some(StateKey::new()),
|
||||
timestamp: create_timestamp,
|
||||
timestamp: custom_origin_server_ts,
|
||||
..Default::default()
|
||||
},
|
||||
sender_user,
|
||||
|
||||
@@ -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 {event_id} not found.")));
|
||||
return Err!(Request(NotFound("Event {} not found.", event_id)));
|
||||
}
|
||||
|
||||
services
|
||||
@@ -32,15 +32,10 @@ pub(crate) async fn get_room_event_route(
|
||||
.timeline
|
||||
.get_remote_pdu(room_id, event_id)
|
||||
.await
|
||||
.map_err(|_| err!(Request(NotFound("Event {event_id} not found."))))?
|
||||
.map_err(|_| err!(Request(NotFound("Event {} not found.", event_id))))?
|
||||
},
|
||||
| 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, rooms::read_receipt::pack_receipts};
|
||||
use conduwuit_service::Services;
|
||||
use futures::{
|
||||
FutureExt, StreamExt, TryFutureExt,
|
||||
future::{OptionFuture, join, join3, join4, try_join, try_join3},
|
||||
@@ -243,14 +243,9 @@ async fn build_ephemeral(
|
||||
let (receipt_events, typing_event, private_read_event) =
|
||||
join3(receipt_events, typing_event, private_read_event).await;
|
||||
|
||||
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());
|
||||
}
|
||||
let mut edus = receipt_events;
|
||||
edus.extend(typing_event);
|
||||
edus.extend(private_read_event);
|
||||
|
||||
Ok(assign!(Ephemeral::new(), { events: edus }))
|
||||
}
|
||||
|
||||
+4
-13
@@ -1,21 +1,18 @@
|
||||
use std::{
|
||||
net::{IpAddr, Ipv4Addr},
|
||||
ops::Deref,
|
||||
};
|
||||
use std::ops::Deref;
|
||||
|
||||
use axum::{
|
||||
RequestExt, RequestPartsExt,
|
||||
body::Body,
|
||||
extract::{FromRequest, Path, Query},
|
||||
};
|
||||
use conduwuit::{Error, Result, err, error};
|
||||
use conduwuit::{Error, Result, err};
|
||||
use ruma::{
|
||||
CanonicalJsonObject,
|
||||
api::{IncomingRequest, IncomingRequestExt, auth_scheme::AuthScheme},
|
||||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{State, client_ip::ClientIp, router::auth::CheckAuth};
|
||||
use crate::{State, router::auth::CheckAuth};
|
||||
|
||||
/// Query parameters needed to authenticate requests
|
||||
#[derive(Deserialize)]
|
||||
@@ -90,11 +87,6 @@ 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());
|
||||
@@ -110,8 +102,7 @@ where
|
||||
})?;
|
||||
|
||||
let identity =
|
||||
R::Authentication::check::<R>(services, &request, ip, authentication, auth_query)
|
||||
.await?;
|
||||
R::Authentication::check::<R>(services, &request, authentication, auth_query).await?;
|
||||
|
||||
// Deserialize the body
|
||||
let body = R::try_from_http_request(request, &borrowed_path)
|
||||
|
||||
+5
-38
@@ -1,7 +1,6 @@
|
||||
use std::{
|
||||
any::{Any, TypeId},
|
||||
collections::BTreeSet,
|
||||
net::IpAddr,
|
||||
};
|
||||
|
||||
use conduwuit::{
|
||||
@@ -19,10 +18,7 @@ use ruma::{
|
||||
AuthScheme, NoAccessToken, NoAuthentication,
|
||||
},
|
||||
client,
|
||||
error::{
|
||||
ErrorKind, InsufficientUserAuthenticationErrorData, LimitExceededErrorData,
|
||||
UnknownTokenErrorData,
|
||||
},
|
||||
error::{ErrorKind, InsufficientUserAuthenticationErrorData, UnknownTokenErrorData},
|
||||
federation::authentication::ServerSignatures,
|
||||
},
|
||||
assign,
|
||||
@@ -94,7 +90,6 @@ 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;
|
||||
@@ -106,7 +101,6 @@ 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> {
|
||||
@@ -167,7 +161,6 @@ 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> {
|
||||
@@ -188,7 +181,6 @@ 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> {
|
||||
@@ -203,10 +195,6 @@ impl CheckAuth for AccessTokenOptional {
|
||||
.await
|
||||
.map(Some)
|
||||
} else {
|
||||
if R::RATE_LIMITED {
|
||||
check_unauthenticated_request_ratelimiting(services, request_ip)?;
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
@@ -218,7 +206,6 @@ 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> {
|
||||
@@ -232,7 +219,6 @@ 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> {
|
||||
@@ -252,7 +238,6 @@ 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 {
|
||||
@@ -266,7 +251,6 @@ 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> {
|
||||
@@ -283,10 +267,6 @@ impl CheckAuth for NoAccessToken {
|
||||
.await
|
||||
.map(Some)
|
||||
} else {
|
||||
if R::RATE_LIMITED {
|
||||
check_unauthenticated_request_ratelimiting(services, request_ip)?;
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
@@ -399,7 +379,10 @@ async fn check_access_token(
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
return Err!(Request(UnknownDevice("Device does not exist for this user.")));
|
||||
return Err!(Request(Forbidden(
|
||||
"Device does not exist for user or appservice cannot masquerade as this \
|
||||
device."
|
||||
)));
|
||||
}
|
||||
|
||||
Some(device_id.to_owned())
|
||||
@@ -428,19 +411,3 @@ 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,6 +421,7 @@ 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");
|
||||
},
|
||||
|
||||
+22
-14
@@ -581,20 +581,28 @@ async fn handle_edu_receipt_room_user(
|
||||
}
|
||||
|
||||
let data = &user_updates.data;
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
async fn handle_edu_typing(services: &Services, origin: &ServerName, typing: TypingContent) {
|
||||
|
||||
+3
-1
@@ -47,6 +47,8 @@ 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 = [
|
||||
@@ -75,13 +77,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
|
||||
|
||||
+1
-43
@@ -5,10 +5,7 @@ pub mod proxy;
|
||||
|
||||
use std::{
|
||||
collections::{BTreeMap, BTreeSet, HashMap},
|
||||
hash::Hash,
|
||||
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
|
||||
num::NonZero,
|
||||
ops::Deref,
|
||||
path::PathBuf,
|
||||
time::Duration,
|
||||
};
|
||||
@@ -20,7 +17,6 @@ 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;
|
||||
@@ -44,7 +40,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(Debug, Deserialize)]
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[config_example_generator(
|
||||
filename = "conduwuit-example.toml",
|
||||
section = "global",
|
||||
@@ -794,14 +790,6 @@ 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.
|
||||
///
|
||||
@@ -2972,32 +2960,6 @@ 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",
|
||||
@@ -3441,7 +3403,3 @@ 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,12 +16,7 @@ use ruma::{
|
||||
use serde::Deserialize;
|
||||
use serde_json::{Value as JsonValue, value::RawValue as RawJsonValue};
|
||||
|
||||
pub use self::{
|
||||
filter::Matches,
|
||||
id::*,
|
||||
relation::{RelationTypeEqual, relation_type},
|
||||
type_ext::TypeExt,
|
||||
};
|
||||
pub use self::{filter::Matches, id::*, relation::RelationTypeEqual, 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 ExtractRelatesToRelType {
|
||||
struct ExtractRelatesToEventId {
|
||||
#[serde(rename = "m.relates_to")]
|
||||
relates_to: ExtractRelType,
|
||||
}
|
||||
@@ -18,16 +18,11 @@ 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 {
|
||||
relation_type(event).is_some_and(|r| r == *self)
|
||||
event
|
||||
.get_content()
|
||||
.map(|c: ExtractRelatesToEventId| c.relates_to.rel_type)
|
||||
.is_ok_and(|r| r == *self)
|
||||
}
|
||||
}
|
||||
@@ -105,16 +105,6 @@ 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,21 +5,17 @@ use futures::{
|
||||
future::{OptionFuture, join, join3},
|
||||
};
|
||||
use ruma::{
|
||||
AnyKeyName, CanonicalJsonObject, Int, OwnedUserId, RoomVersionId, SigningKeyId, UserId,
|
||||
Int, OwnedUserId, RoomVersionId, UserId,
|
||||
events::room::{
|
||||
join_rules::{JoinRule, RoomJoinRulesEventContent},
|
||||
member::MembershipState,
|
||||
member::{MembershipState, ThirdPartyInvite},
|
||||
power_levels::{RoomPowerLevelsEventContent, UserPowerLevel},
|
||||
third_party_invite::PublicKey,
|
||||
},
|
||||
int,
|
||||
room_version_rules::{RoomIdFormatVersion, RoomVersionRules},
|
||||
serde::{Raw, base64, base64::Standard},
|
||||
signatures,
|
||||
signatures::to_canonical_json_string_for_signing,
|
||||
third_party_invite::IdentityServerBase64PublicKey,
|
||||
serde::Raw,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::Deserialize;
|
||||
use serde_json::{from_str as from_json_str, value::RawValue as RawJsonValue};
|
||||
|
||||
use super::{
|
||||
@@ -29,7 +25,7 @@ use super::{
|
||||
deserialize_power_levels_content_redact,
|
||||
},
|
||||
};
|
||||
use crate::{debug, err, error, trace, warn};
|
||||
use crate::{debug, error, trace, warn};
|
||||
|
||||
// FIXME: field extracting could be bundled for `content`
|
||||
#[derive(Deserialize)]
|
||||
@@ -52,40 +48,6 @@ 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`.
|
||||
///
|
||||
@@ -99,7 +61,7 @@ pub fn auth_types_for_event(
|
||||
state_key: Option<&str>,
|
||||
content: &RawJsonValue,
|
||||
room_version: &RoomVersionRules,
|
||||
) -> crate::Result<Vec<(StateEventType, StateKey)>> {
|
||||
) -> serde_json::Result<Vec<(StateEventType, StateKey)>> {
|
||||
if kind == &TimelineEventType::RoomCreate {
|
||||
return Ok(vec![]);
|
||||
}
|
||||
@@ -122,7 +84,7 @@ pub fn auth_types_for_event(
|
||||
#[allow(unused)]
|
||||
struct RoomMemberContentFields {
|
||||
membership: Option<Raw<MembershipState>>,
|
||||
third_party_invite: Option<Raw<MemberThirdPartyInviteSignedContent>>,
|
||||
third_party_invite: Option<Raw<ThirdPartyInvite>>,
|
||||
join_authorised_via_users_server: Option<Raw<OwnedUserId>>,
|
||||
}
|
||||
|
||||
@@ -154,24 +116,16 @@ pub fn auth_types_for_event(
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,11 +179,12 @@ 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 + Copy,
|
||||
F: Fn(&StateEventType, &str) -> Fut + Send,
|
||||
Fut: Future<Output = Option<E>> + Send,
|
||||
E: Event + Send + Sync,
|
||||
for<'a> &'a E: Event + Send,
|
||||
@@ -489,15 +444,13 @@ where
|
||||
sender,
|
||||
sender_member_event.as_ref(),
|
||||
incoming_event,
|
||||
fetch_state,
|
||||
current_third_party_invite,
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -686,14 +639,14 @@ where
|
||||
/// event and the current State.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
async fn valid_membership_change<E, F, Fut>(
|
||||
fn valid_membership_change<E>(
|
||||
room_version: &RoomVersionRules,
|
||||
target_user: &UserId,
|
||||
target_user_membership_event: Option<&E>,
|
||||
sender: &UserId,
|
||||
sender_membership_event: Option<&E>,
|
||||
current_event: &E,
|
||||
fetch_state: F,
|
||||
current_third_party_invite: Option<&E>,
|
||||
power_levels_event: Option<&E>,
|
||||
join_rules_event: Option<&E>,
|
||||
user_for_join_auth: Option<&UserId>,
|
||||
@@ -702,13 +655,11 @@ async fn valid_membership_change<E, F, Fut>(
|
||||
) -> 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<MemberThirdPartyInviteSignedContent>>,
|
||||
third_party_invite: Option<Raw<ThirdPartyInvite>>,
|
||||
}
|
||||
let create_content = from_json_str::<RoomCreateContentFields>(create_room.content().get())?;
|
||||
let creator = if room_version.authorization.use_room_create_sender {
|
||||
@@ -950,18 +901,22 @@ where
|
||||
| MembershipState::Invite => {
|
||||
// If content has third_party_invite key
|
||||
trace!("starting target_membership=invite check");
|
||||
match third_party_invite {
|
||||
| Some(raw_tp_id) =>
|
||||
match third_party_invite.and_then(|i| i.deserialize().ok()) {
|
||||
| Some(tp_id) =>
|
||||
if target_user_current_membership == MembershipState::Ban {
|
||||
warn!(?target_user_membership_event_id, "Can't invite banned user");
|
||||
false
|
||||
} else {
|
||||
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
|
||||
let allow = verify_third_party_invite(
|
||||
Some(target_user),
|
||||
sender,
|
||||
&tp_id,
|
||||
current_third_party_invite,
|
||||
);
|
||||
if !allow {
|
||||
warn!("Third party invite invalid");
|
||||
}
|
||||
allow
|
||||
},
|
||||
| _ =>
|
||||
if !sender_is_joined {
|
||||
@@ -1480,133 +1435,14 @@ fn get_send_level(
|
||||
.unwrap_or_else(|| if state_key.is_some() { int!(50) } else { int!(0) })
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -1625,7 +1461,7 @@ mod tests {
|
||||
use serde_json::value::to_raw_value as to_raw_json_value;
|
||||
|
||||
use crate::{
|
||||
matrix::{Event, EventTypeExt},
|
||||
matrix::{Event, EventTypeExt, Pdu as PduEvent},
|
||||
state_res::{
|
||||
StateMap,
|
||||
event_auth::valid_membership_change,
|
||||
@@ -1636,8 +1472,8 @@ mod tests {
|
||||
},
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_ban_pass() {
|
||||
#[test]
|
||||
fn test_ban_pass() {
|
||||
let _ = tracing::subscriber::set_default(
|
||||
tracing_subscriber::fmt().with_test_writer().finish(),
|
||||
);
|
||||
@@ -1659,8 +1495,6 @@ 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();
|
||||
|
||||
@@ -1672,20 +1506,19 @@ mod tests {
|
||||
sender,
|
||||
fetch_state(StateEventType::RoomMember, sender.as_str().into()).as_ref(),
|
||||
&requester,
|
||||
&async_fetch_state,
|
||||
None::<&PduEvent>,
|
||||
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()
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_join_non_creator() {
|
||||
#[test]
|
||||
fn test_join_non_creator() {
|
||||
let _ = tracing::subscriber::set_default(
|
||||
tracing_subscriber::fmt().with_test_writer().finish(),
|
||||
);
|
||||
@@ -1707,8 +1540,6 @@ 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();
|
||||
|
||||
@@ -1720,20 +1551,19 @@ mod tests {
|
||||
sender,
|
||||
fetch_state(StateEventType::RoomMember, sender.as_str().into()).as_ref(),
|
||||
&requester,
|
||||
&async_fetch_state,
|
||||
None::<&PduEvent>,
|
||||
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()
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_join_creator() {
|
||||
#[test]
|
||||
fn test_join_creator() {
|
||||
let _ = tracing::subscriber::set_default(
|
||||
tracing_subscriber::fmt().with_test_writer().finish(),
|
||||
);
|
||||
@@ -1755,8 +1585,6 @@ 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();
|
||||
|
||||
@@ -1768,20 +1596,19 @@ mod tests {
|
||||
sender,
|
||||
fetch_state(StateEventType::RoomMember, sender.as_str().into()).as_ref(),
|
||||
&requester,
|
||||
&async_fetch_state,
|
||||
None::<&PduEvent>,
|
||||
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()
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_ban_fail() {
|
||||
#[test]
|
||||
fn test_ban_fail() {
|
||||
let _ = tracing::subscriber::set_default(
|
||||
tracing_subscriber::fmt().with_test_writer().finish(),
|
||||
);
|
||||
@@ -1803,8 +1630,6 @@ 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();
|
||||
|
||||
@@ -1816,20 +1641,19 @@ mod tests {
|
||||
sender,
|
||||
fetch_state(StateEventType::RoomMember, sender.as_str().into()).as_ref(),
|
||||
&requester,
|
||||
&async_fetch_state,
|
||||
None::<&PduEvent>,
|
||||
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()
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_restricted_join_rule() {
|
||||
#[test]
|
||||
fn test_restricted_join_rule() {
|
||||
let _ = tracing::subscriber::set_default(
|
||||
tracing_subscriber::fmt().with_test_writer().finish(),
|
||||
);
|
||||
@@ -1868,8 +1692,6 @@ 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();
|
||||
|
||||
@@ -1881,14 +1703,13 @@ mod tests {
|
||||
sender,
|
||||
fetch_state(StateEventType::RoomMember, sender.as_str().into()).as_ref(),
|
||||
&requester,
|
||||
&async_fetch_state,
|
||||
None::<&PduEvent>,
|
||||
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()
|
||||
);
|
||||
|
||||
@@ -1900,20 +1721,19 @@ mod tests {
|
||||
sender,
|
||||
fetch_state(StateEventType::RoomMember, sender.as_str().into()).as_ref(),
|
||||
&requester,
|
||||
&async_fetch_state,
|
||||
None::<&PduEvent>,
|
||||
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()
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_knock() {
|
||||
#[test]
|
||||
fn test_knock() {
|
||||
let _ = tracing::subscriber::set_default(
|
||||
tracing_subscriber::fmt().with_test_writer().finish(),
|
||||
);
|
||||
@@ -1944,8 +1764,6 @@ 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();
|
||||
|
||||
@@ -1957,14 +1775,13 @@ mod tests {
|
||||
sender,
|
||||
fetch_state(StateEventType::RoomMember, sender.as_str().into()).as_ref(),
|
||||
&requester,
|
||||
&async_fetch_state,
|
||||
None::<&PduEvent>,
|
||||
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,8 +757,7 @@ 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();
|
||||
@@ -831,6 +830,12 @@ 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
|
||||
@@ -842,6 +847,7 @@ where
|
||||
let auth_result = auth_check(
|
||||
room_version,
|
||||
&event,
|
||||
current_third_party,
|
||||
fetch_state,
|
||||
&fetch_state(&StateEventType::RoomCreate, "")
|
||||
.await
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
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,6 +34,8 @@ 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",
|
||||
]
|
||||
@@ -58,6 +60,7 @@ 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::RANDOM
|
||||
..descriptor::DROPPED
|
||||
},
|
||||
Descriptor {
|
||||
name: "refreshtoken_refreshtokeninfo",
|
||||
|
||||
Loaded 100 of 138 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user