mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-22 08:27:32 +00:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7bc6db2d5 | ||
|
|
f65e0a83de | ||
|
|
290269c8a3 | ||
|
|
0269f3307d | ||
|
|
9e2e6941e2 | ||
|
|
fd06bca825 | ||
|
|
f3cb13802a |
No files matched your search
@@ -0,0 +1,52 @@
|
|||||||
|
name: Create release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
ref: "main"
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup Rust nightly
|
||||||
|
uses: ./.forgejo/actions/setup-rust
|
||||||
|
with:
|
||||||
|
rust-version: nightly
|
||||||
|
|
||||||
|
- name: Setup towncrier
|
||||||
|
run: uv tool install towncrier
|
||||||
|
|
||||||
|
- name: Generate release notes
|
||||||
|
run: cargo run --package xtask --no-default-features -- generate-release-notes > /tmp/RELEASE.md
|
||||||
|
|
||||||
|
- name: Create release
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
jq -n --rawfile body /tmp/RELEASE.md '{"body": $body, "tag_name": "${{ forgejo.ref_name }}", "name": "${{ forgejo.ref_name }}"}' \
|
||||||
|
| curl --fail-with-body \
|
||||||
|
--data-binary @- \
|
||||||
|
--header "Content-Type: application/json" \
|
||||||
|
--header "Accept: application/json" \
|
||||||
|
--header "Authorization: token ${{ forgejo.token }}" \
|
||||||
|
-X POST \
|
||||||
|
"${{ forgejo.server_url }}/api/v1/repos/${{ forgejo.repository }}/releases"
|
||||||
|
|
||||||
|
- name: Remove news fragments
|
||||||
|
run: git rm -r changelog.d/
|
||||||
|
|
||||||
|
- name: Commit changes
|
||||||
|
run: |
|
||||||
|
git config user.email "forgejo@mail.ellis.link"
|
||||||
|
git config user.name "Ellis Git"
|
||||||
|
|
||||||
|
git commit -am "chore: Post-release cleanup"
|
||||||
|
|
||||||
|
git push origin HEAD:refs/heads/main
|
||||||
@@ -31,7 +31,7 @@ repos:
|
|||||||
stages: [commit-msg]
|
stages: [commit-msg]
|
||||||
|
|
||||||
- repo: https://github.com/crate-ci/committed
|
- repo: https://github.com/crate-ci/committed
|
||||||
rev: v1.1.10
|
rev: v1.1.9
|
||||||
hooks:
|
hooks:
|
||||||
- id: committed
|
- id: committed
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,3 @@
|
|||||||
# Continuwuity 0.5.3 (2026-01-12)
|
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
- Improve the display of nested configuration with the `!admin server show-config` command. Contributed by @Jade (#1279)
|
|
||||||
|
|
||||||
## Bugfixes
|
|
||||||
|
|
||||||
- Fixed `M_BAD_JSON` error when sending invites to other servers or when providing joins. Contributed by @nex (#1286)
|
|
||||||
|
|
||||||
|
|
||||||
## Docs
|
|
||||||
|
|
||||||
- Improve admin command documentation generation. Contributed by @ginger (#1280)
|
|
||||||
|
|
||||||
|
|
||||||
## Misc
|
|
||||||
|
|
||||||
- Improve timeout-related code for federation and URL previews. Contributed by @Jade (#1278)
|
|
||||||
|
|
||||||
|
|
||||||
# Continuwuity 0.5.2 (2026-01-09)
|
# Continuwuity 0.5.2 (2026-01-09)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|||||||
Generated
+457
-556
File diff suppressed because it is too large.
Load diff
+3
-3
@@ -12,7 +12,7 @@ license = "Apache-2.0"
|
|||||||
# See also `rust-toolchain.toml`
|
# See also `rust-toolchain.toml`
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://forgejo.ellis.link/continuwuation/continuwuity"
|
repository = "https://forgejo.ellis.link/continuwuation/continuwuity"
|
||||||
version = "0.5.3"
|
version = "0.5.2"
|
||||||
|
|
||||||
[workspace.metadata.crane]
|
[workspace.metadata.crane]
|
||||||
name = "conduwuit"
|
name = "conduwuit"
|
||||||
@@ -158,7 +158,7 @@ features = ["raw_value"]
|
|||||||
|
|
||||||
# Used for appservice registration files
|
# Used for appservice registration files
|
||||||
[workspace.dependencies.serde-saphyr]
|
[workspace.dependencies.serde-saphyr]
|
||||||
version = "0.0.14"
|
version = "0.0.10"
|
||||||
|
|
||||||
# Used to load forbidden room/user regex from config
|
# Used to load forbidden room/user regex from config
|
||||||
[workspace.dependencies.serde_regex]
|
[workspace.dependencies.serde_regex]
|
||||||
@@ -342,7 +342,7 @@ 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 = "85d00fb5746cba23904234b4fd3c838dcf141541"
|
rev = "f9e74cb206cfa45cf5f17d39282253b43a15fcd5"
|
||||||
features = [
|
features = [
|
||||||
"compat",
|
"compat",
|
||||||
"rand",
|
"rand",
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
The announcement checker will now announce errors it encounters in the first run to the admin room, plus a few other misc improvements. Contributed by @Jade
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Fix the generated configuration containing uncommented optional sections. Contributed by @Jade
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Fixed specification non-compliance when handling remote media errors. Contributed by @nex.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
UIAA requests which check for out-of-band success (sent by matrix-js-sdk) will no longer create unhelpful errors in the logs.
|
|
||||||
@@ -1926,9 +1926,9 @@
|
|||||||
#
|
#
|
||||||
#admin_filter = ""
|
#admin_filter = ""
|
||||||
|
|
||||||
#[global.antispam]
|
[global.antispam]
|
||||||
|
|
||||||
#[global.antispam.meowlnir]
|
[global.antispam.meowlnir]
|
||||||
|
|
||||||
# The base URL on which to contact Meowlnir (before /_meowlnir/antispam).
|
# The base URL on which to contact Meowlnir (before /_meowlnir/antispam).
|
||||||
#
|
#
|
||||||
@@ -1953,7 +1953,7 @@
|
|||||||
#
|
#
|
||||||
#check_all_joins = false
|
#check_all_joins = false
|
||||||
|
|
||||||
#[global.antispam.draupnir]
|
[global.antispam.draupnir]
|
||||||
|
|
||||||
# The base URL on which to contact Draupnir (before /api/).
|
# The base URL on which to contact Draupnir (before /api/).
|
||||||
#
|
#
|
||||||
|
|||||||
+1
-1
@@ -48,7 +48,7 @@ EOF
|
|||||||
|
|
||||||
# Developer tool versions
|
# Developer tool versions
|
||||||
# renovate: datasource=github-releases depName=cargo-bins/cargo-binstall
|
# renovate: datasource=github-releases depName=cargo-bins/cargo-binstall
|
||||||
ENV BINSTALL_VERSION=1.16.7
|
ENV BINSTALL_VERSION=1.16.6
|
||||||
# renovate: datasource=github-releases depName=psastras/sbom-rs
|
# renovate: datasource=github-releases depName=psastras/sbom-rs
|
||||||
ENV CARGO_SBOM_VERSION=0.9.1
|
ENV CARGO_SBOM_VERSION=0.9.1
|
||||||
# renovate: datasource=crate depName=lddtree
|
# renovate: datasource=crate depName=lddtree
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ RUN --mount=type=cache,target=/etc/apk/cache apk add \
|
|||||||
|
|
||||||
# Developer tool versions
|
# Developer tool versions
|
||||||
# renovate: datasource=github-releases depName=cargo-bins/cargo-binstall
|
# renovate: datasource=github-releases depName=cargo-bins/cargo-binstall
|
||||||
ENV BINSTALL_VERSION=1.16.7
|
ENV BINSTALL_VERSION=1.16.6
|
||||||
# renovate: datasource=github-releases depName=psastras/sbom-rs
|
# renovate: datasource=github-releases depName=psastras/sbom-rs
|
||||||
ENV CARGO_SBOM_VERSION=0.9.1
|
ENV CARGO_SBOM_VERSION=0.9.1
|
||||||
# renovate: datasource=crate depName=lddtree
|
# renovate: datasource=crate depName=lddtree
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
"message": "Welcome to Continuwuity! Important announcements about the project will appear here."
|
"message": "Welcome to Continuwuity! Important announcements about the project will appear here."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 8,
|
"id": 7,
|
||||||
"mention_room": false,
|
"mention_room": true,
|
||||||
"date": "2026-01-12",
|
"date": "2025-12-30",
|
||||||
"message": "Hey everyone!\n\nJust letting you know we've released [v0.5.3](https://forgejo.ellis.link/continuwuation/continuwuity/releases/tag/v0.5.3) - this one is a bit of a hotfix for an issue with inviting and allowing others to join rooms.\n\nIf you appreceate the round-the-clock work we've been doing to keep your servers secure over this holiday period, we'd really appreciate your support - you can sponsor individuals on our team using the 'sponsor' button at the top of [our GitHub repository](https://github.com/continuwuity/continuwuity). If you can't do that, even a star helps - spreading the word and advocating for our project helps keep it going.\n\nHave a lovely rest of your year \\\n[Jade \\(she/her\\)](https://matrix.to/#/%40jade%3Aellis.link) \n🩵"
|
"message": "Continuwuity v0.5.1 has been released. **The release contains a fix for the critical vulnerability [GHSA-m5p2-vccg-8c9v](https://github.com/continuwuity/continuwuity/security/advisories/GHSA-m5p2-vccg-8c9v) (embargoed) affecting all Conduit-derived servers. Update as soon as possible.**\n\nThis has been *actively exploited* to attempt account takeover and forge events bricking the Continuwuity rooms. The new space is accessible at [Continuwuity (room list)](https://matrix.to/#/!8cR4g-i9ucof69E4JHNg9LbPVkGprHb3SzcrGBDDJgk?via=continuwuity.org&via=starstruck.systems&via=gingershaped.computer)\n"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -118,6 +118,10 @@ Print detailed tokio runtime metrics accumulated since last command invocation
|
|||||||
|
|
||||||
Print the current time
|
Print the current time
|
||||||
|
|
||||||
|
## `!admin debug list-dependencies`
|
||||||
|
|
||||||
|
List dependencies
|
||||||
|
|
||||||
## `!admin debug database-stats`
|
## `!admin debug database-stats`
|
||||||
|
|
||||||
Get database statistics
|
Get database statistics
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ Show configuration values
|
|||||||
|
|
||||||
Reload configuration values
|
Reload configuration values
|
||||||
|
|
||||||
|
## `!admin server list-features`
|
||||||
|
|
||||||
|
List the features built into the server
|
||||||
|
|
||||||
## `!admin server memory-usage`
|
## `!admin server memory-usage`
|
||||||
|
|
||||||
Print database memory usage statistics
|
Print database memory usage statistics
|
||||||
|
|||||||
Generated
+15
-15
@@ -713,9 +713,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@remix-run/router": {
|
"node_modules/@remix-run/router": {
|
||||||
"version": "1.23.2",
|
"version": "1.23.1",
|
||||||
"resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.23.2.tgz",
|
"resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.23.1.tgz",
|
||||||
"integrity": "sha512-Ic6m2U/rMjTkhERIa/0ZtXJP17QUi2CbWE7cqx4J58M8aA3QTfW+2UlQ4psvTX9IO1RfNVhK3pcpdjej7L+t2w==",
|
"integrity": "sha512-vDbaOzF7yT2Qs4vO6XV1MHcJv+3dgR1sT+l3B8xxOVhUC336prMvqrvsLL/9Dnw2xr6Qhz4J0dmS0llNAbnUmQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -3244,9 +3244,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mdast-util-to-hast": {
|
"node_modules/mdast-util-to-hast": {
|
||||||
"version": "13.2.1",
|
"version": "13.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.0.tgz",
|
||||||
"integrity": "sha512-cctsq2wp5vTsLIcaymblUriiTcZd0CwWtCbLvrOzYCDZoWyMNV8sZ7krj09FSnsiJi3WVsHLM4k6Dq/yaPyCXA==",
|
"integrity": "sha512-QGYKEuUsYT9ykKBCMOEDLsU5JRObWQusAolFMeko/tYPufNkRffBAQjIE+99jbA87xv6FgmjLtwjh9wBWajwAA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -4285,13 +4285,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-router": {
|
"node_modules/react-router": {
|
||||||
"version": "6.30.3",
|
"version": "6.30.2",
|
||||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-6.30.3.tgz",
|
"resolved": "https://registry.npmjs.org/react-router/-/react-router-6.30.2.tgz",
|
||||||
"integrity": "sha512-XRnlbKMTmktBkjCLE8/XcZFlnHvr2Ltdr1eJX4idL55/9BbORzyZEaIkBFDhFGCEWBBItsVrDxwx3gnisMitdw==",
|
"integrity": "sha512-H2Bm38Zu1bm8KUE5NVWRMzuIyAV8p/JrOaBJAwVmp37AXG72+CZJlEBw6pdn9i5TBgLMhNDgijS4ZlblpHyWTA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@remix-run/router": "1.23.2"
|
"@remix-run/router": "1.23.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14.0.0"
|
"node": ">=14.0.0"
|
||||||
@@ -4301,14 +4301,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-router-dom": {
|
"node_modules/react-router-dom": {
|
||||||
"version": "6.30.3",
|
"version": "6.30.2",
|
||||||
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.30.3.tgz",
|
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.30.2.tgz",
|
||||||
"integrity": "sha512-pxPcv1AczD4vso7G4Z3TKcvlxK7g7TNt3/FNGMhfqyntocvYKj+GCatfigGDjbLozC4baguJ0ReCigoDJXb0ag==",
|
"integrity": "sha512-l2OwHn3UUnEVUqc6/1VMmR1cvZryZ3j3NzapC2eUXO1dB0sYp5mvwdjiXhpUbRb21eFow3qSxpP8Yv6oAU824Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@remix-run/router": "1.23.2",
|
"@remix-run/router": "1.23.1",
|
||||||
"react-router": "6.30.3"
|
"react-router": "6.30.2"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14.0.0"
|
"node": ">=14.0.0"
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ serde-saphyr.workspace = true
|
|||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
tracing-subscriber.workspace = true
|
tracing-subscriber.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
|
ctor.workspace = true
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
@@ -819,6 +819,32 @@ pub(super) async fn time(&self) -> Result {
|
|||||||
self.write_str(&now).await
|
self.write_str(&now).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
|
pub(super) async fn list_dependencies(&self, names: bool) -> Result {
|
||||||
|
if names {
|
||||||
|
let out = info::cargo::dependencies_names().join(" ");
|
||||||
|
return self.write_str(&out).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut out = String::new();
|
||||||
|
let deps = info::cargo::dependencies();
|
||||||
|
writeln!(out, "| name | version | features |")?;
|
||||||
|
writeln!(out, "| ---- | ------- | -------- |")?;
|
||||||
|
for (name, dep) in deps {
|
||||||
|
let version = dep.try_req().unwrap_or("*");
|
||||||
|
let feats = dep.req_features();
|
||||||
|
let feats = if !feats.is_empty() {
|
||||||
|
feats.join(" ")
|
||||||
|
} else {
|
||||||
|
String::new()
|
||||||
|
};
|
||||||
|
|
||||||
|
writeln!(out, "| {name} | {version} | {feats} |")?;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.write_str(&out).await
|
||||||
|
}
|
||||||
|
|
||||||
#[admin_command]
|
#[admin_command]
|
||||||
pub(super) async fn database_stats(
|
pub(super) async fn database_stats(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@@ -206,6 +206,12 @@ pub enum DebugCommand {
|
|||||||
/// Print the current time
|
/// Print the current time
|
||||||
Time,
|
Time,
|
||||||
|
|
||||||
|
/// List dependencies
|
||||||
|
ListDependencies {
|
||||||
|
#[arg(short, long)]
|
||||||
|
names: bool,
|
||||||
|
},
|
||||||
|
|
||||||
/// Get database statistics
|
/// Get database statistics
|
||||||
DatabaseStats {
|
DatabaseStats {
|
||||||
property: Option<String>,
|
property: Option<String>,
|
||||||
|
|||||||
@@ -30,8 +30,11 @@ pub(crate) use crate::{context::Context, utils::get_room_info};
|
|||||||
|
|
||||||
pub(crate) const PAGE_SIZE: usize = 100;
|
pub(crate) const PAGE_SIZE: usize = 100;
|
||||||
|
|
||||||
|
use ctor::{ctor, dtor};
|
||||||
|
|
||||||
conduwuit::mod_ctor! {}
|
conduwuit::mod_ctor! {}
|
||||||
conduwuit::mod_dtor! {}
|
conduwuit::mod_dtor! {}
|
||||||
|
conduwuit::rustc_flags_capture! {}
|
||||||
|
|
||||||
pub use crate::admin::AdminCommand;
|
pub use crate::admin::AdminCommand;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::{path::PathBuf, sync::Arc};
|
use std::{fmt::Write, path::PathBuf, sync::Arc};
|
||||||
|
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Result,
|
Err, Result, info,
|
||||||
utils::{stream::IterStream, time},
|
utils::{stream::IterStream, time},
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
@@ -59,6 +59,34 @@ pub(super) async fn reload_config(&self, path: Option<PathBuf>) -> Result {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[admin_command]
|
||||||
|
pub(super) async fn list_features(&self, available: bool, enabled: bool, comma: bool) -> Result {
|
||||||
|
let delim = if comma { "," } else { " " };
|
||||||
|
if enabled && !available {
|
||||||
|
let features = info::rustc::features().join(delim);
|
||||||
|
let out = format!("`\n{features}\n`");
|
||||||
|
return self.write_str(&out).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
if available && !enabled {
|
||||||
|
let features = info::cargo::features().join(delim);
|
||||||
|
let out = format!("`\n{features}\n`");
|
||||||
|
return self.write_str(&out).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut features = String::new();
|
||||||
|
let enabled = info::rustc::features();
|
||||||
|
let available = info::cargo::features();
|
||||||
|
for feature in available {
|
||||||
|
let active = enabled.contains(&feature.as_str());
|
||||||
|
let emoji = if active { "✅" } else { "❌" };
|
||||||
|
let remark = if active { "[enabled]" } else { "" };
|
||||||
|
writeln!(features, "{emoji} {feature} {remark}")?;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.write_str(&features).await
|
||||||
|
}
|
||||||
|
|
||||||
#[admin_command]
|
#[admin_command]
|
||||||
pub(super) async fn memory_usage(&self) -> Result {
|
pub(super) async fn memory_usage(&self) -> Result {
|
||||||
let services_usage = self.services.memory_usage().await?;
|
let services_usage = self.services.memory_usage().await?;
|
||||||
|
|||||||
@@ -21,6 +21,18 @@ pub enum ServerCommand {
|
|||||||
path: Option<PathBuf>,
|
path: Option<PathBuf>,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// List the features built into the server
|
||||||
|
ListFeatures {
|
||||||
|
#[arg(short, long)]
|
||||||
|
available: bool,
|
||||||
|
|
||||||
|
#[arg(short, long)]
|
||||||
|
enabled: bool,
|
||||||
|
|
||||||
|
#[arg(short, long)]
|
||||||
|
comma: bool,
|
||||||
|
},
|
||||||
|
|
||||||
/// Print database memory usage statistics
|
/// Print database memory usage statistics
|
||||||
MemoryUsage,
|
MemoryUsage,
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ serde.workspace = true
|
|||||||
sha1.workspace = true
|
sha1.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
|
ctor.workspace = true
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
@@ -1 +0,0 @@
|
|||||||
pub mod rooms;
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
use axum::extract::State;
|
|
||||||
use conduwuit::{Err, Result, info, utils::ReadyExt, warn};
|
|
||||||
use futures::{FutureExt, StreamExt};
|
|
||||||
use ruma::{
|
|
||||||
OwnedRoomAliasId, continuwuity_admin_api::rooms,
|
|
||||||
events::room::message::RoomMessageEventContent,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{Ruma, client::leave_room};
|
|
||||||
|
|
||||||
/// # `PUT /_continuwuity/admin/rooms/{roomID}/ban`
|
|
||||||
///
|
|
||||||
/// Bans or unbans a room.
|
|
||||||
pub(crate) async fn ban_room(
|
|
||||||
State(services): State<crate::State>,
|
|
||||||
body: Ruma<rooms::ban::v1::Request>,
|
|
||||||
) -> Result<rooms::ban::v1::Response> {
|
|
||||||
let sender_user = body.sender_user();
|
|
||||||
if !services.users.is_admin(sender_user).await {
|
|
||||||
return Err!(Request(Forbidden("Only server administrators can use this endpoint")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if body.banned {
|
|
||||||
// Don't ban again if already banned
|
|
||||||
if services.rooms.metadata.is_banned(&body.room_id).await {
|
|
||||||
return Err!(Request(InvalidParam("Room is already banned")));
|
|
||||||
}
|
|
||||||
info!(%sender_user, "Banning room {}", body.room_id);
|
|
||||||
|
|
||||||
services
|
|
||||||
.admin
|
|
||||||
.notice(&format!("{sender_user} banned {} (ban in progress)", body.room_id))
|
|
||||||
.await;
|
|
||||||
|
|
||||||
let mut users = services
|
|
||||||
.rooms
|
|
||||||
.state_cache
|
|
||||||
.room_members(&body.room_id)
|
|
||||||
.map(ToOwned::to_owned)
|
|
||||||
.ready_filter(|user| services.globals.user_is_local(user))
|
|
||||||
.boxed();
|
|
||||||
let mut evicted = Vec::new();
|
|
||||||
let mut failed_evicted = Vec::new();
|
|
||||||
|
|
||||||
while let Some(ref user_id) = users.next().await {
|
|
||||||
info!("Evicting user {} from room {}", user_id, body.room_id);
|
|
||||||
match leave_room(&services, user_id, &body.room_id, None)
|
|
||||||
.boxed()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
| Ok(()) => {
|
|
||||||
services.rooms.state_cache.forget(&body.room_id, user_id);
|
|
||||||
evicted.push(user_id.clone());
|
|
||||||
},
|
|
||||||
| Err(e) => {
|
|
||||||
warn!("Failed to evict user {} from room {}: {}", user_id, body.room_id, e);
|
|
||||||
failed_evicted.push(user_id.clone());
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let aliases: Vec<OwnedRoomAliasId> = services
|
|
||||||
.rooms
|
|
||||||
.alias
|
|
||||||
.local_aliases_for_room(&body.room_id)
|
|
||||||
.map(ToOwned::to_owned)
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.await;
|
|
||||||
for alias in &aliases {
|
|
||||||
info!("Removing alias {} for banned room {}", alias, body.room_id);
|
|
||||||
services
|
|
||||||
.rooms
|
|
||||||
.alias
|
|
||||||
.remove_alias(alias, &services.globals.server_user)
|
|
||||||
.await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
services.rooms.directory.set_not_public(&body.room_id); // remove from the room directory
|
|
||||||
services.rooms.metadata.ban_room(&body.room_id, true); // prevent further joins
|
|
||||||
services.rooms.metadata.disable_room(&body.room_id, true); // disable federation
|
|
||||||
|
|
||||||
services
|
|
||||||
.admin
|
|
||||||
.notice(&format!(
|
|
||||||
"Finished banning {}: Removed {} users ({} failed) and {} aliases",
|
|
||||||
body.room_id,
|
|
||||||
evicted.len(),
|
|
||||||
failed_evicted.len(),
|
|
||||||
aliases.len()
|
|
||||||
))
|
|
||||||
.await;
|
|
||||||
if !evicted.is_empty() || !failed_evicted.is_empty() || !aliases.is_empty() {
|
|
||||||
let msg = services
|
|
||||||
.admin
|
|
||||||
.text_or_file(RoomMessageEventContent::text_markdown(format!(
|
|
||||||
"Removed users:\n{}\n\nFailed to remove users:\n{}\n\nRemoved aliases: {}",
|
|
||||||
evicted
|
|
||||||
.iter()
|
|
||||||
.map(|u| u.as_str())
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.join("\n"),
|
|
||||||
failed_evicted
|
|
||||||
.iter()
|
|
||||||
.map(|u| u.as_str())
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.join("\n"),
|
|
||||||
aliases
|
|
||||||
.iter()
|
|
||||||
.map(|a| a.as_str())
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.join(", "),
|
|
||||||
)))
|
|
||||||
.await;
|
|
||||||
services.admin.send_message(msg).await.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(rooms::ban::v1::Response::new(evicted, failed_evicted, aliases))
|
|
||||||
} else {
|
|
||||||
// Don't unban if not banned
|
|
||||||
if !services.rooms.metadata.is_banned(&body.room_id).await {
|
|
||||||
return Err!(Request(InvalidParam("Room is not banned")));
|
|
||||||
}
|
|
||||||
info!(%sender_user, "Unbanning room {}", body.room_id);
|
|
||||||
services.rooms.metadata.disable_room(&body.room_id, false);
|
|
||||||
services.rooms.metadata.ban_room(&body.room_id, false);
|
|
||||||
services
|
|
||||||
.admin
|
|
||||||
.notice(&format!("{sender_user} unbanned {}", body.room_id))
|
|
||||||
.await;
|
|
||||||
Ok(rooms::ban::v1::Response::new(Vec::new(), Vec::new(), Vec::new()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
use axum::extract::State;
|
|
||||||
use conduwuit::{Err, Result};
|
|
||||||
use futures::StreamExt;
|
|
||||||
use ruma::{OwnedRoomId, continuwuity_admin_api::rooms};
|
|
||||||
|
|
||||||
use crate::Ruma;
|
|
||||||
|
|
||||||
/// # `GET /_continuwuity/admin/rooms/list`
|
|
||||||
///
|
|
||||||
/// Lists all rooms known to this server, excluding banned ones.
|
|
||||||
pub(crate) async fn list_rooms(
|
|
||||||
State(services): State<crate::State>,
|
|
||||||
body: Ruma<rooms::list::v1::Request>,
|
|
||||||
) -> Result<rooms::list::v1::Response> {
|
|
||||||
let sender_user = body.sender_user();
|
|
||||||
if !services.users.is_admin(sender_user).await {
|
|
||||||
return Err!(Request(Forbidden("Only server administrators can use this endpoint")));
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut rooms: Vec<OwnedRoomId> = services
|
|
||||||
.rooms
|
|
||||||
.metadata
|
|
||||||
.iter_ids()
|
|
||||||
.filter_map(|room_id| async move {
|
|
||||||
if !services.rooms.metadata.is_banned(room_id).await {
|
|
||||||
Some(room_id.to_owned())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
.await;
|
|
||||||
rooms.sort();
|
|
||||||
Ok(rooms::list::v1::Response::new(rooms))
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
pub mod ban;
|
|
||||||
pub mod list;
|
|
||||||
@@ -91,11 +91,8 @@ pub(crate) async fn upload_keys_route(
|
|||||||
.users
|
.users
|
||||||
.get_device_keys(sender_user, sender_device)
|
.get_device_keys(sender_user, sender_device)
|
||||||
.await
|
.await
|
||||||
.and_then(|keys| keys.deserialize().map_err(Into::into))
|
|
||||||
{
|
{
|
||||||
// NOTE: also serves as a workaround for a nheko bug which omits cross-signing
|
if existing_keys.json().get() == device_keys.json().get() {
|
||||||
// NOTE: signatures when re-uploading the same DeviceKeys.
|
|
||||||
if existing_keys.keys == deser_device_keys.keys {
|
|
||||||
debug!(
|
debug!(
|
||||||
%sender_user,
|
%sender_user,
|
||||||
%sender_device,
|
%sender_device,
|
||||||
|
|||||||
@@ -371,3 +371,11 @@ pub(crate) async fn is_ignored_invite(
|
|||||||
.invite_filter_level(&sender_user, recipient_user)
|
.invite_filter_level(&sender_user, recipient_user)
|
||||||
.await == FilterLevel::Ignore
|
.await == FilterLevel::Ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(debug_assertions, ctor::ctor)]
|
||||||
|
fn _is_sorted() {
|
||||||
|
debug_assert!(
|
||||||
|
IGNORED_MESSAGE_TYPES.is_sorted(),
|
||||||
|
"IGNORED_MESSAGE_TYPES must be sorted by the developer"
|
||||||
|
);
|
||||||
|
}
|
||||||
+2
-3
@@ -1,13 +1,12 @@
|
|||||||
#![type_length_limit = "16384"] //TODO: reduce me
|
#![type_length_limit = "16384"] //TODO: reduce me
|
||||||
#![allow(clippy::toplevel_ref_arg)]
|
#![allow(clippy::toplevel_ref_arg)]
|
||||||
|
|
||||||
extern crate conduwuit_core as conduwuit;
|
|
||||||
extern crate conduwuit_service as service;
|
|
||||||
pub mod client;
|
pub mod client;
|
||||||
pub mod router;
|
pub mod router;
|
||||||
pub mod server;
|
pub mod server;
|
||||||
|
|
||||||
pub mod admin;
|
extern crate conduwuit_core as conduwuit;
|
||||||
|
extern crate conduwuit_service as service;
|
||||||
|
|
||||||
pub(crate) use self::router::{Ruma, RumaResponse, State};
|
pub(crate) use self::router::{Ruma, RumaResponse, State};
|
||||||
|
|
||||||
|
|||||||
+2
-4
@@ -17,7 +17,7 @@ use http::{Uri, uri};
|
|||||||
|
|
||||||
use self::handler::RouterExt;
|
use self::handler::RouterExt;
|
||||||
pub(super) use self::{args::Args as Ruma, response::RumaResponse};
|
pub(super) use self::{args::Args as Ruma, response::RumaResponse};
|
||||||
use crate::{admin, client, server};
|
use crate::{client, server};
|
||||||
|
|
||||||
pub fn build(router: Router<State>, server: &Server) -> Router<State> {
|
pub fn build(router: Router<State>, server: &Server) -> Router<State> {
|
||||||
let config = &server.config;
|
let config = &server.config;
|
||||||
@@ -187,9 +187,7 @@ pub fn build(router: Router<State>, server: &Server) -> Router<State> {
|
|||||||
.route("/_conduwuit/server_version", get(client::conduwuit_server_version))
|
.route("/_conduwuit/server_version", get(client::conduwuit_server_version))
|
||||||
.route("/_continuwuity/server_version", get(client::conduwuit_server_version))
|
.route("/_continuwuity/server_version", get(client::conduwuit_server_version))
|
||||||
.ruma_route(&client::room_initial_sync_route)
|
.ruma_route(&client::room_initial_sync_route)
|
||||||
.route("/client/server.json", get(client::syncv3_client_server_json))
|
.route("/client/server.json", get(client::syncv3_client_server_json));
|
||||||
.ruma_route(&admin::rooms::ban::ban_room)
|
|
||||||
.ruma_route(&admin::rooms::list::list_rooms);
|
|
||||||
|
|
||||||
if config.allow_federation {
|
if config.allow_federation {
|
||||||
router = router
|
router = router
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ use conduwuit::{
|
|||||||
use conduwuit_service::Services;
|
use conduwuit_service::Services;
|
||||||
use futures::{FutureExt, StreamExt, TryStreamExt};
|
use futures::{FutureExt, StreamExt, TryStreamExt};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonValue, OwnedEventId, OwnedRoomId, OwnedUserId, RoomId, ServerName,
|
CanonicalJsonValue, OwnedEventId, OwnedRoomId, OwnedServerName, OwnedUserId, RoomId,
|
||||||
|
ServerName,
|
||||||
api::federation::membership::create_join_event,
|
api::federation::membership::create_join_event,
|
||||||
events::{
|
events::{
|
||||||
StateEventType,
|
StateEventType,
|
||||||
@@ -177,6 +178,15 @@ async fn create_join_event(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let origin: OwnedServerName = serde_json::from_value(
|
||||||
|
value
|
||||||
|
.get("origin")
|
||||||
|
.ok_or_else(|| err!(Request(BadJson("Event does not have an origin server name."))))?
|
||||||
|
.clone()
|
||||||
|
.into(),
|
||||||
|
)
|
||||||
|
.map_err(|e| err!(Request(BadJson("Event has an invalid origin server name: {e}"))))?;
|
||||||
|
|
||||||
trace!("Signing send_join event");
|
trace!("Signing send_join event");
|
||||||
services
|
services
|
||||||
.server_keys
|
.server_keys
|
||||||
@@ -194,7 +204,7 @@ async fn create_join_event(
|
|||||||
let pdu_id = services
|
let pdu_id = services
|
||||||
.rooms
|
.rooms
|
||||||
.event_handler
|
.event_handler
|
||||||
.handle_incoming_pdu(sender.server_name(), room_id, &event_id, value.clone(), true)
|
.handle_incoming_pdu(&origin, room_id, &event_id, value.clone(), true)
|
||||||
.boxed()
|
.boxed()
|
||||||
.await?
|
.await?
|
||||||
.ok_or_else(|| err!(Request(InvalidParam("Could not accept as timeline event."))))?;
|
.ok_or_else(|| err!(Request(InvalidParam("Could not accept as timeline event."))))?;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use conduwuit::{
|
|||||||
};
|
};
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedUserId,
|
OwnedServerName, OwnedUserId,
|
||||||
RoomVersionId::*,
|
RoomVersionId::*,
|
||||||
api::federation::knock::send_knock,
|
api::federation::knock::send_knock,
|
||||||
events::{
|
events::{
|
||||||
@@ -136,6 +136,15 @@ pub(crate) async fn create_knock_event_v1_route(
|
|||||||
return Err!(Request(InvalidParam("state_key does not match sender user of event.")));
|
return Err!(Request(InvalidParam("state_key does not match sender user of event.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let origin: OwnedServerName = serde_json::from_value(
|
||||||
|
value
|
||||||
|
.get("origin")
|
||||||
|
.ok_or_else(|| err!(Request(BadJson("Event does not have an origin server name."))))?
|
||||||
|
.clone()
|
||||||
|
.into(),
|
||||||
|
)
|
||||||
|
.map_err(|e| err!(Request(BadJson("Event has an invalid origin server name: {e}"))))?;
|
||||||
|
|
||||||
let mut event: JsonObject = serde_json::from_str(body.pdu.get())
|
let mut event: JsonObject = serde_json::from_str(body.pdu.get())
|
||||||
.map_err(|e| err!(Request(InvalidParam("Invalid knock event PDU: {e}"))))?;
|
.map_err(|e| err!(Request(InvalidParam("Invalid knock event PDU: {e}"))))?;
|
||||||
|
|
||||||
@@ -154,7 +163,7 @@ pub(crate) async fn create_knock_event_v1_route(
|
|||||||
let pdu_id = services
|
let pdu_id = services
|
||||||
.rooms
|
.rooms
|
||||||
.event_handler
|
.event_handler
|
||||||
.handle_incoming_pdu(sender.server_name(), &body.room_id, &event_id, value.clone(), true)
|
.handle_incoming_pdu(&origin, &body.room_id, &event_id, value.clone(), true)
|
||||||
.boxed()
|
.boxed()
|
||||||
.await?
|
.await?
|
||||||
.ok_or_else(|| err!(Request(InvalidParam("Could not accept as timeline event."))))?;
|
.ok_or_else(|| err!(Request(InvalidParam("Could not accept as timeline event."))))?;
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ type Key = ArrayVec<usize, KEY_SEGS>;
|
|||||||
const NAME_MAX: usize = 128;
|
const NAME_MAX: usize = 128;
|
||||||
const KEY_SEGS: usize = 8;
|
const KEY_SEGS: usize = 8;
|
||||||
|
|
||||||
#[ctor::ctor]
|
#[crate::ctor]
|
||||||
fn _static_initialization() {
|
fn _static_initialization() {
|
||||||
acq_epoch().expect("pre-initialization of jemalloc failed");
|
acq_epoch().expect("pre-initialization of jemalloc failed");
|
||||||
acq_epoch().expect("pre-initialization of jemalloc failed");
|
acq_epoch().expect("pre-initialization of jemalloc failed");
|
||||||
|
|||||||
@@ -2261,11 +2261,7 @@ struct ListeningAddr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Deserialize)]
|
||||||
#[config_example_generator(
|
#[config_example_generator(filename = "conduwuit-example.toml", section = "global.antispam")]
|
||||||
filename = "conduwuit-example.toml",
|
|
||||||
section = "global.antispam",
|
|
||||||
optional = "true"
|
|
||||||
)]
|
|
||||||
pub struct Antispam {
|
pub struct Antispam {
|
||||||
/// display: nested
|
/// display: nested
|
||||||
pub meowlnir: Option<MeowlnirConfig>,
|
pub meowlnir: Option<MeowlnirConfig>,
|
||||||
@@ -2276,8 +2272,7 @@ pub struct Antispam {
|
|||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Deserialize)]
|
||||||
#[config_example_generator(
|
#[config_example_generator(
|
||||||
filename = "conduwuit-example.toml",
|
filename = "conduwuit-example.toml",
|
||||||
section = "global.antispam.meowlnir",
|
section = "global.antispam.meowlnir"
|
||||||
optional = "true"
|
|
||||||
)]
|
)]
|
||||||
pub struct MeowlnirConfig {
|
pub struct MeowlnirConfig {
|
||||||
/// The base URL on which to contact Meowlnir (before /_meowlnir/antispam).
|
/// The base URL on which to contact Meowlnir (before /_meowlnir/antispam).
|
||||||
@@ -2306,8 +2301,7 @@ pub struct MeowlnirConfig {
|
|||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Deserialize)]
|
||||||
#[config_example_generator(
|
#[config_example_generator(
|
||||||
filename = "conduwuit-example.toml",
|
filename = "conduwuit-example.toml",
|
||||||
section = "global.antispam.draupnir",
|
section = "global.antispam.draupnir"
|
||||||
optional = "true"
|
|
||||||
)]
|
)]
|
||||||
pub struct DraupnirConfig {
|
pub struct DraupnirConfig {
|
||||||
/// The base URL on which to contact Draupnir (before /api/).
|
/// The base URL on which to contact Draupnir (before /api/).
|
||||||
|
|||||||
+1
-1
@@ -62,7 +62,7 @@ pub const INFO_SPAN_LEVEL: Level = if cfg!(debug_assertions) {
|
|||||||
pub static DEBUGGER: LazyLock<bool> =
|
pub static DEBUGGER: LazyLock<bool> =
|
||||||
LazyLock::new(|| env::var("_").unwrap_or_default().ends_with("gdb"));
|
LazyLock::new(|| env::var("_").unwrap_or_default().ends_with("gdb"));
|
||||||
|
|
||||||
#[cfg_attr(debug_assertions, ctor::ctor)]
|
#[cfg_attr(debug_assertions, crate::ctor)]
|
||||||
#[cfg_attr(not(debug_assertions), allow(dead_code))]
|
#[cfg_attr(not(debug_assertions), allow(dead_code))]
|
||||||
fn set_panic_trap() {
|
fn set_panic_trap() {
|
||||||
if !*DEBUGGER {
|
if !*DEBUGGER {
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ macro_rules! err {
|
|||||||
macro_rules! err_log {
|
macro_rules! err_log {
|
||||||
($out:ident, $level:ident, $($fields:tt)+) => {{
|
($out:ident, $level:ident, $($fields:tt)+) => {{
|
||||||
use $crate::tracing::{
|
use $crate::tracing::{
|
||||||
callsite, callsite2, metadata, valueset_all, Callsite,
|
callsite, callsite2, metadata, valueset, Callsite,
|
||||||
Level,
|
Level,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ macro_rules! err_log {
|
|||||||
fields: $($fields)+,
|
fields: $($fields)+,
|
||||||
};
|
};
|
||||||
|
|
||||||
($crate::error::visit)(&mut $out, LEVEL, &__CALLSITE, &mut valueset_all!(__CALLSITE.metadata().fields(), $($fields)+));
|
($crate::error::visit)(&mut $out, LEVEL, &__CALLSITE, &mut valueset!(__CALLSITE.metadata().fields(), $($fields)+));
|
||||||
($out).into()
|
($out).into()
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
//! Information about the build related to Cargo. This is a frontend interface
|
||||||
|
//! informed by proc-macros that capture raw information at build time which is
|
||||||
|
//! further processed at runtime either during static initialization or as
|
||||||
|
//! necessary.
|
||||||
|
|
||||||
|
use std::sync::OnceLock;
|
||||||
|
|
||||||
|
use cargo_toml::{DepsSet, Manifest};
|
||||||
|
use conduwuit_macros::cargo_manifest;
|
||||||
|
|
||||||
|
use crate::Result;
|
||||||
|
|
||||||
|
// Raw captures of the cargo manifest for each crate. This is provided by a
|
||||||
|
// proc-macro at build time since the source directory and the cargo toml's may
|
||||||
|
// not be present during execution.
|
||||||
|
|
||||||
|
#[cargo_manifest]
|
||||||
|
const WORKSPACE_MANIFEST: &'static str = ();
|
||||||
|
#[cargo_manifest(crate = "macros")]
|
||||||
|
const MACROS_MANIFEST: &'static str = ();
|
||||||
|
#[cargo_manifest(crate = "core")]
|
||||||
|
const CORE_MANIFEST: &'static str = ();
|
||||||
|
#[cargo_manifest(crate = "database")]
|
||||||
|
const DATABASE_MANIFEST: &'static str = ();
|
||||||
|
#[cargo_manifest(crate = "service")]
|
||||||
|
const SERVICE_MANIFEST: &'static str = ();
|
||||||
|
#[cargo_manifest(crate = "admin")]
|
||||||
|
const ADMIN_MANIFEST: &'static str = ();
|
||||||
|
#[cargo_manifest(crate = "router")]
|
||||||
|
const ROUTER_MANIFEST: &'static str = ();
|
||||||
|
#[cargo_manifest(crate = "main")]
|
||||||
|
const MAIN_MANIFEST: &'static str = ();
|
||||||
|
|
||||||
|
/// Processed list of features across all project crates. This is generated from
|
||||||
|
/// the data in the MANIFEST strings and contains all possible project features.
|
||||||
|
/// For *enabled* features see the info::rustc module instead.
|
||||||
|
static FEATURES: OnceLock<Vec<String>> = OnceLock::new();
|
||||||
|
|
||||||
|
/// Processed list of dependencies. This is generated from the data captured in
|
||||||
|
/// the MANIFEST.
|
||||||
|
static DEPENDENCIES: OnceLock<DepsSet> = OnceLock::new();
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub fn dependencies_names() -> Vec<&'static str> {
|
||||||
|
dependencies().keys().map(String::as_str).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn dependencies() -> &'static DepsSet {
|
||||||
|
DEPENDENCIES.get_or_init(|| {
|
||||||
|
init_dependencies().unwrap_or_else(|e| panic!("Failed to initialize dependencies: {e}"))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// List of all possible features for the project. For *enabled* features in
|
||||||
|
/// this build see the companion function in info::rustc.
|
||||||
|
pub fn features() -> &'static Vec<String> {
|
||||||
|
FEATURES.get_or_init(|| {
|
||||||
|
init_features().unwrap_or_else(|e| panic!("Failed initialize features: {e}"))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn init_features() -> Result<Vec<String>> {
|
||||||
|
let mut features = Vec::new();
|
||||||
|
append_features(&mut features, WORKSPACE_MANIFEST)?;
|
||||||
|
append_features(&mut features, MACROS_MANIFEST)?;
|
||||||
|
append_features(&mut features, CORE_MANIFEST)?;
|
||||||
|
append_features(&mut features, DATABASE_MANIFEST)?;
|
||||||
|
append_features(&mut features, SERVICE_MANIFEST)?;
|
||||||
|
append_features(&mut features, ADMIN_MANIFEST)?;
|
||||||
|
append_features(&mut features, ROUTER_MANIFEST)?;
|
||||||
|
append_features(&mut features, MAIN_MANIFEST)?;
|
||||||
|
features.sort();
|
||||||
|
features.dedup();
|
||||||
|
|
||||||
|
Ok(features)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn append_features(features: &mut Vec<String>, manifest: &str) -> Result<()> {
|
||||||
|
let manifest = Manifest::from_str(manifest)?;
|
||||||
|
features.extend(manifest.features.keys().cloned());
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn init_dependencies() -> Result<DepsSet> {
|
||||||
|
let manifest = Manifest::from_str(WORKSPACE_MANIFEST)?;
|
||||||
|
let deps_set = manifest
|
||||||
|
.workspace
|
||||||
|
.as_ref()
|
||||||
|
.expect("manifest has workspace section")
|
||||||
|
.dependencies
|
||||||
|
.clone();
|
||||||
|
|
||||||
|
Ok(deps_set)
|
||||||
|
}
|
||||||
@@ -1,5 +1,12 @@
|
|||||||
|
//! Information about the project. This module contains version, build, system,
|
||||||
|
//! etc information which can be queried by admins or used by developers.
|
||||||
|
|
||||||
|
pub mod cargo;
|
||||||
pub mod room_version;
|
pub mod room_version;
|
||||||
|
pub mod rustc;
|
||||||
pub mod version;
|
pub mod version;
|
||||||
|
|
||||||
|
pub use conduwuit_macros::rustc_flags_capture;
|
||||||
|
|
||||||
pub const MODULE_ROOT: &str = const_str::split!(std::module_path!(), "::")[0];
|
pub const MODULE_ROOT: &str = const_str::split!(std::module_path!(), "::")[0];
|
||||||
pub const CRATE_PREFIX: &str = const_str::split!(MODULE_ROOT, '_')[0];
|
pub const CRATE_PREFIX: &str = const_str::split!(MODULE_ROOT, '_')[0];
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
//! Information about the build related to rustc. This is a frontend interface
|
||||||
|
//! informed by proc-macros at build time. Since the project is split into
|
||||||
|
//! several crates, lower-level information is supplied from each crate during
|
||||||
|
//! static initialization.
|
||||||
|
|
||||||
|
use std::{collections::BTreeMap, sync::OnceLock};
|
||||||
|
|
||||||
|
use crate::utils::exchange;
|
||||||
|
|
||||||
|
/// Raw capture of rustc flags used to build each crate in the project. Informed
|
||||||
|
/// by rustc_flags_capture macro (one in each crate's mod.rs). This is
|
||||||
|
/// done during static initialization which is why it's mutex-protected and pub.
|
||||||
|
/// Should not be written to by anything other than our macro.
|
||||||
|
///
|
||||||
|
/// We specifically use a std mutex here because parking_lot cannot be used
|
||||||
|
/// after thread local storage is destroyed on MacOS.
|
||||||
|
pub static FLAGS: std::sync::Mutex<BTreeMap<&str, &[&str]>> =
|
||||||
|
std::sync::Mutex::new(BTreeMap::new());
|
||||||
|
|
||||||
|
/// Processed list of enabled features across all project crates. This is
|
||||||
|
/// generated from the data in FLAGS.
|
||||||
|
static FEATURES: OnceLock<Vec<&'static str>> = OnceLock::new();
|
||||||
|
|
||||||
|
/// List of features enabled for the project.
|
||||||
|
pub fn features() -> &'static Vec<&'static str> { FEATURES.get_or_init(init_features) }
|
||||||
|
|
||||||
|
fn init_features() -> Vec<&'static str> {
|
||||||
|
let mut features = Vec::new();
|
||||||
|
FLAGS
|
||||||
|
.lock()
|
||||||
|
.expect("locked")
|
||||||
|
.iter()
|
||||||
|
.for_each(|(_, flags)| append_features(&mut features, flags));
|
||||||
|
|
||||||
|
features.sort_unstable();
|
||||||
|
features.dedup();
|
||||||
|
features
|
||||||
|
}
|
||||||
|
|
||||||
|
fn append_features(features: &mut Vec<&'static str>, flags: &[&'static str]) {
|
||||||
|
let mut next_is_cfg = false;
|
||||||
|
for flag in flags {
|
||||||
|
let is_cfg = *flag == "--cfg";
|
||||||
|
let is_feature = flag.starts_with("feature=");
|
||||||
|
if exchange(&mut next_is_cfg, is_cfg) && is_feature {
|
||||||
|
if let Some(feature) = flag
|
||||||
|
.split_once('=')
|
||||||
|
.map(|(_, feature)| feature.trim_matches('"'))
|
||||||
|
{
|
||||||
|
features.push(feature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-2
@@ -22,7 +22,7 @@ pub use ::tracing;
|
|||||||
pub use config::Config;
|
pub use config::Config;
|
||||||
pub use error::Error;
|
pub use error::Error;
|
||||||
pub use info::{
|
pub use info::{
|
||||||
version,
|
rustc_flags_capture, version,
|
||||||
version::{name, version},
|
version::{name, version},
|
||||||
};
|
};
|
||||||
pub use matrix::{
|
pub use matrix::{
|
||||||
@@ -30,10 +30,12 @@ pub use matrix::{
|
|||||||
};
|
};
|
||||||
pub use parking_lot::{Mutex as SyncMutex, RwLock as SyncRwLock};
|
pub use parking_lot::{Mutex as SyncMutex, RwLock as SyncRwLock};
|
||||||
pub use server::Server;
|
pub use server::Server;
|
||||||
pub use utils::{implement, result, result::Result};
|
pub use utils::{ctor, dtor, implement, result, result::Result};
|
||||||
|
|
||||||
pub use crate as conduwuit_core;
|
pub use crate as conduwuit_core;
|
||||||
|
|
||||||
|
rustc_flags_capture! {}
|
||||||
|
|
||||||
#[cfg(any(not(conduwuit_mods), not(feature = "conduwuit_mods")))]
|
#[cfg(any(not(conduwuit_mods), not(feature = "conduwuit_mods")))]
|
||||||
pub mod mods {
|
pub mod mods {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ pub mod time;
|
|||||||
pub mod with_lock;
|
pub mod with_lock;
|
||||||
|
|
||||||
pub use ::conduwuit_macros::implement;
|
pub use ::conduwuit_macros::implement;
|
||||||
|
pub use ::ctor::{ctor, dtor};
|
||||||
|
|
||||||
pub use self::{
|
pub use self::{
|
||||||
arrayvec::ArrayVecExt,
|
arrayvec::ArrayVecExt,
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ serde.workspace = true
|
|||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
|
ctor.workspace = true
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
@@ -3,8 +3,11 @@
|
|||||||
extern crate conduwuit_core as conduwuit;
|
extern crate conduwuit_core as conduwuit;
|
||||||
extern crate rust_rocksdb as rocksdb;
|
extern crate rust_rocksdb as rocksdb;
|
||||||
|
|
||||||
|
use ctor::{ctor, dtor};
|
||||||
|
|
||||||
conduwuit::mod_ctor! {}
|
conduwuit::mod_ctor! {}
|
||||||
conduwuit::mod_dtor! {}
|
conduwuit::mod_dtor! {}
|
||||||
|
conduwuit::rustc_flags_capture! {}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod benches;
|
mod benches;
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
use std::{fs::read_to_string, path::PathBuf};
|
||||||
|
|
||||||
|
use proc_macro::{Span, TokenStream};
|
||||||
|
use quote::quote;
|
||||||
|
use syn::{Error, ItemConst, Meta};
|
||||||
|
|
||||||
|
use crate::{Result, utils};
|
||||||
|
|
||||||
|
pub(super) fn manifest(item: ItemConst, args: &[Meta]) -> Result<TokenStream> {
|
||||||
|
let member = utils::get_named_string(args, "crate");
|
||||||
|
let path = manifest_path(member.as_deref())?;
|
||||||
|
let manifest = read_to_string(&path).unwrap_or_default();
|
||||||
|
let val = manifest.as_str();
|
||||||
|
let name = item.ident;
|
||||||
|
let ret = quote! {
|
||||||
|
const #name: &'static str = #val;
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(ret.into())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::option_env_unwrap)]
|
||||||
|
fn manifest_path(member: Option<&str>) -> Result<PathBuf> {
|
||||||
|
let Some(path) = option_env!("CARGO_MANIFEST_DIR") else {
|
||||||
|
return Err(Error::new(
|
||||||
|
Span::call_site().into(),
|
||||||
|
"missing CARGO_MANIFEST_DIR in environment",
|
||||||
|
));
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut path: PathBuf = path.into();
|
||||||
|
|
||||||
|
// conduwuit/src/macros/ -> conduwuit/src/
|
||||||
|
path.pop();
|
||||||
|
|
||||||
|
if let Some(member) = member {
|
||||||
|
// conduwuit/$member/Cargo.toml
|
||||||
|
path.push(member);
|
||||||
|
} else {
|
||||||
|
// conduwuit/src/ -> conduwuit/
|
||||||
|
path.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
path.push("Cargo.toml");
|
||||||
|
|
||||||
|
Ok(path)
|
||||||
|
}
|
||||||
@@ -73,13 +73,7 @@ fn generate_example(input: &ItemStruct, args: &[Meta], write: bool) -> Result<To
|
|||||||
.expect("written to config file");
|
.expect("written to config file");
|
||||||
}
|
}
|
||||||
|
|
||||||
let optional = settings.get("optional").is_some_and(|v| v == "true");
|
file.write_fmt(format_args!("\n[{section}]\n"))
|
||||||
let section_header = if optional {
|
|
||||||
format!("\n#[{section}]\n")
|
|
||||||
} else {
|
|
||||||
format!("\n[{section}]\n")
|
|
||||||
};
|
|
||||||
file.write_fmt(format_args!("{section_header}"))
|
|
||||||
.expect("written to config file");
|
.expect("written to config file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-1
@@ -1,13 +1,15 @@
|
|||||||
mod admin;
|
mod admin;
|
||||||
|
mod cargo;
|
||||||
mod config;
|
mod config;
|
||||||
mod debug;
|
mod debug;
|
||||||
mod implement;
|
mod implement;
|
||||||
mod refutable;
|
mod refutable;
|
||||||
|
mod rustc;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
use syn::{
|
use syn::{
|
||||||
Error, Item, ItemEnum, ItemFn, ItemStruct, Meta,
|
Error, Item, ItemConst, ItemEnum, ItemFn, ItemStruct, Meta,
|
||||||
parse::{Parse, Parser},
|
parse::{Parse, Parser},
|
||||||
parse_macro_input,
|
parse_macro_input,
|
||||||
};
|
};
|
||||||
@@ -24,11 +26,19 @@ pub fn admin_command_dispatch(args: TokenStream, input: TokenStream) -> TokenStr
|
|||||||
attribute_macro::<ItemEnum, _>(args, input, admin::command_dispatch)
|
attribute_macro::<ItemEnum, _>(args, input, admin::command_dispatch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[proc_macro_attribute]
|
||||||
|
pub fn cargo_manifest(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
|
attribute_macro::<ItemConst, _>(args, input, cargo::manifest)
|
||||||
|
}
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
pub fn recursion_depth(args: TokenStream, input: TokenStream) -> TokenStream {
|
pub fn recursion_depth(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
attribute_macro::<Item, _>(args, input, debug::recursion_depth)
|
attribute_macro::<Item, _>(args, input, debug::recursion_depth)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[proc_macro]
|
||||||
|
pub fn rustc_flags_capture(args: TokenStream) -> TokenStream { rustc::flags_capture(args) }
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
pub fn refutable(args: TokenStream, input: TokenStream) -> TokenStream {
|
pub fn refutable(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
attribute_macro::<ItemFn, _>(args, input, refutable::refutable)
|
attribute_macro::<ItemFn, _>(args, input, refutable::refutable)
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
use proc_macro::TokenStream;
|
||||||
|
use quote::quote;
|
||||||
|
|
||||||
|
pub(super) fn flags_capture(args: TokenStream) -> TokenStream {
|
||||||
|
let cargo_crate_name = std::env::var("CARGO_CRATE_NAME");
|
||||||
|
let crate_name = match cargo_crate_name.as_ref() {
|
||||||
|
| Err(_) => return args,
|
||||||
|
| Ok(crate_name) => crate_name.trim_start_matches("conduwuit_"),
|
||||||
|
};
|
||||||
|
|
||||||
|
let flag = std::env::args().collect::<Vec<_>>();
|
||||||
|
let flag_len = flag.len();
|
||||||
|
let ret = quote! {
|
||||||
|
pub static RUSTC_FLAGS: [&str; #flag_len] = [#( #flag ),*];
|
||||||
|
|
||||||
|
#[ctor]
|
||||||
|
fn _set_rustc_flags() {
|
||||||
|
conduwuit_core::info::rustc::FLAGS.lock().expect("locked").insert(#crate_name, &RUSTC_FLAGS);
|
||||||
|
}
|
||||||
|
|
||||||
|
// static strings have to be yanked on module unload
|
||||||
|
#[dtor]
|
||||||
|
fn _unset_rustc_flags() {
|
||||||
|
conduwuit_core::info::rustc::FLAGS.lock().expect("locked").remove(#crate_name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ret.into()
|
||||||
|
}
|
||||||
@@ -207,6 +207,7 @@ clap.workspace = true
|
|||||||
console-subscriber.optional = true
|
console-subscriber.optional = true
|
||||||
console-subscriber.workspace = true
|
console-subscriber.workspace = true
|
||||||
const-str.workspace = true
|
const-str.workspace = true
|
||||||
|
ctor.workspace = true
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
opentelemetry.optional = true
|
opentelemetry.optional = true
|
||||||
opentelemetry.workspace = true
|
opentelemetry.workspace = true
|
||||||
|
|||||||
+6
-2
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use std::sync::{Arc, atomic::Ordering};
|
use std::sync::{Arc, atomic::Ordering};
|
||||||
|
|
||||||
use conduwuit_core::{debug_info, error};
|
use conduwuit_core::{debug_info, error, rustc_flags_capture};
|
||||||
|
|
||||||
mod clap;
|
mod clap;
|
||||||
mod logging;
|
mod logging;
|
||||||
@@ -13,9 +13,13 @@ mod sentry;
|
|||||||
mod server;
|
mod server;
|
||||||
mod signal;
|
mod signal;
|
||||||
|
|
||||||
pub use conduwuit_core::{Error, Result};
|
use ctor::{ctor, dtor};
|
||||||
use server::Server;
|
use server::Server;
|
||||||
|
|
||||||
|
rustc_flags_capture! {}
|
||||||
|
|
||||||
|
pub use conduwuit_core::{Error, Result};
|
||||||
|
|
||||||
pub use crate::clap::Args;
|
pub use crate::clap::Args;
|
||||||
|
|
||||||
pub fn run() -> Result<()> {
|
pub fn run() -> Result<()> {
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ tokio.workspace = true
|
|||||||
tower.workspace = true
|
tower.workspace = true
|
||||||
tower-http.workspace = true
|
tower-http.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
|
ctor.workspace = true
|
||||||
|
|
||||||
[target.'cfg(all(unix, target_os = "linux"))'.dependencies]
|
[target.'cfg(all(unix, target_os = "linux"))'.dependencies]
|
||||||
sd-notify.workspace = true
|
sd-notify.workspace = true
|
||||||
|
|||||||
@@ -12,10 +12,12 @@ use std::{panic::AssertUnwindSafe, pin::Pin, sync::Arc};
|
|||||||
|
|
||||||
use conduwuit::{Error, Result, Server};
|
use conduwuit::{Error, Result, Server};
|
||||||
use conduwuit_service::Services;
|
use conduwuit_service::Services;
|
||||||
|
use ctor::{ctor, dtor};
|
||||||
use futures::{Future, FutureExt, TryFutureExt};
|
use futures::{Future, FutureExt, TryFutureExt};
|
||||||
|
|
||||||
conduwuit::mod_ctor! {}
|
conduwuit::mod_ctor! {}
|
||||||
conduwuit::mod_dtor! {}
|
conduwuit::mod_dtor! {}
|
||||||
|
conduwuit::rustc_flags_capture! {}
|
||||||
|
|
||||||
#[unsafe(no_mangle)]
|
#[unsafe(no_mangle)]
|
||||||
pub extern "Rust" fn start(
|
pub extern "Rust" fn start(
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ webpage.optional = true
|
|||||||
blurhash.workspace = true
|
blurhash.workspace = true
|
||||||
blurhash.optional = true
|
blurhash.optional = true
|
||||||
recaptcha-verify = { version = "0.1.5", default-features = false }
|
recaptcha-verify = { version = "0.1.5", default-features = false }
|
||||||
|
ctor.workspace = true
|
||||||
|
|
||||||
[target.'cfg(all(unix, target_os = "linux"))'.dependencies]
|
[target.'cfg(all(unix, target_os = "linux"))'.dependencies]
|
||||||
sd-notify.workspace = true
|
sd-notify.workspace = true
|
||||||
|
|||||||
@@ -18,9 +18,8 @@
|
|||||||
use std::{sync::Arc, time::Duration};
|
use std::{sync::Arc, time::Duration};
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use conduwuit::{Result, Server, debug, error, info, warn};
|
use conduwuit::{Result, Server, debug, info, warn};
|
||||||
use database::{Deserialized, Map};
|
use database::{Deserialized, Map};
|
||||||
use rand::Rng;
|
|
||||||
use ruma::events::{Mentions, room::message::RoomMessageEventContent};
|
use ruma::events::{Mentions, room::message::RoomMessageEventContent};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use tokio::{
|
use tokio::{
|
||||||
@@ -87,27 +86,9 @@ impl crate::Service for Service {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the first check immediately and send errors to admin room
|
|
||||||
if let Err(e) = self.check().await {
|
|
||||||
error!(?e, "Failed to check for announcements on startup");
|
|
||||||
self.services
|
|
||||||
.admin
|
|
||||||
.send_message(RoomMessageEventContent::text_plain(format!(
|
|
||||||
"Failed to check for announcements on startup: {e}"
|
|
||||||
)))
|
|
||||||
.await
|
|
||||||
.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
let first_check_jitter = {
|
|
||||||
let mut rng = rand::thread_rng();
|
|
||||||
let jitter_percent = rng.gen_range(-50.0..=10.0);
|
|
||||||
self.interval.mul_f64(1.0 + jitter_percent / 100.0)
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut i = interval(self.interval);
|
let mut i = interval(self.interval);
|
||||||
i.set_missed_tick_behavior(MissedTickBehavior::Delay);
|
i.set_missed_tick_behavior(MissedTickBehavior::Delay);
|
||||||
i.reset_after(first_check_jitter);
|
i.reset_after(self.interval);
|
||||||
loop {
|
loop {
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
() = self.interrupt.notified() => break,
|
() = self.interrupt.notified() => break,
|
||||||
|
|||||||
+41
-15
@@ -56,18 +56,9 @@ pub async fn fetch_remote_content(
|
|||||||
|
|
||||||
let result = self
|
let result = self
|
||||||
.fetch_content_authenticated(mxc, user, server, timeout_ms)
|
.fetch_content_authenticated(mxc, user, server, timeout_ms)
|
||||||
.await
|
.await;
|
||||||
.inspect_err(|error| {
|
|
||||||
debug_warn!(
|
|
||||||
%mxc,
|
|
||||||
?user,
|
|
||||||
?server,
|
|
||||||
?error,
|
|
||||||
"Authenticated fetch of remote content failed"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
if let Err(Error::Request(Unrecognized, ..)) = &result {
|
if let Err(Error::Request(NotFound, ..)) = &result {
|
||||||
return self
|
return self
|
||||||
.fetch_content_unauthenticated(mxc, user, server, timeout_ms)
|
.fetch_content_unauthenticated(mxc, user, server, timeout_ms)
|
||||||
.await;
|
.await;
|
||||||
@@ -96,7 +87,7 @@ async fn fetch_thumbnail_authenticated(
|
|||||||
timeout_ms,
|
timeout_ms,
|
||||||
};
|
};
|
||||||
|
|
||||||
let Response { content, .. } = self.federation_request(mxc, server, request).await?;
|
let Response { content, .. } = self.federation_request(mxc, user, server, request).await?;
|
||||||
|
|
||||||
match content {
|
match content {
|
||||||
| FileOrLocation::File(content) =>
|
| FileOrLocation::File(content) =>
|
||||||
@@ -120,7 +111,7 @@ async fn fetch_content_authenticated(
|
|||||||
timeout_ms,
|
timeout_ms,
|
||||||
};
|
};
|
||||||
|
|
||||||
let Response { content, .. } = self.federation_request(mxc, server, request).await?;
|
let Response { content, .. } = self.federation_request(mxc, user, server, request).await?;
|
||||||
|
|
||||||
match content {
|
match content {
|
||||||
| FileOrLocation::File(content) => self.handle_content_file(mxc, user, content).await,
|
| FileOrLocation::File(content) => self.handle_content_file(mxc, user, content).await,
|
||||||
@@ -154,7 +145,7 @@ async fn fetch_thumbnail_unauthenticated(
|
|||||||
|
|
||||||
let Response {
|
let Response {
|
||||||
file, content_type, content_disposition, ..
|
file, content_type, content_disposition, ..
|
||||||
} = self.federation_request(mxc, server, request).await?;
|
} = self.federation_request(mxc, user, server, request).await?;
|
||||||
|
|
||||||
let content = Content { file, content_type, content_disposition };
|
let content = Content { file, content_type, content_disposition };
|
||||||
|
|
||||||
@@ -182,7 +173,7 @@ async fn fetch_content_unauthenticated(
|
|||||||
|
|
||||||
let Response {
|
let Response {
|
||||||
file, content_type, content_disposition, ..
|
file, content_type, content_disposition, ..
|
||||||
} = self.federation_request(mxc, server, request).await?;
|
} = self.federation_request(mxc, user, server, request).await?;
|
||||||
|
|
||||||
let content = Content { file, content_type, content_disposition };
|
let content = Content { file, content_type, content_disposition };
|
||||||
|
|
||||||
@@ -305,6 +296,7 @@ async fn location_request(&self, location: &str) -> Result<FileMeta> {
|
|||||||
async fn federation_request<Request>(
|
async fn federation_request<Request>(
|
||||||
&self,
|
&self,
|
||||||
mxc: &Mxc<'_>,
|
mxc: &Mxc<'_>,
|
||||||
|
user: Option<&UserId>,
|
||||||
server: Option<&ServerName>,
|
server: Option<&ServerName>,
|
||||||
request: Request,
|
request: Request,
|
||||||
) -> Result<Request::IncomingResponse>
|
) -> Result<Request::IncomingResponse>
|
||||||
@@ -315,6 +307,40 @@ where
|
|||||||
.sending
|
.sending
|
||||||
.send_federation_request(server.unwrap_or(mxc.server_name), request)
|
.send_federation_request(server.unwrap_or(mxc.server_name), request)
|
||||||
.await
|
.await
|
||||||
|
.map_err(|error| handle_federation_error(mxc, user, server, error))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handles and adjusts the error for the caller to determine if they should
|
||||||
|
// request the fallback endpoint or give up.
|
||||||
|
fn handle_federation_error(
|
||||||
|
mxc: &Mxc<'_>,
|
||||||
|
user: Option<&UserId>,
|
||||||
|
server: Option<&ServerName>,
|
||||||
|
error: Error,
|
||||||
|
) -> Error {
|
||||||
|
let fallback = || {
|
||||||
|
err!(Request(NotFound(
|
||||||
|
debug_error!(%mxc, user = user.map(tracing::field::display), server = server.map(tracing::field::display), ?error, "Remote media not found")
|
||||||
|
)))
|
||||||
|
};
|
||||||
|
|
||||||
|
// Matrix server responses for fallback always taken.
|
||||||
|
if error.kind() == NotFound || error.kind() == Unrecognized {
|
||||||
|
return fallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we get these from any middleware we'll try the other endpoint rather than
|
||||||
|
// giving up too early.
|
||||||
|
if error.status_code().is_redirection()
|
||||||
|
|| error.status_code().is_client_error()
|
||||||
|
|| error.status_code().is_server_error()
|
||||||
|
{
|
||||||
|
return fallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reached for 5xx errors. This is where we don't fallback given the likelihood
|
||||||
|
// the other endpoint will also be a 5xx and we're wasting time.
|
||||||
|
error
|
||||||
}
|
}
|
||||||
|
|
||||||
#[implement(super::Service)]
|
#[implement(super::Service)]
|
||||||
|
|||||||
@@ -34,9 +34,11 @@ pub mod transaction_ids;
|
|||||||
pub mod uiaa;
|
pub mod uiaa;
|
||||||
pub mod users;
|
pub mod users;
|
||||||
|
|
||||||
|
use ctor::{ctor, dtor};
|
||||||
pub(crate) use service::{Args, Dep, Service};
|
pub(crate) use service::{Args, Dep, Service};
|
||||||
|
|
||||||
pub use crate::services::Services;
|
pub use crate::services::Services;
|
||||||
|
|
||||||
conduwuit::mod_ctor! {}
|
conduwuit::mod_ctor! {}
|
||||||
conduwuit::mod_dtor! {}
|
conduwuit::mod_dtor! {}
|
||||||
|
conduwuit::rustc_flags_capture! {}
|
||||||
@@ -233,16 +233,6 @@ pub async fn try_auth(
|
|||||||
| AuthData::Dummy(_) => {
|
| AuthData::Dummy(_) => {
|
||||||
uiaainfo.completed.push(AuthType::Dummy);
|
uiaainfo.completed.push(AuthType::Dummy);
|
||||||
},
|
},
|
||||||
| AuthData::FallbackAcknowledgement(_) => {
|
|
||||||
// The client is checking if authentication has succeeded out-of-band. This is
|
|
||||||
// possible if the client is using "fallback auth" (see spec section
|
|
||||||
// 4.9.1.4), which we don't support (and probably never will, because it's a
|
|
||||||
// disgusting hack).
|
|
||||||
|
|
||||||
// Return early to tell the client that no, authentication did not succeed while
|
|
||||||
// it wasn't looking.
|
|
||||||
return Ok((false, uiaainfo));
|
|
||||||
},
|
|
||||||
| k => error!("type not supported: {:?}", k),
|
| k => error!("type not supported: {:?}", k),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -9,13 +9,18 @@ readme.workspace = true
|
|||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["generate-docs"]
|
||||||
|
generate-docs = ["dep:conduwuit", "dep:conduwuit-admin"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
conduwuit-admin.workspace = true
|
|
||||||
conduwuit.workspace = true
|
|
||||||
clap.workspace = true
|
clap.workspace = true
|
||||||
|
conduwuit = { workspace = true, optional = true }
|
||||||
|
conduwuit-admin = { workspace = true, optional = true }
|
||||||
|
|
||||||
askama = "0.15.1"
|
askama = "0.15.1"
|
||||||
cargo_metadata = "0.23.1"
|
cargo_metadata = "0.23.1"
|
||||||
|
duct = "1.1.1"
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
+7
-1
@@ -1,5 +1,6 @@
|
|||||||
mod tasks;
|
mod tasks;
|
||||||
|
|
||||||
|
use cargo_metadata::MetadataCommand;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
use crate::tasks::Task;
|
use crate::tasks::Task;
|
||||||
@@ -22,5 +23,10 @@ struct Args {
|
|||||||
fn main() -> impl std::process::Termination {
|
fn main() -> impl std::process::Termination {
|
||||||
let BaseArgs { task, args } = BaseArgs::parse();
|
let BaseArgs { task, args } = BaseArgs::parse();
|
||||||
|
|
||||||
task.invoke(args)
|
let metadata = MetadataCommand::new()
|
||||||
|
.no_deps()
|
||||||
|
.exec()
|
||||||
|
.expect("should have been able to run cargo");
|
||||||
|
|
||||||
|
task.invoke(metadata, args)
|
||||||
}
|
}
|
||||||
@@ -2,8 +2,6 @@ mod admin_commands;
|
|||||||
|
|
||||||
use std::{collections::HashMap, fs::File, io::Write, path::{Path, PathBuf}};
|
use std::{collections::HashMap, fs::File, io::Write, path::{Path, PathBuf}};
|
||||||
|
|
||||||
use cargo_metadata::MetadataCommand;
|
|
||||||
|
|
||||||
use crate::tasks::TaskResult;
|
use crate::tasks::TaskResult;
|
||||||
|
|
||||||
trait FileOutput {
|
trait FileOutput {
|
||||||
@@ -68,14 +66,9 @@ pub(crate) struct Args {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[expect(clippy::needless_pass_by_value)]
|
#[expect(clippy::needless_pass_by_value)]
|
||||||
pub(super) fn run(common_args: crate::Args, task_args: Args) -> TaskResult<()> {
|
pub(super) fn run(metadata: cargo_metadata::Metadata, common_args: crate::Args, task_args: Args) -> TaskResult<()> {
|
||||||
let mut queue = FileQueue::default();
|
let mut queue = FileQueue::default();
|
||||||
|
|
||||||
let metadata = MetadataCommand::new()
|
|
||||||
.no_deps()
|
|
||||||
.exec()
|
|
||||||
.expect("should have been able to run cargo");
|
|
||||||
|
|
||||||
let root = task_args.root.unwrap_or_else(|| metadata.workspace_root.join_os("docs/"));
|
let root = task_args.root.unwrap_or_else(|| metadata.workspace_root.join_os("docs/"));
|
||||||
|
|
||||||
admin_commands::generate(&mut queue)?;
|
admin_commands::generate(&mut queue)?;
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
use askama::Template;
|
||||||
|
use duct::cmd;
|
||||||
|
|
||||||
|
use crate::tasks::TaskResult;
|
||||||
|
|
||||||
|
#[derive(askama::Template)]
|
||||||
|
#[template(path = "release-notes.md")]
|
||||||
|
struct ReleaseNotes<'a> {
|
||||||
|
version: &'a str,
|
||||||
|
header: &'a str,
|
||||||
|
changelog: &'a str,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(clap::Args)]
|
||||||
|
pub(crate) struct Args;
|
||||||
|
|
||||||
|
pub(super) fn run(_: cargo_metadata::Metadata, _: crate::Args, _: Args) -> TaskResult<()> {
|
||||||
|
const TAG_PREFIX: &str = "v";
|
||||||
|
|
||||||
|
let tag = cmd!("git", "describe", "--exact")
|
||||||
|
.stdout_capture()
|
||||||
|
.read()
|
||||||
|
.expect("failed to get current tag");
|
||||||
|
|
||||||
|
let version = tag
|
||||||
|
.strip_prefix(TAG_PREFIX)
|
||||||
|
.expect("tag did not start with expected prefix");
|
||||||
|
|
||||||
|
eprintln!("Generating release notes for {version}");
|
||||||
|
|
||||||
|
let header = cmd!("git", "tag", "-l", &tag, "--format", "%(contents)")
|
||||||
|
.stdout_capture()
|
||||||
|
.read()
|
||||||
|
.expect("failed to read tag contents");
|
||||||
|
|
||||||
|
let mut changelog = cmd!("towncrier", "build", "--draft", "--version", &version)
|
||||||
|
.stdout_capture()
|
||||||
|
.stderr_null()
|
||||||
|
.read()
|
||||||
|
.expect("failed to run towncrier");
|
||||||
|
|
||||||
|
|
||||||
|
// towncrier generates a title with the project name and date, which we don't want. remove it here.
|
||||||
|
// split off the first line and make sure it's a markdown heading
|
||||||
|
assert!(changelog.starts_with("# "), "expected h1 at the start of towncrier output");
|
||||||
|
let changelog = changelog.split_off(changelog.find("\n\n").unwrap());
|
||||||
|
|
||||||
|
let rendered = ReleaseNotes {
|
||||||
|
version,
|
||||||
|
header: header.trim(),
|
||||||
|
changelog: changelog.trim()
|
||||||
|
}.render()?;
|
||||||
|
|
||||||
|
println!("{rendered}");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
+12
-6
@@ -1,29 +1,33 @@
|
|||||||
type TaskResult<T> = Result<T, Box<dyn std::error::Error>>;
|
type TaskResult<T> = Result<T, Box<dyn std::error::Error>>;
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! tasks {
|
macro_rules! tasks {
|
||||||
(
|
(
|
||||||
$(
|
$(
|
||||||
$module:ident: $desc:literal
|
$(#[$meta:meta])? $module:ident: $desc:literal
|
||||||
),*
|
),*
|
||||||
) => {
|
) => {
|
||||||
$(pub(super) mod $module;)*
|
$(
|
||||||
|
$(#[cfg($meta)])?
|
||||||
|
pub(super) mod $module;
|
||||||
|
)*
|
||||||
|
|
||||||
#[derive(clap::Subcommand)]
|
#[derive(clap::Subcommand)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub(super) enum Task {
|
pub(super) enum Task {
|
||||||
$(
|
$(
|
||||||
|
$(#[cfg($meta)])?
|
||||||
#[clap(about = $desc, long_about = None)]
|
#[clap(about = $desc, long_about = None)]
|
||||||
$module($module::Args),
|
$module($module::Args),
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Task {
|
impl Task {
|
||||||
pub(super) fn invoke(self, common_args: $crate::Args) -> TaskResult<impl std::process::Termination> {
|
pub(super) fn invoke(self, metadata: cargo_metadata::Metadata, common_args: $crate::Args) -> TaskResult<impl std::process::Termination> {
|
||||||
match self {
|
match self {
|
||||||
$(
|
$(
|
||||||
|
$(#[cfg($meta)])?
|
||||||
Self::$module(task_args) => {
|
Self::$module(task_args) => {
|
||||||
$module::run(common_args, task_args)
|
$module::run(metadata, common_args, task_args)
|
||||||
},
|
},
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
@@ -33,5 +37,7 @@ macro_rules! tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks! {
|
tasks! {
|
||||||
generate_docs: "Generate various documentation files. This is run automatically when compiling the website."
|
#[feature = "generate-docs"]
|
||||||
|
generate_docs: "Generate various documentation files. This is run automatically when compiling the website.",
|
||||||
|
generate_release_notes: "Generate release notes from towncrier and a git tag. Used by CI."
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
# Continuwuity {{ version }}
|
||||||
|
|
||||||
|
{{ header }}
|
||||||
|
|
||||||
|
{{ changelog }}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Get Continuwuity
|
||||||
|
|
||||||
|
### Docker Images
|
||||||
|
- Forgejo: `forgejo.ellis.link/continuwuation/continuwuity:v{{ version }}`
|
||||||
|
|
||||||
|
Mirrors (may be outdated):
|
||||||
|
- Docker Hub: `docker.io/continuwuity/continuwuity:v{{ version }}`
|
||||||
|
- GitHub: `ghcr.io/continuwuity/continuwuity:v{{ version }}`
|
||||||
|
- GitLab: `registry.gitlab.com/continuwuity/continuwuity:v{{ version }}`
|
||||||
|
|
||||||
|
You can also use the `latest` tag for the most recent release.
|
||||||
|
|
||||||
|
### First-party Packages
|
||||||
|
|
||||||
|
- [Debian packages](https://forgejo.ellis.link/continuwuation/-/packages/debian/continuwuity/)
|
||||||
|
- [Fedora RPM packages](https://forgejo.ellis.link/continuwuation/-/packages/rpm/continuwuity/)
|
||||||
|
|
||||||
|
### Community Packages
|
||||||
|
|
||||||
|
[](https://repology.org/project/continuwuity/versions)
|
||||||
|
|
||||||
|
### Binaries
|
||||||
|
|
||||||
|
Plain binaries are distributed below. They require glibc and liburing to work - most distributions already have these installed.
|
||||||
|
|
||||||
|
### From Source
|
||||||
|
See our [deployment documentation](https://continuwuity.org/deploying.html) for instructions on building from source.
|
||||||
Reference in new issue
Block a user