mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b6c5991e1f | |||
| efd879fcd8 | |||
| 92a848f74d | |||
| 776b5865ba | |||
| 722bacbe89 | |||
| 46907e3dce | |||
| 31e2195e56 | |||
| 7ecac93ddc | |||
| 6a0b103722 | |||
| 23d77b614f | |||
| e01aa44b16 | |||
| a08739c246 | |||
| c14864b881 | |||
| 1773e72e68 | |||
| 0f94d55689 | |||
| abfb6377c2 | |||
| 91d64f5b24 | |||
| 9a3f3f6e78 | |||
| b3e31a4aad | |||
| 8cda431cc6 | |||
| 02b9a3f713 | |||
| d40893730c | |||
| 28fae58cf6 | |||
| f458f6ab76 | |||
| fdf9cea533 | |||
| ecb1b73c84 | |||
| e03082480a | |||
| f9e7f019ad | |||
| 12069e7c86 | |||
| 77928a62b4 | |||
| c73cb5c1bf | |||
| a140eacb04 |
@@ -23,7 +23,7 @@ repos:
|
|||||||
- id: check-added-large-files
|
- id: check-added-large-files
|
||||||
|
|
||||||
- repo: https://github.com/crate-ci/typos
|
- repo: https://github.com/crate-ci/typos
|
||||||
rev: v1.43.4
|
rev: v1.43.5
|
||||||
hooks:
|
hooks:
|
||||||
- id: typos
|
- id: typos
|
||||||
- id: typos
|
- id: typos
|
||||||
|
|||||||
+16
-8
@@ -85,24 +85,31 @@ If your changes are done to fix Matrix tests, please note that in your pull requ
|
|||||||
|
|
||||||
### Writing documentation
|
### Writing documentation
|
||||||
|
|
||||||
Continuwuity's website uses [`mdbook`][mdbook] and is deployed via CI using Cloudflare Pages
|
Continuwuity's website uses [`rspress`][rspress] and is deployed via CI using Cloudflare Pages
|
||||||
in the [`documentation.yml`][documentation.yml] workflow file. All documentation is in the `docs/`
|
in the [`documentation.yml`][documentation.yml] workflow file. All documentation is in the `docs/`
|
||||||
directory at the top level.
|
directory at the top level.
|
||||||
|
|
||||||
To build the documentation locally:
|
To load the documentation locally:
|
||||||
|
|
||||||
|
1. Install NodeJS and npm from their [official website][nodejs-download] or via your package manager of choice
|
||||||
|
|
||||||
|
2. From the project's root directory, install the relevant npm modules
|
||||||
|
|
||||||
1. Install mdbook if you don't have it already:
|
|
||||||
```bash
|
```bash
|
||||||
cargo install mdbook # or cargo binstall, or another method
|
npm ci
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Build the documentation:
|
3. Make changes to the document pages as you see fit
|
||||||
|
|
||||||
|
4. Generate a live preview of the documentation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mdbook build
|
npm run docs:dev
|
||||||
```
|
```
|
||||||
|
|
||||||
The output of the mdbook generation is in `public/`. You can open the HTML files directly in your browser without needing a web server.
|
A webserver for the docs will be spun up for you (e.g. at `http://localhost:3000`). Any changes you make to the documentation will be live-reloaded on the webpage.
|
||||||
|
|
||||||
|
Alternatively, you can build the documentation using `npm run docs:build` - the output of this will be in the `/doc_build` directory. Once you're happy with your documentation updates, you can commit the changes.
|
||||||
|
|
||||||
### Commit Messages
|
### Commit Messages
|
||||||
|
|
||||||
@@ -169,5 +176,6 @@ continuwuity Matrix rooms for Code of Conduct violations.
|
|||||||
[continuwuity-matrix]: https://matrix.to/#/#continuwuity:continuwuity.org?via=continuwuity.org&via=ellis.link&via=explodie.org&via=matrix.org
|
[continuwuity-matrix]: https://matrix.to/#/#continuwuity:continuwuity.org?via=continuwuity.org&via=ellis.link&via=explodie.org&via=matrix.org
|
||||||
[complement]: https://github.com/matrix-org/complement/
|
[complement]: https://github.com/matrix-org/complement/
|
||||||
[sytest]: https://github.com/matrix-org/sytest/
|
[sytest]: https://github.com/matrix-org/sytest/
|
||||||
[mdbook]: https://rust-lang.github.io/mdBook/
|
[nodejs-download]: https://nodejs.org/en/download
|
||||||
|
[rspress]: https://rspress.rs/
|
||||||
[documentation.yml]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/.forgejo/workflows/documentation.yml
|
[documentation.yml]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/.forgejo/workflows/documentation.yml
|
||||||
|
|||||||
Generated
+440
-321
File diff suppressed because it is too large
Load Diff
+12
-11
@@ -68,7 +68,7 @@ default-features = false
|
|||||||
version = "0.1.3"
|
version = "0.1.3"
|
||||||
|
|
||||||
[workspace.dependencies.rand]
|
[workspace.dependencies.rand]
|
||||||
version = "0.8.5"
|
version = "0.10.0"
|
||||||
|
|
||||||
# Used for the http request / response body type for Ruma endpoints used with reqwest
|
# Used for the http request / response body type for Ruma endpoints used with reqwest
|
||||||
[workspace.dependencies.bytes]
|
[workspace.dependencies.bytes]
|
||||||
@@ -84,7 +84,7 @@ version = "1.3.1"
|
|||||||
version = "1.11.1"
|
version = "1.11.1"
|
||||||
|
|
||||||
[workspace.dependencies.axum]
|
[workspace.dependencies.axum]
|
||||||
version = "0.7.9"
|
version = "0.8.8"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = [
|
features = [
|
||||||
"form",
|
"form",
|
||||||
@@ -97,7 +97,7 @@ features = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[workspace.dependencies.axum-extra]
|
[workspace.dependencies.axum-extra]
|
||||||
version = "0.9.6"
|
version = "0.10.1"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["typed-header", "tracing"]
|
features = ["typed-header", "tracing"]
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ default-features = false
|
|||||||
version = "0.7"
|
version = "0.7"
|
||||||
|
|
||||||
[workspace.dependencies.axum-client-ip]
|
[workspace.dependencies.axum-client-ip]
|
||||||
version = "0.6.1"
|
version = "0.7"
|
||||||
|
|
||||||
[workspace.dependencies.tower]
|
[workspace.dependencies.tower]
|
||||||
version = "0.5.2"
|
version = "0.5.2"
|
||||||
@@ -118,7 +118,7 @@ default-features = false
|
|||||||
features = ["util"]
|
features = ["util"]
|
||||||
|
|
||||||
[workspace.dependencies.tower-http]
|
[workspace.dependencies.tower-http]
|
||||||
version = "0.6.2"
|
version = "0.6.8"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = [
|
features = [
|
||||||
"add-extension",
|
"add-extension",
|
||||||
@@ -298,7 +298,7 @@ default-features = false
|
|||||||
features = ["env", "toml"]
|
features = ["env", "toml"]
|
||||||
|
|
||||||
[workspace.dependencies.hickory-resolver]
|
[workspace.dependencies.hickory-resolver]
|
||||||
version = "0.25.1"
|
version = "0.25.2"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = [
|
features = [
|
||||||
"serde",
|
"serde",
|
||||||
@@ -342,7 +342,8 @@ version = "0.1.2"
|
|||||||
# Used for matrix spec type definitions and helpers
|
# Used for matrix spec type definitions and helpers
|
||||||
[workspace.dependencies.ruma]
|
[workspace.dependencies.ruma]
|
||||||
git = "https://forgejo.ellis.link/continuwuation/ruwuma"
|
git = "https://forgejo.ellis.link/continuwuation/ruwuma"
|
||||||
rev = "b496b7f38d517149361a882e75d3fd4faf210441"
|
#branch = "conduwuit-changes"
|
||||||
|
rev = "e087ff15888156942ca2ffe6097d1b4c3fd27628"
|
||||||
features = [
|
features = [
|
||||||
"compat",
|
"compat",
|
||||||
"rand",
|
"rand",
|
||||||
@@ -424,7 +425,7 @@ features = ["http", "grpc-tonic", "trace", "logs", "metrics"]
|
|||||||
|
|
||||||
# optional sentry metrics for crash/panic reporting
|
# optional sentry metrics for crash/panic reporting
|
||||||
[workspace.dependencies.sentry]
|
[workspace.dependencies.sentry]
|
||||||
version = "0.45.0"
|
version = "0.46.0"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = [
|
features = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
@@ -440,9 +441,9 @@ features = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[workspace.dependencies.sentry-tracing]
|
[workspace.dependencies.sentry-tracing]
|
||||||
version = "0.45.0"
|
version = "0.46.0"
|
||||||
[workspace.dependencies.sentry-tower]
|
[workspace.dependencies.sentry-tower]
|
||||||
version = "0.45.0"
|
version = "0.46.0"
|
||||||
|
|
||||||
# jemalloc usage
|
# jemalloc usage
|
||||||
[workspace.dependencies.tikv-jemalloc-sys]
|
[workspace.dependencies.tikv-jemalloc-sys]
|
||||||
@@ -553,7 +554,7 @@ version = "0.7.5"
|
|||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
|
|
||||||
[workspace.dependencies.askama]
|
[workspace.dependencies.askama]
|
||||||
version = "0.14.0"
|
version = "0.15.0"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Patches
|
# Patches
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Removed non-compliant nor functional room alias lookups over federation. Contributed by @nex
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Outgoing presence is now disabled by default, and the config option documentation has been adjusted to more accurately represent the weight of presence, typing indicators, and read receipts. Contributed by @nex.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Removed ability to set rocksdb as read only. Doing so would cause unintentional and buggy behaviour. Contributed by @Terryiscool160.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Fixed a startup crash in the sender service if we can't detect the number of CPU cores, even if the `sender_workers' config option is set correctly. Contributed by @katie.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Updated `list-backups` admin command to output one backup per line.
|
||||||
+26
-19
@@ -1056,14 +1056,6 @@
|
|||||||
#
|
#
|
||||||
#rocksdb_repair = false
|
#rocksdb_repair = false
|
||||||
|
|
||||||
# This item is undocumented. Please contribute documentation for it.
|
|
||||||
#
|
|
||||||
#rocksdb_read_only = false
|
|
||||||
|
|
||||||
# This item is undocumented. Please contribute documentation for it.
|
|
||||||
#
|
|
||||||
#rocksdb_secondary = false
|
|
||||||
|
|
||||||
# Enables idle CPU priority for compaction thread. This is not enabled by
|
# Enables idle CPU priority for compaction thread. This is not enabled by
|
||||||
# default to prevent compaction from falling too far behind on busy
|
# default to prevent compaction from falling too far behind on busy
|
||||||
# systems.
|
# systems.
|
||||||
@@ -1120,27 +1112,34 @@
|
|||||||
|
|
||||||
# Allow local (your server only) presence updates/requests.
|
# Allow local (your server only) presence updates/requests.
|
||||||
#
|
#
|
||||||
# Note that presence on continuwuity is very fast unlike Synapse's. If
|
# Local presence must be enabled for outgoing presence to function.
|
||||||
# using outgoing presence, this MUST be enabled.
|
#
|
||||||
|
# Note that local presence is not as heavy on the CPU as federated
|
||||||
|
# presence, but will still become more expensive the more local users you
|
||||||
|
# have.
|
||||||
#
|
#
|
||||||
#allow_local_presence = true
|
#allow_local_presence = true
|
||||||
|
|
||||||
# Allow incoming federated presence updates/requests.
|
# Allow incoming federated presence updates.
|
||||||
#
|
#
|
||||||
# This option receives presence updates from other servers, but does not
|
# This option enables processing inbound presence updates from other
|
||||||
# send any unless `allow_outgoing_presence` is true. Note that presence on
|
# servers. Without it, remote users will appear as if they are always
|
||||||
# continuwuity is very fast unlike Synapse's.
|
# offline to your local users. This does not affect typing indicators or
|
||||||
|
# read receipts.
|
||||||
#
|
#
|
||||||
#allow_incoming_presence = true
|
#allow_incoming_presence = true
|
||||||
|
|
||||||
# Allow outgoing presence updates/requests.
|
# Allow outgoing presence updates/requests.
|
||||||
#
|
#
|
||||||
# This option sends presence updates to other servers, but does not
|
# This option sends presence updates to other servers, and requires that
|
||||||
# receive any unless `allow_incoming_presence` is true. Note that presence
|
# `allow_local_presence` is also enabled.
|
||||||
# on continuwuity is very fast unlike Synapse's. If using outgoing
|
|
||||||
# presence, you MUST enable `allow_local_presence` as well.
|
|
||||||
#
|
#
|
||||||
#allow_outgoing_presence = true
|
# Note that outgoing presence is very heavy on the CPU and network, and
|
||||||
|
# will typically cause extreme strain and slowdowns for no real benefit.
|
||||||
|
# There are only a few clients that even implement presence, so you
|
||||||
|
# probably don't want to enable this.
|
||||||
|
#
|
||||||
|
#allow_outgoing_presence = false
|
||||||
|
|
||||||
# How many seconds without presence updates before you become idle.
|
# How many seconds without presence updates before you become idle.
|
||||||
# Defaults to 5 minutes.
|
# Defaults to 5 minutes.
|
||||||
@@ -1174,6 +1173,10 @@
|
|||||||
|
|
||||||
# Allow sending read receipts to remote servers.
|
# Allow sending read receipts to remote servers.
|
||||||
#
|
#
|
||||||
|
# Note that sending read receipts to remote servers in large rooms with
|
||||||
|
# lots of other homeservers may cause additional strain on the CPU and
|
||||||
|
# network.
|
||||||
|
#
|
||||||
#allow_outgoing_read_receipts = true
|
#allow_outgoing_read_receipts = true
|
||||||
|
|
||||||
# Allow local typing updates.
|
# Allow local typing updates.
|
||||||
@@ -1185,6 +1188,10 @@
|
|||||||
|
|
||||||
# Allow outgoing typing updates to federation.
|
# Allow outgoing typing updates to federation.
|
||||||
#
|
#
|
||||||
|
# Note that sending typing indicators to remote servers in large rooms
|
||||||
|
# with lots of other homeservers may cause additional strain on the CPU
|
||||||
|
# and network.
|
||||||
|
#
|
||||||
#allow_outgoing_typing = true
|
#allow_outgoing_typing = true
|
||||||
|
|
||||||
# Allow incoming typing updates from federation.
|
# Allow incoming typing updates from federation.
|
||||||
|
|||||||
+41
-2
@@ -137,7 +137,7 @@ By default, all routes should be forwarded to Livekit with the exception of the
|
|||||||
# for lk-jwt-service
|
# for lk-jwt-service
|
||||||
@lk-jwt-service path /sfu/get* /healthz* /get_token*
|
@lk-jwt-service path /sfu/get* /healthz* /get_token*
|
||||||
route @lk-jwt-service {
|
route @lk-jwt-service {
|
||||||
reverse_proxy 127.0.0.1:8080
|
reverse_proxy 127.0.0.1:8081
|
||||||
}
|
}
|
||||||
|
|
||||||
# for livekit
|
# for livekit
|
||||||
@@ -146,6 +146,46 @@ By default, all routes should be forwarded to Livekit with the exception of the
|
|||||||
```
|
```
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Example nginx config</summary>
|
||||||
|
```
|
||||||
|
server {
|
||||||
|
server_name matrix-rtc.example.com;
|
||||||
|
|
||||||
|
# for lk-jwt-service
|
||||||
|
location ~ ^/(sfu/get|healthz|get_token) {
|
||||||
|
proxy_pass http://127.0.0.1:8081$request_uri;
|
||||||
|
proxy_set_header X-Forwarded-For $remote_addr;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_buffering off;
|
||||||
|
}
|
||||||
|
|
||||||
|
# for livekit
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:7880$request_uri;
|
||||||
|
proxy_set_header X-Forwarded-For $remote_addr;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_buffering off;
|
||||||
|
|
||||||
|
# websocket
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection $connection_upgrade;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that for websockets to work, you need to have this somewhere outside your server block:
|
||||||
|
```
|
||||||
|
map $http_upgrade $connection_upgrade {
|
||||||
|
default upgrade;
|
||||||
|
'' close;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Example traefik router</summary>
|
<summary>Example traefik router</summary>
|
||||||
```
|
```
|
||||||
@@ -226,4 +266,3 @@ turn:
|
|||||||
- [Synapse documentation](https://github.com/element-hq/element-call/blob/livekit/docs/self-hosting.md)
|
- [Synapse documentation](https://github.com/element-hq/element-call/blob/livekit/docs/self-hosting.md)
|
||||||
- [Community guide](https://tomfos.tr/matrix/livekit/)
|
- [Community guide](https://tomfos.tr/matrix/livekit/)
|
||||||
- [Community guide](https://blog.kimiblock.top/2024/12/24/hosting-element-call/)
|
- [Community guide](https://blog.kimiblock.top/2024/12/24/hosting-element-call/)
|
||||||
-
|
|
||||||
|
|||||||
@@ -3,3 +3,5 @@
|
|||||||
Continuwuity currently does not provide FreeBSD builds or FreeBSD packaging. However, Continuwuity does build and work on FreeBSD using the system-provided RocksDB.
|
Continuwuity currently does not provide FreeBSD builds or FreeBSD packaging. However, Continuwuity does build and work on FreeBSD using the system-provided RocksDB.
|
||||||
|
|
||||||
Contributions to get Continuwuity packaged for FreeBSD are welcome.
|
Contributions to get Continuwuity packaged for FreeBSD are welcome.
|
||||||
|
|
||||||
|
Please join our [Continuwuity BSD](https://matrix.to/#/%23bsd:continuwuity.org) community room.
|
||||||
|
|||||||
@@ -1,7 +1,109 @@
|
|||||||
# Continuwuity for Kubernetes
|
# Continuwuity for Kubernetes
|
||||||
|
|
||||||
Continuwuity doesn't support horizontal scalability or distributed loading
|
Continuwuity doesn't support horizontal scalability or distributed loading
|
||||||
natively. However, [a community-maintained Helm Chart is available here to run
|
natively. However, a deployment in Kubernetes is very similar to the docker
|
||||||
|
setup. This is because Continuwuity can be fully configured using environment
|
||||||
|
variables. A sample StatefulSet is shared below. The only thing missing is
|
||||||
|
a PVC definition (named `continuwuity-data`) for the volume mounted to
|
||||||
|
the StatefulSet, an Ingress resources to point your webserver to the
|
||||||
|
Continuwuity Pods, and a Service resource (targeting `app.kubernetes.io/name: continuwuity`)
|
||||||
|
to glue the Ingress and Pod together.
|
||||||
|
|
||||||
|
Carefully go through the `env` section and add, change, and remove any env vars you like using the [Configuration reference](https://continuwuity.org/reference/config.html)
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: StatefulSet
|
||||||
|
metadata:
|
||||||
|
name: continuwuity
|
||||||
|
namespace: matrix
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: continuwuity
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
serviceName: continuwuity
|
||||||
|
podManagementPolicy: Parallel
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/name: continuwuity
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: continuwuity
|
||||||
|
spec:
|
||||||
|
securityContext:
|
||||||
|
sysctls:
|
||||||
|
- name: net.ipv4.ip_unprivileged_port_start
|
||||||
|
value: "0"
|
||||||
|
containers:
|
||||||
|
- name: continuwuity
|
||||||
|
# use a sha hash <3
|
||||||
|
image: forgejo.ellis.link/continuwuation/continuwuity:latest
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
containerPort: 80
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /data
|
||||||
|
name: data
|
||||||
|
subPath: data
|
||||||
|
securityContext:
|
||||||
|
capabilities:
|
||||||
|
add:
|
||||||
|
- NET_BIND_SERVICE
|
||||||
|
env:
|
||||||
|
- name: TOKIO_WORKER_THREADS
|
||||||
|
value: "2"
|
||||||
|
- name: CONTINUWUITY_SERVER_NAME
|
||||||
|
value: "example.com"
|
||||||
|
- name: CONTINUWUITY_DATABASE_PATH
|
||||||
|
value: "/data/db"
|
||||||
|
- name: CONTINUWUITY_DATABASE_BACKEND
|
||||||
|
value: "rocksdb"
|
||||||
|
- name: CONTINUWUITY_PORT
|
||||||
|
value: "80"
|
||||||
|
- name: CONTINUWUITY_MAX_REQUEST_SIZE
|
||||||
|
value: "20000000"
|
||||||
|
- name: CONTINUWUITY_ALLOW_FEDERATION
|
||||||
|
value: "true"
|
||||||
|
- name: CONTINUWUITY_TRUSTED_SERVERS
|
||||||
|
value: '["matrix.org"]'
|
||||||
|
- name: CONTINUWUITY_ADDRESS
|
||||||
|
value: "0.0.0.0"
|
||||||
|
- name: CONTINUWUITY_ROCKSDB_PARALLELISM_THREADS
|
||||||
|
value: "1"
|
||||||
|
- name: CONTINUWUITY_WELL_KNOWN__SERVER
|
||||||
|
value: "matrix.example.com:443"
|
||||||
|
- name: CONTINUWUITY_WELL_KNOWN__CLIENT
|
||||||
|
value: "https://matrix.example.com"
|
||||||
|
- name: CONTINUWUITY_ALLOW_REGISTRATION
|
||||||
|
value: "false"
|
||||||
|
- name: RUST_LOG
|
||||||
|
value: info
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /_matrix/federation/v1/version
|
||||||
|
port: http
|
||||||
|
periodSeconds: 4
|
||||||
|
failureThreshold: 5
|
||||||
|
resources:
|
||||||
|
# Continuwuity might use quite some RAM :3
|
||||||
|
requests:
|
||||||
|
cpu: "2"
|
||||||
|
memory: "512Mi"
|
||||||
|
limits:
|
||||||
|
cpu: "4"
|
||||||
|
memory: "2048Mi"
|
||||||
|
volumes:
|
||||||
|
- name: data
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: continuwuity-data
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Apart from manually configuring the containers,
|
||||||
|
[a community-maintained Helm Chart is available here to run
|
||||||
conduwuit on Kubernetes](https://gitlab.cronce.io/charts/conduwuit)
|
conduwuit on Kubernetes](https://gitlab.cronce.io/charts/conduwuit)
|
||||||
|
|
||||||
This should be compatible with Continuwuity, but you will need to change the image reference.
|
This should be compatible with Continuwuity, but you will need to change the image reference.
|
||||||
|
|||||||
@@ -1,13 +1,28 @@
|
|||||||
# Troubleshooting Continuwuity
|
# Troubleshooting Continuwuity
|
||||||
|
|
||||||
> **Docker users ⚠️**
|
:::warning{title="Docker users:"}
|
||||||
>
|
Docker can be difficult to use and debug. It's common for Docker
|
||||||
> Docker can be difficult to use and debug. It's common for Docker
|
misconfigurations to cause issues, particularly with networking and permissions.
|
||||||
> misconfigurations to cause issues, particularly with networking and permissions.
|
Please check that your issues are not due to problems with your Docker setup.
|
||||||
> Please check that your issues are not due to problems with your Docker setup.
|
:::
|
||||||
|
|
||||||
## Continuwuity and Matrix issues
|
## Continuwuity and Matrix issues
|
||||||
|
|
||||||
|
### Slow joins to rooms
|
||||||
|
|
||||||
|
Some slowness is to be expected if you're the first person on your homserver to join a room (which will
|
||||||
|
always be the case for single-user homeservers). In this situation, your homeserver has to verify the signatures of
|
||||||
|
all of the state events sent by other servers before your join. To make this process as fast as possible, make sure you have
|
||||||
|
multiple fast, trusted servers listed in `trusted_servers` in your configuration, and ensure
|
||||||
|
`query_trusted_key_servers_first_on_join` is set to true (the default).
|
||||||
|
If you need suggestions for trusted servers, ask in the Continuwuity main room.
|
||||||
|
|
||||||
|
However, _very_ slow joins, especially to rooms with only a few users in them or rooms created by another user
|
||||||
|
on your homeserver, may be caused by [issue !779](https://forgejo.ellis.link/continuwuation/continuwuity/issues/779),
|
||||||
|
which is a longstanding bug with synchronizing room joins to clients. In this situation, you did succeed in joining the room, but
|
||||||
|
the bug caused your homeserver to forget to tell your client. **To fix this, clear your client's cache.** Both Element and Cinny
|
||||||
|
have a button to clear their cache in the "About" section of their settings.
|
||||||
|
|
||||||
### Lost access to admin room
|
### Lost access to admin room
|
||||||
|
|
||||||
You can reinvite yourself to the admin room through the following methods:
|
You can reinvite yourself to the admin room through the following methods:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
"extends": ["config:recommended", "replacements:all"],
|
"extends": ["config:recommended", "replacements:all"],
|
||||||
|
"dependencyDashboard": true,
|
||||||
"osvVulnerabilityAlerts": true,
|
"osvVulnerabilityAlerts": true,
|
||||||
"lockFileMaintenance": {
|
"lockFileMaintenance": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
@@ -57,12 +58,25 @@
|
|||||||
"matchUpdateTypes": ["minor", "patch"],
|
"matchUpdateTypes": ["minor", "patch"],
|
||||||
"groupName": "github-actions-non-major"
|
"groupName": "github-actions-non-major"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"description": "Batch patch-level Node.js dependency updates",
|
||||||
|
"matchManagers": ["npm"],
|
||||||
|
"matchUpdateTypes": ["patch"],
|
||||||
|
"groupName": "node-patch-updates"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"description": "Pin forgejo artifact actions to prevent breaking changes",
|
"description": "Pin forgejo artifact actions to prevent breaking changes",
|
||||||
"matchManagers": ["github-actions"],
|
"matchManagers": ["github-actions"],
|
||||||
"matchPackageNames": ["forgejo/upload-artifact", "forgejo/download-artifact"],
|
"matchPackageNames": ["forgejo/upload-artifact", "forgejo/download-artifact"],
|
||||||
"enabled": false
|
"enabled": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"description": "Auto-merge crate-ci/typos minor updates",
|
||||||
|
"matchPackageNames": ["crate-ci/typos"],
|
||||||
|
"matchUpdateTypes": ["minor", "patch"],
|
||||||
|
"automerge": true,
|
||||||
|
"automergeStrategy": "fast-forward"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"description": "Auto-merge renovatebot docker image updates",
|
"description": "Auto-merge renovatebot docker image updates",
|
||||||
"matchDatasources": ["docker"],
|
"matchDatasources": ["docker"],
|
||||||
|
|||||||
@@ -89,13 +89,7 @@ async fn ban_room(&self, room: OwnedRoomOrAliasId) -> Result {
|
|||||||
locally, if not using get_alias_helper to fetch room ID remotely"
|
locally, if not using get_alias_helper to fetch room ID remotely"
|
||||||
);
|
);
|
||||||
|
|
||||||
match self
|
match self.services.rooms.alias.resolve_alias(room_alias).await {
|
||||||
.services
|
|
||||||
.rooms
|
|
||||||
.alias
|
|
||||||
.resolve_alias(room_alias, None)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
| Ok((room_id, servers)) => {
|
| Ok((room_id, servers)) => {
|
||||||
debug!(
|
debug!(
|
||||||
%room_id,
|
%room_id,
|
||||||
@@ -235,7 +229,7 @@ async fn ban_list_of_rooms(&self) -> Result {
|
|||||||
.services
|
.services
|
||||||
.rooms
|
.rooms
|
||||||
.alias
|
.alias
|
||||||
.resolve_alias(room_alias, None)
|
.resolve_alias(room_alias)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
| Ok((room_id, servers)) => {
|
| Ok((room_id, servers)) => {
|
||||||
@@ -388,13 +382,7 @@ async fn unban_room(&self, room: OwnedRoomOrAliasId) -> Result {
|
|||||||
room ID over federation"
|
room ID over federation"
|
||||||
);
|
);
|
||||||
|
|
||||||
match self
|
match self.services.rooms.alias.resolve_alias(room_alias).await {
|
||||||
.services
|
|
||||||
.rooms
|
|
||||||
.alias
|
|
||||||
.resolve_alias(room_alias, None)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
| Ok((room_id, servers)) => {
|
| Ok((room_id, servers)) => {
|
||||||
debug!(
|
debug!(
|
||||||
%room_id,
|
%room_id,
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ pub(super) async fn list_backups(&self) -> Result {
|
|||||||
.db
|
.db
|
||||||
.backup_list()?
|
.backup_list()?
|
||||||
.try_stream()
|
.try_stream()
|
||||||
.try_for_each(|result| write!(self, "{result}"))
|
.try_for_each(|result| writeln!(self, "{result}"))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-65
@@ -1,12 +1,6 @@
|
|||||||
use axum::extract::State;
|
use axum::extract::State;
|
||||||
use conduwuit::{Err, Result, debug};
|
use conduwuit::{Err, Result};
|
||||||
use conduwuit_service::Services;
|
use ruma::api::client::alias::{create_alias, delete_alias, get_alias};
|
||||||
use futures::StreamExt;
|
|
||||||
use rand::seq::SliceRandom;
|
|
||||||
use ruma::{
|
|
||||||
OwnedServerName, RoomAliasId, RoomId,
|
|
||||||
api::client::alias::{create_alias, delete_alias, get_alias},
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::Ruma;
|
use crate::Ruma;
|
||||||
|
|
||||||
@@ -96,65 +90,9 @@ pub(crate) async fn get_alias_route(
|
|||||||
) -> Result<get_alias::v3::Response> {
|
) -> Result<get_alias::v3::Response> {
|
||||||
let room_alias = body.body.room_alias;
|
let room_alias = body.body.room_alias;
|
||||||
|
|
||||||
let Ok((room_id, servers)) = services.rooms.alias.resolve_alias(&room_alias, None).await
|
let Ok((room_id, servers)) = services.rooms.alias.resolve_alias(&room_alias).await else {
|
||||||
else {
|
|
||||||
return Err!(Request(NotFound("Room with alias not found.")));
|
return Err!(Request(NotFound("Room with alias not found.")));
|
||||||
};
|
};
|
||||||
|
|
||||||
let servers = room_available_servers(&services, &room_id, &room_alias, servers).await;
|
|
||||||
debug!(%room_alias, %room_id, "available servers: {servers:?}");
|
|
||||||
|
|
||||||
Ok(get_alias::v3::Response::new(room_id, servers))
|
Ok(get_alias::v3::Response::new(room_id, servers))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn room_available_servers(
|
|
||||||
services: &Services,
|
|
||||||
room_id: &RoomId,
|
|
||||||
room_alias: &RoomAliasId,
|
|
||||||
pre_servers: Vec<OwnedServerName>,
|
|
||||||
) -> Vec<OwnedServerName> {
|
|
||||||
// find active servers in room state cache to suggest
|
|
||||||
let mut servers: Vec<OwnedServerName> = services
|
|
||||||
.rooms
|
|
||||||
.state_cache
|
|
||||||
.room_servers(room_id)
|
|
||||||
.map(ToOwned::to_owned)
|
|
||||||
.collect()
|
|
||||||
.await;
|
|
||||||
|
|
||||||
// push any servers we want in the list already (e.g. responded remote alias
|
|
||||||
// servers, room alias server itself)
|
|
||||||
servers.extend(pre_servers);
|
|
||||||
|
|
||||||
servers.sort_unstable();
|
|
||||||
servers.dedup();
|
|
||||||
|
|
||||||
// shuffle list of servers randomly after sort and dedupe
|
|
||||||
servers.shuffle(&mut rand::thread_rng());
|
|
||||||
|
|
||||||
// insert our server as the very first choice if in list, else check if we can
|
|
||||||
// prefer the room alias server first
|
|
||||||
match servers
|
|
||||||
.iter()
|
|
||||||
.position(|server_name| services.globals.server_is_ours(server_name))
|
|
||||||
{
|
|
||||||
| Some(server_index) => {
|
|
||||||
servers.swap_remove(server_index);
|
|
||||||
servers.insert(0, services.globals.server_name().to_owned());
|
|
||||||
},
|
|
||||||
| _ => {
|
|
||||||
match servers
|
|
||||||
.iter()
|
|
||||||
.position(|server| server == room_alias.server_name())
|
|
||||||
{
|
|
||||||
| Some(alias_server_index) => {
|
|
||||||
servers.swap_remove(alias_server_index);
|
|
||||||
servers.insert(0, room_alias.server_name().into());
|
|
||||||
},
|
|
||||||
| _ => {},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
servers
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -198,11 +198,7 @@ pub(crate) async fn join_room_by_id_or_alias_route(
|
|||||||
(servers, room_id)
|
(servers, room_id)
|
||||||
},
|
},
|
||||||
| Err(room_alias) => {
|
| Err(room_alias) => {
|
||||||
let (room_id, mut servers) = services
|
let (room_id, mut servers) = services.rooms.alias.resolve_alias(&room_alias).await?;
|
||||||
.rooms
|
|
||||||
.alias
|
|
||||||
.resolve_alias(&room_alias, Some(body.via.clone()))
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
banned_room_check(
|
banned_room_check(
|
||||||
&services,
|
&services,
|
||||||
|
|||||||
@@ -102,11 +102,7 @@ pub(crate) async fn knock_room_route(
|
|||||||
(servers, room_id)
|
(servers, room_id)
|
||||||
},
|
},
|
||||||
| Err(room_alias) => {
|
| Err(room_alias) => {
|
||||||
let (room_id, mut servers) = services
|
let (room_id, mut servers) = services.rooms.alias.resolve_alias(&room_alias).await?;
|
||||||
.rooms
|
|
||||||
.alias
|
|
||||||
.resolve_alias(&room_alias, Some(body.via.clone()))
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
banned_room_check(
|
banned_room_check(
|
||||||
&services,
|
&services,
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ fn build_report(report: Report) -> RoomMessageEventContent {
|
|||||||
/// random delay sending a response per spec suggestion regarding
|
/// random delay sending a response per spec suggestion regarding
|
||||||
/// enumerating for potential events existing in our server.
|
/// enumerating for potential events existing in our server.
|
||||||
async fn delay_response() {
|
async fn delay_response() {
|
||||||
let time_to_wait = rand::thread_rng().gen_range(2..5);
|
let time_to_wait = rand::random_range(2..5);
|
||||||
debug_info!(
|
debug_info!(
|
||||||
"Got successful /report request, waiting {time_to_wait} seconds before sending \
|
"Got successful /report request, waiting {time_to_wait} seconds before sending \
|
||||||
successful response."
|
successful response."
|
||||||
|
|||||||
@@ -342,10 +342,10 @@ async fn allowed_to_send_state_event(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for alias in aliases {
|
for alias in aliases {
|
||||||
let (alias_room_id, _servers) = services
|
let (alias_room_id, _) = services
|
||||||
.rooms
|
.rooms
|
||||||
.alias
|
.alias
|
||||||
.resolve_alias(&alias, None)
|
.resolve_alias(&alias)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
err!(Request(Unknown("Failed resolving alias \"{alias}\": {e}")))
|
err!(Request(Unknown("Failed resolving alias \"{alias}\": {e}")))
|
||||||
|
|||||||
+16
-16
@@ -122,23 +122,23 @@ pub fn build(router: Router<State>, server: &Server) -> Router<State> {
|
|||||||
// Ruma doesn't have support for multiple paths for a single endpoint yet, and these routes
|
// Ruma doesn't have support for multiple paths for a single endpoint yet, and these routes
|
||||||
// share one Ruma request / response type pair with {get,send}_state_event_for_key_route
|
// share one Ruma request / response type pair with {get,send}_state_event_for_key_route
|
||||||
.route(
|
.route(
|
||||||
"/_matrix/client/r0/rooms/:room_id/state/:event_type",
|
"/_matrix/client/r0/rooms/{room_id}/state/{event_type}",
|
||||||
get(client::get_state_events_for_empty_key_route)
|
get(client::get_state_events_for_empty_key_route)
|
||||||
.put(client::send_state_event_for_empty_key_route),
|
.put(client::send_state_event_for_empty_key_route),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/_matrix/client/v3/rooms/:room_id/state/:event_type",
|
"/_matrix/client/v3/rooms/{room_id}/state/{event_type}",
|
||||||
get(client::get_state_events_for_empty_key_route)
|
get(client::get_state_events_for_empty_key_route)
|
||||||
.put(client::send_state_event_for_empty_key_route),
|
.put(client::send_state_event_for_empty_key_route),
|
||||||
)
|
)
|
||||||
// These two endpoints allow trailing slashes
|
// These two endpoints allow trailing slashes
|
||||||
.route(
|
.route(
|
||||||
"/_matrix/client/r0/rooms/:room_id/state/:event_type/",
|
"/_matrix/client/r0/rooms/{room_id}/state/{event_type}/",
|
||||||
get(client::get_state_events_for_empty_key_route)
|
get(client::get_state_events_for_empty_key_route)
|
||||||
.put(client::send_state_event_for_empty_key_route),
|
.put(client::send_state_event_for_empty_key_route),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/_matrix/client/v3/rooms/:room_id/state/:event_type/",
|
"/_matrix/client/v3/rooms/{room_id}/state/{event_type}/",
|
||||||
get(client::get_state_events_for_empty_key_route)
|
get(client::get_state_events_for_empty_key_route)
|
||||||
.put(client::send_state_event_for_empty_key_route),
|
.put(client::send_state_event_for_empty_key_route),
|
||||||
)
|
)
|
||||||
@@ -177,7 +177,7 @@ pub fn build(router: Router<State>, server: &Server) -> Router<State> {
|
|||||||
.ruma_route(&client::get_mutual_rooms_route)
|
.ruma_route(&client::get_mutual_rooms_route)
|
||||||
.ruma_route(&client::get_room_summary)
|
.ruma_route(&client::get_room_summary)
|
||||||
.route(
|
.route(
|
||||||
"/_matrix/client/unstable/im.nheko.summary/rooms/:room_id_or_alias/summary",
|
"/_matrix/client/unstable/im.nheko.summary/rooms/{room_id_or_alias}/summary",
|
||||||
get(client::get_room_summary_legacy)
|
get(client::get_room_summary_legacy)
|
||||||
)
|
)
|
||||||
.ruma_route(&client::get_suspended_status)
|
.ruma_route(&client::get_suspended_status)
|
||||||
@@ -196,7 +196,7 @@ pub fn build(router: Router<State>, server: &Server) -> Router<State> {
|
|||||||
.ruma_route(&server::get_server_version_route)
|
.ruma_route(&server::get_server_version_route)
|
||||||
.route("/_matrix/key/v2/server", get(server::get_server_keys_route))
|
.route("/_matrix/key/v2/server", get(server::get_server_keys_route))
|
||||||
.route(
|
.route(
|
||||||
"/_matrix/key/v2/server/:key_id",
|
"/_matrix/key/v2/server/{key_id}",
|
||||||
get(server::get_server_keys_deprecated_route),
|
get(server::get_server_keys_deprecated_route),
|
||||||
)
|
)
|
||||||
.ruma_route(&server::get_public_rooms_route)
|
.ruma_route(&server::get_public_rooms_route)
|
||||||
@@ -232,9 +232,9 @@ pub fn build(router: Router<State>, server: &Server) -> Router<State> {
|
|||||||
.route("/_continuwuity/local_user_count", get(client::conduwuit_local_user_count));
|
.route("/_continuwuity/local_user_count", get(client::conduwuit_local_user_count));
|
||||||
} else {
|
} else {
|
||||||
router = router
|
router = router
|
||||||
.route("/_matrix/federation/*path", any(federation_disabled))
|
.route("/_matrix/federation/{*path}", any(federation_disabled))
|
||||||
.route("/.well-known/matrix/server", any(federation_disabled))
|
.route("/.well-known/matrix/server", any(federation_disabled))
|
||||||
.route("/_matrix/key/*path", any(federation_disabled))
|
.route("/_matrix/key/{*path}", any(federation_disabled))
|
||||||
.route("/_conduwuit/local_user_count", any(federation_disabled))
|
.route("/_conduwuit/local_user_count", any(federation_disabled))
|
||||||
.route("/_continuwuity/local_user_count", any(federation_disabled));
|
.route("/_continuwuity/local_user_count", any(federation_disabled));
|
||||||
}
|
}
|
||||||
@@ -253,27 +253,27 @@ pub fn build(router: Router<State>, server: &Server) -> Router<State> {
|
|||||||
get(client::get_media_preview_legacy_legacy_route),
|
get(client::get_media_preview_legacy_legacy_route),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/_matrix/media/v1/download/:server_name/:media_id",
|
"/_matrix/media/v1/download/{server_name}/{media_id}",
|
||||||
get(client::get_content_legacy_legacy_route),
|
get(client::get_content_legacy_legacy_route),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/_matrix/media/v1/download/:server_name/:media_id/:file_name",
|
"/_matrix/media/v1/download/{server_name}/{media_id}/{file_name}",
|
||||||
get(client::get_content_as_filename_legacy_legacy_route),
|
get(client::get_content_as_filename_legacy_legacy_route),
|
||||||
)
|
)
|
||||||
.route(
|
.route(
|
||||||
"/_matrix/media/v1/thumbnail/:server_name/:media_id",
|
"/_matrix/media/v1/thumbnail/{server_name}/{media_id}",
|
||||||
get(client::get_content_thumbnail_legacy_legacy_route),
|
get(client::get_content_thumbnail_legacy_legacy_route),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
router = router
|
router = router
|
||||||
.route("/_matrix/media/v1/*path", any(legacy_media_disabled))
|
.route("/_matrix/media/v1/{*path}", any(legacy_media_disabled))
|
||||||
.route("/_matrix/media/v3/config", any(legacy_media_disabled))
|
.route("/_matrix/media/v3/config", any(legacy_media_disabled))
|
||||||
.route("/_matrix/media/v3/download/*path", any(legacy_media_disabled))
|
.route("/_matrix/media/v3/download/{*path}", any(legacy_media_disabled))
|
||||||
.route("/_matrix/media/v3/thumbnail/*path", any(legacy_media_disabled))
|
.route("/_matrix/media/v3/thumbnail/{*path}", any(legacy_media_disabled))
|
||||||
.route("/_matrix/media/v3/preview_url", any(redirect_legacy_preview))
|
.route("/_matrix/media/v3/preview_url", any(redirect_legacy_preview))
|
||||||
.route("/_matrix/media/r0/config", any(legacy_media_disabled))
|
.route("/_matrix/media/r0/config", any(legacy_media_disabled))
|
||||||
.route("/_matrix/media/r0/download/*path", any(legacy_media_disabled))
|
.route("/_matrix/media/r0/download/{*path}", any(legacy_media_disabled))
|
||||||
.route("/_matrix/media/r0/thumbnail/*path", any(legacy_media_disabled))
|
.route("/_matrix/media/r0/thumbnail/{*path}", any(legacy_media_disabled))
|
||||||
.route("/_matrix/media/r0/preview_url", any(redirect_legacy_preview));
|
.route("/_matrix/media/r0/preview_url", any(redirect_legacy_preview));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use std::{mem, ops::Deref};
|
use std::{mem, ops::Deref};
|
||||||
|
|
||||||
use async_trait::async_trait;
|
|
||||||
use axum::{body::Body, extract::FromRequest};
|
use axum::{body::Body, extract::FromRequest};
|
||||||
use bytes::{BufMut, Bytes, BytesMut};
|
use bytes::{BufMut, Bytes, BytesMut};
|
||||||
use conduwuit::{Error, Result, debug, debug_warn, err, trace, utils::string::EMPTY};
|
use conduwuit::{Error, Result, debug, debug_warn, err, trace, utils::string::EMPTY};
|
||||||
@@ -79,7 +78,6 @@ where
|
|||||||
fn deref(&self) -> &Self::Target { &self.body }
|
fn deref(&self) -> &Self::Target { &self.body }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl<T> FromRequest<State, Body> for Args<T>
|
impl<T> FromRequest<State, Body> for Args<T>
|
||||||
where
|
where
|
||||||
T: IncomingRequest + Send + Sync + 'static,
|
T: IncomingRequest + Send + Sync + 'static,
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ pub(super) async fn auth(
|
|||||||
json_body: Option<&CanonicalJsonValue>,
|
json_body: Option<&CanonicalJsonValue>,
|
||||||
metadata: &Metadata,
|
metadata: &Metadata,
|
||||||
) -> Result<Auth> {
|
) -> Result<Auth> {
|
||||||
let bearer: Option<TypedHeader<Authorization<Bearer>>> = request.parts.extract().await?;
|
let bearer: Option<TypedHeader<Authorization<Bearer>>> =
|
||||||
|
request.parts.extract().await.unwrap_or(None);
|
||||||
let token = match &bearer {
|
let token = match &bearer {
|
||||||
| Some(TypedHeader(Authorization(bearer))) => Some(bearer.token()),
|
| Some(TypedHeader(Authorization(bearer))) => Some(bearer.token()),
|
||||||
| None => request.query.access_token.as_deref(),
|
| None => request.query.access_token.as_deref(),
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ pub(crate) async fn get_room_information_route(
|
|||||||
servers.sort_unstable();
|
servers.sort_unstable();
|
||||||
servers.dedup();
|
servers.dedup();
|
||||||
|
|
||||||
servers.shuffle(&mut rand::thread_rng());
|
servers.shuffle(&mut rand::rng());
|
||||||
|
|
||||||
// insert our server as the very first choice if in list
|
// insert our server as the very first choice if in list
|
||||||
if let Some(server_index) = servers
|
if let Some(server_index) = servers
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ libloading.optional = true
|
|||||||
log.workspace = true
|
log.workspace = true
|
||||||
num-traits.workspace = true
|
num-traits.workspace = true
|
||||||
rand.workspace = true
|
rand.workspace = true
|
||||||
|
rand_core = { version = "0.6.4", features = ["getrandom"] }
|
||||||
regex.workspace = true
|
regex.workspace = true
|
||||||
reqwest.workspace = true
|
reqwest.workspace = true
|
||||||
ring.workspace = true
|
ring.workspace = true
|
||||||
|
|||||||
+26
-17
@@ -1244,12 +1244,6 @@ pub struct Config {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub rocksdb_repair: bool,
|
pub rocksdb_repair: bool,
|
||||||
|
|
||||||
#[serde(default)]
|
|
||||||
pub rocksdb_read_only: bool,
|
|
||||||
|
|
||||||
#[serde(default)]
|
|
||||||
pub rocksdb_secondary: bool,
|
|
||||||
|
|
||||||
/// Enables idle CPU priority for compaction thread. This is not enabled by
|
/// Enables idle CPU priority for compaction thread. This is not enabled by
|
||||||
/// default to prevent compaction from falling too far behind on busy
|
/// default to prevent compaction from falling too far behind on busy
|
||||||
/// systems.
|
/// systems.
|
||||||
@@ -1309,26 +1303,33 @@ pub struct Config {
|
|||||||
|
|
||||||
/// Allow local (your server only) presence updates/requests.
|
/// Allow local (your server only) presence updates/requests.
|
||||||
///
|
///
|
||||||
/// Note that presence on continuwuity is very fast unlike Synapse's. If
|
/// Local presence must be enabled for outgoing presence to function.
|
||||||
/// using outgoing presence, this MUST be enabled.
|
///
|
||||||
|
/// Note that local presence is not as heavy on the CPU as federated
|
||||||
|
/// presence, but will still become more expensive the more local users you
|
||||||
|
/// have.
|
||||||
#[serde(default = "true_fn")]
|
#[serde(default = "true_fn")]
|
||||||
pub allow_local_presence: bool,
|
pub allow_local_presence: bool,
|
||||||
|
|
||||||
/// Allow incoming federated presence updates/requests.
|
/// Allow incoming federated presence updates.
|
||||||
///
|
///
|
||||||
/// This option receives presence updates from other servers, but does not
|
/// This option enables processing inbound presence updates from other
|
||||||
/// send any unless `allow_outgoing_presence` is true. Note that presence on
|
/// servers. Without it, remote users will appear as if they are always
|
||||||
/// continuwuity is very fast unlike Synapse's.
|
/// offline to your local users. This does not affect typing indicators or
|
||||||
|
/// read receipts.
|
||||||
#[serde(default = "true_fn")]
|
#[serde(default = "true_fn")]
|
||||||
pub allow_incoming_presence: bool,
|
pub allow_incoming_presence: bool,
|
||||||
|
|
||||||
/// Allow outgoing presence updates/requests.
|
/// Allow outgoing presence updates/requests.
|
||||||
///
|
///
|
||||||
/// This option sends presence updates to other servers, but does not
|
/// This option sends presence updates to other servers, and requires that
|
||||||
/// receive any unless `allow_incoming_presence` is true. Note that presence
|
/// `allow_local_presence` is also enabled.
|
||||||
/// on continuwuity is very fast unlike Synapse's. If using outgoing
|
///
|
||||||
/// presence, you MUST enable `allow_local_presence` as well.
|
/// Note that outgoing presence is very heavy on the CPU and network, and
|
||||||
#[serde(default = "true_fn")]
|
/// will typically cause extreme strain and slowdowns for no real benefit.
|
||||||
|
/// There are only a few clients that even implement presence, so you
|
||||||
|
/// probably don't want to enable this.
|
||||||
|
#[serde(default)]
|
||||||
pub allow_outgoing_presence: bool,
|
pub allow_outgoing_presence: bool,
|
||||||
|
|
||||||
/// How many seconds without presence updates before you become idle.
|
/// How many seconds without presence updates before you become idle.
|
||||||
@@ -1366,6 +1367,10 @@ pub struct Config {
|
|||||||
pub allow_incoming_read_receipts: bool,
|
pub allow_incoming_read_receipts: bool,
|
||||||
|
|
||||||
/// Allow sending read receipts to remote servers.
|
/// Allow sending read receipts to remote servers.
|
||||||
|
///
|
||||||
|
/// Note that sending read receipts to remote servers in large rooms with
|
||||||
|
/// lots of other homeservers may cause additional strain on the CPU and
|
||||||
|
/// network.
|
||||||
#[serde(default = "true_fn")]
|
#[serde(default = "true_fn")]
|
||||||
pub allow_outgoing_read_receipts: bool,
|
pub allow_outgoing_read_receipts: bool,
|
||||||
|
|
||||||
@@ -1377,6 +1382,10 @@ pub struct Config {
|
|||||||
pub allow_local_typing: bool,
|
pub allow_local_typing: bool,
|
||||||
|
|
||||||
/// Allow outgoing typing updates to federation.
|
/// Allow outgoing typing updates to federation.
|
||||||
|
///
|
||||||
|
/// Note that sending typing indicators to remote servers in large rooms
|
||||||
|
/// with lots of other homeservers may cause additional strain on the CPU
|
||||||
|
/// and network.
|
||||||
#[serde(default = "true_fn")]
|
#[serde(default = "true_fn")]
|
||||||
pub allow_outgoing_typing: bool,
|
pub allow_outgoing_typing: bool,
|
||||||
|
|
||||||
|
|||||||
@@ -1046,7 +1046,7 @@ mod tests {
|
|||||||
// don't remove any events so we know it sorts them all correctly
|
// don't remove any events so we know it sorts them all correctly
|
||||||
let mut events_to_sort = events.keys().cloned().collect::<Vec<_>>();
|
let mut events_to_sort = events.keys().cloned().collect::<Vec<_>>();
|
||||||
|
|
||||||
events_to_sort.shuffle(&mut rand::thread_rng());
|
events_to_sort.shuffle(&mut rand::rng());
|
||||||
|
|
||||||
let power_level = resolved_power
|
let power_level = resolved_power
|
||||||
.get(&(StateEventType::RoomPowerLevels, "".into()))
|
.get(&(StateEventType::RoomPowerLevels, "".into()))
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ fn init_argon() -> Argon2<'static> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn password(password: &str) -> Result<String> {
|
pub(super) fn password(password: &str) -> Result<String> {
|
||||||
let salt = SaltString::generate(rand::thread_rng());
|
let salt = SaltString::generate(rand_core::OsRng);
|
||||||
ARGON
|
ARGON
|
||||||
.get_or_init(init_argon)
|
.get_or_init(init_argon)
|
||||||
.hash_password(password.as_bytes(), &salt)
|
.hash_password(password.as_bytes(), &salt)
|
||||||
|
|||||||
+7
-10
@@ -4,16 +4,16 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use arrayvec::ArrayString;
|
use arrayvec::ArrayString;
|
||||||
use rand::{Rng, seq::SliceRandom, thread_rng};
|
use rand::{Rng, RngExt, seq::SliceRandom};
|
||||||
|
|
||||||
pub fn shuffle<T>(vec: &mut [T]) {
|
pub fn shuffle<T>(vec: &mut [T]) {
|
||||||
let mut rng = thread_rng();
|
let mut rng = rand::rng();
|
||||||
vec.shuffle(&mut rng);
|
vec.shuffle(&mut rng);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn string(length: usize) -> String {
|
pub fn string(length: usize) -> String {
|
||||||
thread_rng()
|
rand::rng()
|
||||||
.sample_iter(&rand::distributions::Alphanumeric)
|
.sample_iter(&rand::distr::Alphanumeric)
|
||||||
.take(length)
|
.take(length)
|
||||||
.map(char::from)
|
.map(char::from)
|
||||||
.collect()
|
.collect()
|
||||||
@@ -22,8 +22,8 @@ pub fn string(length: usize) -> String {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn string_array<const LENGTH: usize>() -> ArrayString<LENGTH> {
|
pub fn string_array<const LENGTH: usize>() -> ArrayString<LENGTH> {
|
||||||
let mut ret = ArrayString::<LENGTH>::new();
|
let mut ret = ArrayString::<LENGTH>::new();
|
||||||
thread_rng()
|
rand::rng()
|
||||||
.sample_iter(&rand::distributions::Alphanumeric)
|
.sample_iter(&rand::distr::Alphanumeric)
|
||||||
.take(LENGTH)
|
.take(LENGTH)
|
||||||
.map(char::from)
|
.map(char::from)
|
||||||
.for_each(|c| ret.push(c));
|
.for_each(|c| ret.push(c));
|
||||||
@@ -40,7 +40,4 @@ pub fn time_from_now_secs(range: Range<u64>) -> SystemTime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn secs(range: Range<u64>) -> Duration {
|
pub fn secs(range: Range<u64>) -> Duration { Duration::from_secs(rand::random_range(range)) }
|
||||||
let mut rng = thread_rng();
|
|
||||||
Duration::from_secs(rng.gen_range(range))
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ pub struct Engine {
|
|||||||
pub(crate) db: Db,
|
pub(crate) db: Db,
|
||||||
pub(crate) pool: Arc<Pool>,
|
pub(crate) pool: Arc<Pool>,
|
||||||
pub(crate) ctx: Arc<Context>,
|
pub(crate) ctx: Arc<Context>,
|
||||||
pub(super) read_only: bool,
|
|
||||||
pub(super) secondary: bool,
|
|
||||||
pub(crate) checksums: bool,
|
pub(crate) checksums: bool,
|
||||||
corks: AtomicU32,
|
corks: AtomicU32,
|
||||||
}
|
}
|
||||||
@@ -129,14 +127,6 @@ impl Engine {
|
|||||||
|
|
||||||
sequence
|
sequence
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[must_use]
|
|
||||||
pub fn is_read_only(&self) -> bool { self.secondary || self.read_only }
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[must_use]
|
|
||||||
pub fn is_secondary(&self) -> bool { self.secondary }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Engine {
|
impl Drop for Engine {
|
||||||
|
|||||||
@@ -12,9 +12,8 @@ pub fn backup(&self) -> Result {
|
|||||||
let mut engine = self.backup_engine()?;
|
let mut engine = self.backup_engine()?;
|
||||||
let config = &self.ctx.server.config;
|
let config = &self.ctx.server.config;
|
||||||
if config.database_backups_to_keep > 0 {
|
if config.database_backups_to_keep > 0 {
|
||||||
let flush = !self.is_read_only();
|
|
||||||
engine
|
engine
|
||||||
.create_new_backup_flush(&self.db, flush)
|
.create_new_backup_flush(&self.db, true)
|
||||||
.map_err(map_err)?;
|
.map_err(map_err)?;
|
||||||
|
|
||||||
let engine_info = engine.get_backup_info();
|
let engine_info = engine.get_backup_info();
|
||||||
|
|||||||
@@ -35,14 +35,7 @@ pub(crate) async fn open(ctx: Arc<Context>, desc: &[Descriptor]) -> Result<Arc<S
|
|||||||
}
|
}
|
||||||
|
|
||||||
debug!("Opening database...");
|
debug!("Opening database...");
|
||||||
let db = if config.rocksdb_read_only {
|
let db = Db::open_cf_descriptors(&db_opts, path, cfds).or_else(or_else)?;
|
||||||
Db::open_cf_descriptors_read_only(&db_opts, path, cfds, false)
|
|
||||||
} else if config.rocksdb_secondary {
|
|
||||||
Db::open_cf_descriptors_as_secondary(&db_opts, path, path, cfds)
|
|
||||||
} else {
|
|
||||||
Db::open_cf_descriptors(&db_opts, path, cfds)
|
|
||||||
}
|
|
||||||
.or_else(or_else)?;
|
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
columns = num_cfds,
|
columns = num_cfds,
|
||||||
@@ -55,8 +48,6 @@ pub(crate) async fn open(ctx: Arc<Context>, desc: &[Descriptor]) -> Result<Arc<S
|
|||||||
db,
|
db,
|
||||||
pool: ctx.pool.clone(),
|
pool: ctx.pool.clone(),
|
||||||
ctx: ctx.clone(),
|
ctx: ctx.clone(),
|
||||||
read_only: config.rocksdb_read_only,
|
|
||||||
secondary: config.rocksdb_secondary,
|
|
||||||
checksums: config.rocksdb_checksums,
|
checksums: config.rocksdb_checksums,
|
||||||
corks: AtomicU32::new(0),
|
corks: AtomicU32::new(0),
|
||||||
}))
|
}))
|
||||||
|
|||||||
@@ -74,14 +74,6 @@ impl Database {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn keys(&self) -> impl Iterator<Item = &MapsKey> + Send + '_ { self.maps.keys() }
|
pub fn keys(&self) -> impl Iterator<Item = &MapsKey> + Send + '_ { self.maps.keys() }
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[must_use]
|
|
||||||
pub fn is_read_only(&self) -> bool { self.db.is_read_only() }
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[must_use]
|
|
||||||
pub fn is_secondary(&self) -> bool { self.db.is_secondary() }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Index<&str> for Database {
|
impl Index<&str> for Database {
|
||||||
|
|||||||
+1
-9
@@ -27,10 +27,6 @@ pub struct Args {
|
|||||||
#[arg(long, short('O'))]
|
#[arg(long, short('O'))]
|
||||||
pub option: Vec<String>,
|
pub option: Vec<String>,
|
||||||
|
|
||||||
/// Run in a stricter read-only --maintenance mode.
|
|
||||||
#[arg(long)]
|
|
||||||
pub read_only: bool,
|
|
||||||
|
|
||||||
/// Run in maintenance mode while refusing connections.
|
/// Run in maintenance mode while refusing connections.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub maintenance: bool,
|
pub maintenance: bool,
|
||||||
@@ -143,11 +139,7 @@ pub(crate) fn parse() -> Args { Args::parse() }
|
|||||||
|
|
||||||
/// Synthesize any command line options with configuration file options.
|
/// Synthesize any command line options with configuration file options.
|
||||||
pub(crate) fn update(mut config: Figment, args: &Args) -> Result<Figment> {
|
pub(crate) fn update(mut config: Figment, args: &Args) -> Result<Figment> {
|
||||||
if args.read_only {
|
if args.maintenance {
|
||||||
config = config.join(("rocksdb_read_only", true));
|
|
||||||
}
|
|
||||||
|
|
||||||
if args.maintenance || args.read_only {
|
|
||||||
config = config.join(("startup_netburst", false));
|
config = config.join(("startup_netburst", false));
|
||||||
config = config.join(("listening", false));
|
config = config.join(("listening", false));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,8 +100,7 @@ impl crate::Service for Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let first_check_jitter = {
|
let first_check_jitter = {
|
||||||
let mut rng = rand::thread_rng();
|
let jitter_percent = rand::random_range(-50.0..=10.0);
|
||||||
let jitter_percent = rng.gen_range(-50.0..=10.0);
|
|
||||||
self.interval.mul_f64(1.0 + jitter_percent / 100.0)
|
self.interval.mul_f64(1.0 + jitter_percent / 100.0)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -37,10 +37,6 @@ impl crate::Service for Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn worker(self: Arc<Self>) -> Result {
|
async fn worker(self: Arc<Self>) -> Result {
|
||||||
if self.services.globals.is_read_only() {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.services.config.ldap.enable {
|
if self.services.config.ldap.enable {
|
||||||
warn!("emergency password feature not available with LDAP enabled.");
|
warn!("emergency password feature not available with LDAP enabled.");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|||||||
@@ -156,7 +156,4 @@ impl Service {
|
|||||||
pub fn server_is_ours(&self, server_name: &ServerName) -> bool {
|
pub fn server_is_ours(&self, server_name: &ServerName) -> bool {
|
||||||
server_name == self.server_name()
|
server_name == self.server_name()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn is_read_only(&self) -> bool { self.db.db.is_read_only() }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ mod remote;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Event, Result, Server, err,
|
Err, Event, Result, err,
|
||||||
utils::{ReadyExt, stream::TryIgnore},
|
utils::{ReadyExt, stream::TryIgnore},
|
||||||
};
|
};
|
||||||
use database::{Deserialized, Ignore, Interfix, Map};
|
use database::{Deserialized, Ignore, Interfix, Map};
|
||||||
@@ -30,12 +30,12 @@ struct Data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct Services {
|
struct Services {
|
||||||
server: Arc<Server>,
|
|
||||||
admin: Dep<admin::Service>,
|
admin: Dep<admin::Service>,
|
||||||
appservice: Dep<appservice::Service>,
|
appservice: Dep<appservice::Service>,
|
||||||
globals: Dep<globals::Service>,
|
globals: Dep<globals::Service>,
|
||||||
sending: Dep<sending::Service>,
|
sending: Dep<sending::Service>,
|
||||||
state_accessor: Dep<rooms::state_accessor::Service>,
|
state_accessor: Dep<rooms::state_accessor::Service>,
|
||||||
|
state_cache: Dep<rooms::state_cache::Service>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::Service for Service {
|
impl crate::Service for Service {
|
||||||
@@ -47,13 +47,13 @@ impl crate::Service for Service {
|
|||||||
aliasid_alias: args.db["aliasid_alias"].clone(),
|
aliasid_alias: args.db["aliasid_alias"].clone(),
|
||||||
},
|
},
|
||||||
services: Services {
|
services: Services {
|
||||||
server: args.server.clone(),
|
|
||||||
admin: args.depend::<admin::Service>("admin"),
|
admin: args.depend::<admin::Service>("admin"),
|
||||||
appservice: args.depend::<appservice::Service>("appservice"),
|
appservice: args.depend::<appservice::Service>("appservice"),
|
||||||
globals: args.depend::<globals::Service>("globals"),
|
globals: args.depend::<globals::Service>("globals"),
|
||||||
sending: args.depend::<sending::Service>("sending"),
|
sending: args.depend::<sending::Service>("sending"),
|
||||||
state_accessor: args
|
state_accessor: args
|
||||||
.depend::<rooms::state_accessor::Service>("rooms::state_accessor"),
|
.depend::<rooms::state_accessor::Service>("rooms::state_accessor"),
|
||||||
|
state_cache: args.depend::<rooms::state_cache::Service>("rooms::state_cache"),
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@@ -117,6 +117,9 @@ impl Service {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Resolves the given room ID or alias, returning the resolved room ID.
|
||||||
|
/// Unlike resolve_with_servers (the underlying call), potential resident
|
||||||
|
/// servers are not returned
|
||||||
#[inline]
|
#[inline]
|
||||||
pub async fn resolve(&self, room: &RoomOrAliasId) -> Result<OwnedRoomId> {
|
pub async fn resolve(&self, room: &RoomOrAliasId) -> Result<OwnedRoomId> {
|
||||||
self.resolve_with_servers(room, None)
|
self.resolve_with_servers(room, None)
|
||||||
@@ -124,6 +127,14 @@ impl Service {
|
|||||||
.map(|(room_id, _)| room_id)
|
.map(|(room_id, _)| room_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Resolves the given room ID or alias, returning the resolved room ID, and
|
||||||
|
/// any servers that might be able to assist in fetching room data.
|
||||||
|
///
|
||||||
|
/// If the input is a room ID, this simply returns it and <servers>.
|
||||||
|
/// If the input is an alias, this attempts to resolve it locally, then via
|
||||||
|
/// appservices, and finally remotely if the alias is not local.
|
||||||
|
/// If the alias is successfully resolved, the room ID and an empty list of
|
||||||
|
/// servers is returned.
|
||||||
pub async fn resolve_with_servers(
|
pub async fn resolve_with_servers(
|
||||||
&self,
|
&self,
|
||||||
room: &RoomOrAliasId,
|
room: &RoomOrAliasId,
|
||||||
@@ -134,28 +145,26 @@ impl Service {
|
|||||||
Ok((room_id.to_owned(), servers.unwrap_or_default()))
|
Ok((room_id.to_owned(), servers.unwrap_or_default()))
|
||||||
} else {
|
} else {
|
||||||
let alias: &RoomAliasId = room.try_into().expect("valid RoomAliasId");
|
let alias: &RoomAliasId = room.try_into().expect("valid RoomAliasId");
|
||||||
self.resolve_alias(alias, servers).await
|
self.resolve_alias(alias).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Resolves the given room alias, returning the resolved room ID and any
|
||||||
|
/// servers that might be in the room.
|
||||||
#[tracing::instrument(skip(self), name = "resolve")]
|
#[tracing::instrument(skip(self), name = "resolve")]
|
||||||
pub async fn resolve_alias(
|
pub async fn resolve_alias(
|
||||||
&self,
|
&self,
|
||||||
room_alias: &RoomAliasId,
|
room_alias: &RoomAliasId,
|
||||||
servers: Option<Vec<OwnedServerName>>,
|
|
||||||
) -> Result<(OwnedRoomId, Vec<OwnedServerName>)> {
|
) -> Result<(OwnedRoomId, Vec<OwnedServerName>)> {
|
||||||
let server_name = room_alias.server_name();
|
let server_is_ours = self
|
||||||
let server_is_ours = self.services.globals.server_is_ours(server_name);
|
.services
|
||||||
let servers_contains_ours = || {
|
.globals
|
||||||
servers
|
.server_is_ours(room_alias.server_name());
|
||||||
.as_ref()
|
|
||||||
.is_some_and(|servers| servers.contains(&self.services.server.name))
|
|
||||||
};
|
|
||||||
|
|
||||||
if !server_is_ours && !servers_contains_ours() {
|
if !server_is_ours {
|
||||||
return self
|
// TODO: The spec advises servers may cache remote room aliases temporarily.
|
||||||
.remote_resolve(room_alias, servers.unwrap_or_default())
|
// We might want to look at doing that.
|
||||||
.await;
|
return self.remote_resolve(room_alias).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
let room_id = match self.resolve_local_alias(room_alias).await {
|
let room_id = match self.resolve_local_alias(room_alias).await {
|
||||||
@@ -163,10 +172,18 @@ impl Service {
|
|||||||
| Err(_) => self.resolve_appservice_alias(room_alias).await?,
|
| Err(_) => self.resolve_appservice_alias(room_alias).await?,
|
||||||
};
|
};
|
||||||
|
|
||||||
room_id.map_or_else(
|
if let Some(room_id) = room_id {
|
||||||
|| Err!(Request(NotFound("Room with alias not found."))),
|
let servers: Vec<OwnedServerName> = self
|
||||||
|room_id| Ok((room_id, Vec::new())),
|
.services
|
||||||
)
|
.state_cache
|
||||||
|
.room_servers(&room_id)
|
||||||
|
.map(ToOwned::to_owned)
|
||||||
|
.collect()
|
||||||
|
.await;
|
||||||
|
return Ok((room_id, servers));
|
||||||
|
}
|
||||||
|
|
||||||
|
Err!(Request(NotFound("Alias does not exist.")))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self), level = "debug")]
|
#[tracing::instrument(skip(self), level = "debug")]
|
||||||
@@ -206,12 +223,12 @@ impl Service {
|
|||||||
|
|
||||||
// The creator of an alias can remove it
|
// The creator of an alias can remove it
|
||||||
if self
|
if self
|
||||||
.who_created_alias(alias).await
|
.who_created_alias(alias).await
|
||||||
.is_ok_and(|user| user == user_id)
|
.is_ok_and(|user| user == user_id)
|
||||||
// Server admins can remove any local alias
|
// Server admins can remove any local alias
|
||||||
|| self.services.admin.user_is_admin(user_id).await
|
|| self.services.admin.user_is_admin(user_id).await
|
||||||
// Always allow the server service account to remove the alias, since there may not be an admin room
|
// Always allow the server service account to remove the alias, since there may not be an admin room
|
||||||
|| server_user == user_id
|
|| server_user == user_id
|
||||||
{
|
{
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
use std::iter::once;
|
use conduwuit::{Result, debug, error, implement};
|
||||||
|
|
||||||
use conduwuit::{Result, debug, debug_error, err, implement};
|
|
||||||
use federation::query::get_room_information::v1::Response;
|
use federation::query::get_room_information::v1::Response;
|
||||||
use ruma::{OwnedRoomId, OwnedServerName, RoomAliasId, ServerName, api::federation};
|
use ruma::{OwnedRoomId, OwnedServerName, RoomAliasId, ServerName, api::federation};
|
||||||
|
|
||||||
@@ -8,40 +6,21 @@ use ruma::{OwnedRoomId, OwnedServerName, RoomAliasId, ServerName, api::federatio
|
|||||||
pub(super) async fn remote_resolve(
|
pub(super) async fn remote_resolve(
|
||||||
&self,
|
&self,
|
||||||
room_alias: &RoomAliasId,
|
room_alias: &RoomAliasId,
|
||||||
servers: Vec<OwnedServerName>,
|
|
||||||
) -> Result<(OwnedRoomId, Vec<OwnedServerName>)> {
|
) -> Result<(OwnedRoomId, Vec<OwnedServerName>)> {
|
||||||
debug!(?room_alias, servers = ?servers, "resolve");
|
debug!("Asking {} to resolve {room_alias:?}", room_alias.server_name());
|
||||||
let servers = once(room_alias.server_name())
|
match self
|
||||||
.map(ToOwned::to_owned)
|
.remote_request(room_alias, room_alias.server_name())
|
||||||
.chain(servers.into_iter());
|
.await
|
||||||
|
{
|
||||||
let mut resolved_servers = Vec::new();
|
| Err(e) => {
|
||||||
let mut resolved_room_id: Option<OwnedRoomId> = None;
|
error!("Unable to resolve remote room alias {}: {e}", room_alias);
|
||||||
for server in servers {
|
Err(e)
|
||||||
match self.remote_request(room_alias, &server).await {
|
},
|
||||||
| Err(e) => debug_error!("Failed to query for {room_alias:?} from {server}: {e}"),
|
| Ok(Response { room_id, servers }) => {
|
||||||
| Ok(Response { room_id, servers }) => {
|
debug!("Remote resolved {room_alias:?} to {room_id:?} with servers {servers:?}");
|
||||||
debug!(
|
Ok((room_id, servers))
|
||||||
"Server {server} answered with {room_id:?} for {room_alias:?} servers: \
|
},
|
||||||
{servers:?}"
|
|
||||||
);
|
|
||||||
|
|
||||||
resolved_room_id.get_or_insert(room_id);
|
|
||||||
add_server(&mut resolved_servers, server);
|
|
||||||
|
|
||||||
if !servers.is_empty() {
|
|
||||||
add_servers(&mut resolved_servers, servers);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resolved_room_id
|
|
||||||
.map(|room_id| (room_id, resolved_servers))
|
|
||||||
.ok_or_else(|| {
|
|
||||||
err!(Request(NotFound("No servers could assist in resolving the room alias")))
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[implement(super::Service)]
|
#[implement(super::Service)]
|
||||||
@@ -59,15 +38,3 @@ async fn remote_request(
|
|||||||
.send_federation_request(server, request)
|
.send_federation_request(server, request)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_servers(servers: &mut Vec<OwnedServerName>, new: Vec<OwnedServerName>) {
|
|
||||||
for server in new {
|
|
||||||
add_server(servers, server);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn add_server(servers: &mut Vec<OwnedServerName>, server: OwnedServerName) {
|
|
||||||
if !servers.contains(&server) {
|
|
||||||
servers.push(server);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -139,7 +139,12 @@ pub async fn backfill_if_required(&self, room_id: &RoomId, from: PduCount) -> Re
|
|||||||
})
|
})
|
||||||
.boxed();
|
.boxed();
|
||||||
|
|
||||||
|
let mut federated_room = false;
|
||||||
|
|
||||||
while let Some(ref backfill_server) = servers.next().await {
|
while let Some(ref backfill_server) = servers.next().await {
|
||||||
|
if !self.services.globals.server_is_ours(backfill_server) {
|
||||||
|
federated_room = true;
|
||||||
|
}
|
||||||
info!("Asking {backfill_server} for backfill in {room_id}");
|
info!("Asking {backfill_server} for backfill in {room_id}");
|
||||||
let response = self
|
let response = self
|
||||||
.services
|
.services
|
||||||
@@ -168,7 +173,9 @@ pub async fn backfill_if_required(&self, room_id: &RoomId, from: PduCount) -> Re
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
warn!("No servers could backfill, but backfill was needed in room {room_id}");
|
if federated_room {
|
||||||
|
warn!("No servers could backfill, but backfill was needed in room {room_id}");
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -385,11 +385,13 @@ fn num_senders(args: &crate::Args<'_>) -> usize {
|
|||||||
const MIN_SENDERS: usize = 1;
|
const MIN_SENDERS: usize = 1;
|
||||||
// Limit the number of senders to the number of workers threads or number of
|
// Limit the number of senders to the number of workers threads or number of
|
||||||
// cores, conservatively.
|
// cores, conservatively.
|
||||||
let max_senders = args
|
let mut max_senders = args.server.metrics.num_workers();
|
||||||
.server
|
|
||||||
.metrics
|
// Work around some platforms not returning the number of cores.
|
||||||
.num_workers()
|
let num_cores = available_parallelism();
|
||||||
.min(available_parallelism());
|
if num_cores > 0 {
|
||||||
|
max_senders = max_senders.min(num_cores);
|
||||||
|
}
|
||||||
|
|
||||||
// If the user doesn't override the default 0, this is intended to then default
|
// If the user doesn't override the default 0, this is intended to then default
|
||||||
// to 1 for now as multiple senders is experimental.
|
// to 1 for now as multiple senders is experimental.
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ impl Services {
|
|||||||
|
|
||||||
// reset dormant online/away statuses to offline, and set the server user as
|
// reset dormant online/away statuses to offline, and set the server user as
|
||||||
// online
|
// online
|
||||||
if self.server.config.allow_local_presence && !self.db.is_read_only() {
|
if self.server.config.allow_local_presence {
|
||||||
self.presence.unset_all_presence().await;
|
self.presence.unset_all_presence().await;
|
||||||
_ = self
|
_ = self
|
||||||
.presence
|
.presence
|
||||||
@@ -156,7 +156,7 @@ impl Services {
|
|||||||
info!("Shutting down services...");
|
info!("Shutting down services...");
|
||||||
|
|
||||||
// set the server user as offline
|
// set the server user as offline
|
||||||
if self.server.config.allow_local_presence && !self.db.is_read_only() {
|
if self.server.config.allow_local_presence {
|
||||||
_ = self
|
_ = self
|
||||||
.presence
|
.presence
|
||||||
.ping_presence(&self.globals.server_user, &ruma::presence::PresenceState::Offline)
|
.ping_presence(&self.globals.server_user, &ruma::presence::PresenceState::Offline)
|
||||||
|
|||||||
Reference in New Issue
Block a user