Commit graph

38 commits

Author SHA1 Message Date
Charles Hall
e0cf163486
delete useless admin commands
To clear caches, restart the server. We may want to consider adding the
cache sizes and database memory usage as metrics in the future.
2024-10-20 13:29:28 -07:00
Benjamin Lee
9add9a1e96
fix room version comparisons
Fixes a set of bugs introduced by 00b77144c1,
where we replaced explicit `RoomVersionId` matches with `version < V11`
comparisons. The `Ord` impl on `RoomVersionId` does not work like that,
and is in fact a lexicographic string comparison[1]. The most visible
effect of these bugs is that incoming redaction events would sometimes
be ignored.

Instead of reverting to the explicit matches, which were quite verbose,
I implemented a `RoomVersion` struct that has flags for each property
that we care about. This is similar to the approach used by ruma[2] and
synapse[3].

[1]: 7cfa3be0c6/crates/ruma-common/src/identifiers/room_version_id.rs (L136)
[2]: 7cfa3be0c6/crates/ruma-state-res/src/room_version.rs
[3]: c856ae4724/synapse/api/room_versions.py
2024-09-26 13:01:25 -07:00
Charles Hall
b34d78a030
skip over broken keys instead of aborting
Errors will show up in the logs in this case with detailed information
about what broke.

In the future we should add some kind of database integrity check
functionality and also functionality to repair/delete broken data, but
for now this at least makes it work 99.99% of the time.
2024-09-19 15:23:59 -07:00
Benjamin Lee
ba7b224c38
add dry-run mode to delete-remote-media-files admin command 2024-09-17 19:31:54 -07:00
Benjamin Lee
9d14c5d461
add admin command to delete all remote media files 2024-09-17 19:31:51 -07:00
Benjamin Lee
d7087c66bb
add admin command to delete individual media files 2024-09-17 19:13:54 -07:00
Lambda
341f4213d0 Use self instead of going through services() 2024-09-05 19:42:37 +00:00
avdb13
00b77144c1 chore: deprecate support for unstable room versions 2024-08-12 06:18:28 +02:00
Lambda
34ccb2cd06 Use TokenSet for roomid_mutex_state 2024-07-22 18:07:03 +00:00
Lambda
f89e1c7dfc
Allow tracing filters to be changed at runtime
ReloadHandle is taken from conduwuit commit
8a5599adf9eafe9111f3d1597f8fb333b8b76849, authored by Benjamin.

Co-authored-by: Benjamin Lee <benjamin@computer.surgery>
2024-06-27 16:04:23 -07:00
Charles Hall
6aca128547
generalize documentation, make the name shorter
It's more useful than just *debug* logs, but yes, should not be relied
upon for logic reasons.
2024-06-24 12:38:34 -07:00
Charles Hall
44088852cf
remove show-config admin room command
Just `cat` the config file. Also this code would be very annoying to
maintain. Getting rid of this also revealed that another config option
is specific to RocksDB, so `cfg`s for that have been added.
2024-06-12 19:56:59 -07:00
Charles Hall
c7e03a06f7
refuse admin room alias changes unless admin bot
I.e. don't allow the `#admins:example.com` alias to be set or unset by
any user other than `@grapevine:example.com`.
2024-06-12 18:36:55 -07:00
Charles Hall
339a869872
create admin bot room alias id once and reuse it 2024-06-12 16:30:08 -07:00
Charles Hall
95a24c761d
create admin bot user id once and reuse it
This way we don't need to remember to do the conditional everywhere.
2024-06-12 16:23:22 -07:00
Matthias Ahouansou
9087da91db
fix(keys): only use keys valid at the time of PDU or transaction, and actually refresh keys
Previously, we only fetched keys once, only requesting them again if we have any missing, allowing for ancient keys to be used to sign PDUs and transactions
Now we refresh keys that either have or are about to expire, preventing attacks that make use of leaked private keys of a homeserver
We also ensure that when validating PDUs or transactions, that they are valid at the origin_server_ts or time of us receiving the transaction respectfully
As to not break event authorization for old rooms, we need to keep old keys around
We move verify_keys which we no longer see in direct requests to the origin to old_verify_keys
We keep old_verify_keys indefinitely as mentioned above, as to not break event authorization (at least until a future MSC addresses this)

Original patch by Matthias. Benjamin just rebased it onto grapevine and
fixed clippy/rustc warnings.

Co-authored-by: Benjamin Lee <benjamin@computer.surgery>
2024-06-12 11:10:50 -07:00
Charles Hall
5048af3a8f
enable doc_markdown lint 2024-05-26 19:47:00 -07:00
Lambda
5172f66c1a More useful tracing spans 2024-05-20 16:49:45 +00:00
Lambda
ac42e0bfff Fix spans in tokio::spawn-ed tasks
tokio::spawn is a span boundary, the spawned future has no parent span.

For short futures, we simply inherit the current span with
`.in_current_span()`.

For long running futures containing a sleeping infinite loop, we don't
actually want a span on the entire task or even the entire loop body,
both would result in very long spans. Instead, we put the outermost span
(created using #[tracing::instrument] or .instrument()) around the
actual work happening after the sleep, which results in a new root span
being created after every sleep.
2024-05-20 16:49:40 +00:00
Lambda
092315e2cd remove unnecessary async and select!{} 2024-05-20 16:49:20 +00:00
Charles Hall
5cb2551422
enable error_on_line_overflow and fix errors
These required some manual intervention.
2024-05-16 19:11:40 -07:00
Charles Hall
0afc1d2f50
change rustfmt configuration
This change is fully automated, except the `rustfmt.toml` changes and
a few clippy directives to allow specific functions with too many lines
because they are longer now.
2024-05-16 19:11:40 -07:00
Charles Hall
ac53948450
use more, qualify less
Doing this will allow `rustfmt` to collapse lines more efficiently.
Specifically, a lot of these lines fail to wrap to 80 columns without
these changes.
2024-05-16 19:09:10 -07:00
Charles Hall
0915aba44c
remove commented-out code 2024-05-16 15:20:56 -07:00
Charles Hall
a25f2ec950
add conduit compat mode
This makes it possible to deploy Grapevine while using a database
originally created by Conduit, including leaving the admin bot user's
localpart the same as before.
2024-05-14 20:21:51 -07:00
Charles Hall
e3672eb4e0
enable unused_self lint
Functions using `services()` are allowed to pointlessly take `self`
because the existence of `services()` is a crime and the solution is
making the types store references to their dependencies and then going
through `self`, so just allowing the lint saves us from modifying some
code only to switch it back later. Much later. Getting rid of
`services()` will probably be an ordeal.
2024-05-14 20:01:25 -07:00
Charles Hall
baab928281
enable too_many_lines lint
And just disable it everywhere it fires, I know.
2024-05-14 20:01:24 -07:00
Charles Hall
db4951c5fd
enable semicolon_if_nothing_returned lint 2024-05-14 20:01:24 -07:00
Charles Hall
4e6c8451ca
enable match_bool lint 2024-05-14 20:01:24 -07:00
Charles Hall
645d88177a
enable manual_string_new lint 2024-05-14 20:01:24 -07:00
Charles Hall
ebae8ceeb0
enable implicit_clone lint 2024-05-14 19:59:43 -07:00
Charles Hall
b0f65913f3
enable ignored_unit_patterns lint 2024-05-14 19:59:43 -07:00
Charles Hall
844b32f097
enable string_slice lint
Also swaps out vendored HTML-escaping code for a dependency that I
imagine has decent testing considering all of its reverse depedencies.
2024-05-12 19:08:12 -07:00
Charles Hall
9abe4799db
enable string_add lint 2024-05-12 19:01:29 -07:00
Charles Hall
052f3088e9
enable let_underscore_must_use lint 2024-05-12 18:51:26 -07:00
Charles Hall
bd6ea4e358
enable format_push_string lint 2024-05-12 18:51:26 -07:00
Charles Hall
d748544f0e
enable unreachable_pub lint
This causes some other lints to start firing too (which is good), but
I'm going to fix them in follow-up commits to keep things organized.
2024-05-12 18:51:26 -07:00
Charles Hall
a626e7b0f0
enable mod_module_files lint 2024-05-12 18:51:26 -07:00
Renamed from src/service/admin/mod.rs (Browse further)