Commit graph

2498 commits

Author SHA1 Message Date
Charles Hall
9a5e552ca0
set up mdbook
This adds some new tools in CI for lint the book and also sets up
automated deployment to GitLab Pages. Also adds a readme that suggests
reading the book, since that's where all the information will be.
2024-06-16 20:23:18 -07:00
Charles Hall
e318dfcb3d
drop oci image outputs
We don't support this anyway. OCI images will be needed for testing with
Complement, but there are a bunch of other special requirements that has
so these oci image outputs won't be very useful for that anyway.
2024-06-14 14:04:46 -07:00
Benjamin Lee
0b5a07d192
add alternate !admin prefix for admin commands
This is supported on conduwuit, and I liked it because it's faster for
me to type than tab-completing the bot user, and because it makes it a
little easier to copy-paste admin commands.
2024-06-14 11:32:52 -07:00
Benjamin Lee
a909e2079b
config options for log format and color usage
We want to be able to disable colors for complement logs (since they
are likely to be opened in a text editor). There's no pressing need for
alternative log formats, but I'm interested in whether the 'pretty'
format will be easier for debugging.

I chose to add 'log_*' options rather than making a separate 'log'
section for now. There's been some discussion about trying to separate
the tracing/logging stuff into more structured sections, but that can
happen later.
2024-06-13 21:21:14 -07:00
Benjamin Lee
4f041f9153
specify listener in error messages and logs
The "listening for incoming traffic on ..." log line is new, but
something I've wanted even when we only supported one listener.

I considered getting rid of `clippy::too_many_lines` by factoring out
the construction of `app` to a separate function, but found that
specifying it's type (or relevant traits) got quite hairy.
2024-06-13 15:49:21 -07:00
Benjamin Lee
f7d7952f9b
allow listening on multiple ports in config
This is a config compatibility break.

The ability to listen on multiple ports, including both TLS and non-TLS,
is necessary for running complement against grapevine.
2024-06-13 13:33:50 -07:00
Benjamin Lee
b7ad00ef6e
distinct error types for running server
This is in preparation for the config change to allow specifying
multiple listeners, which will add several other possible error
conditions.
2024-06-13 13:30:29 -07:00
Charles Hall
76b060aa84
only process admin commands if bot is in room
This isn't exploitable in any way, it just meant that the bot could
receive and run commands from users who were already in the admin room
despite the bot not being in the room, which also means the bot would be
unable to send response messages.

Now, the bot will simply ignore admin room messages if the bot isn't in
the admin room.
2024-06-12 20:48:06 -07:00
Charles Hall
b0d85bb575
use admin_bot_user_id more
Also change some terminology to be less weird.
2024-06-12 20:42:13 -07:00
Charles Hall
d4b5f62bfe
simplify is_admin 2024-06-12 20:42:13 -07:00
Charles Hall
70fa17dde0
enable clap's wrap_help feature
This makes the output easier to read.
2024-06-12 19:57:00 -07:00
Charles Hall
85e77832e9
follow xdg base dirs spec by default 2024-06-12 19:57:00 -07:00
Charles Hall
c46eaed0e0
parse configured EnvFilter once
This allows the error handling to be done upfront instead of for each
use. In particular, the `toml` error now points to the span of text in
the config file where the misconfigured EnvFilter value is. This is much
better than the previous error that did not indicate what was actually
causing it to happen.
2024-06-12 19:56:59 -07:00
Charles Hall
6b819d6f2d
move config loading to config module
This separates concerns a bit more. We will probably want to extend the
logic for config loading in the future, and that stuff should all live
in the relevant place. This change points us in the right direction.
2024-06-12 19:56:59 -07:00
Charles Hall
2b0bc140cf
drop figment
Just deserialize directly via the `toml` crate.
2024-06-12 19:56:59 -07:00
Charles Hall
003c0a4928
drop nested config
This functionality was never actually used AFAICT, as no way to provide
alternate profiles was ever provided.

This changes the configuration format to remove the `[global]` section,
everything that was previously under that namespace is now at the top
level.
2024-06-12 19:56:59 -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
a6087e97e1
remove config deprecation functionality
This is a hard fork, we don't need to inherit this cruft. Really, I
should've noticed and removed this closer to the beginning of our
history.
2024-06-12 19:56:59 -07:00
Charles Hall
9a92a8047e
drop support for environment variables
The configuration file is now the canonical way to, well, configure.
This change is desirable because it gives us much more flexibility with
how configuration is structured. Environment variables are insufficient
because, for example, they're a flat namespace and have no built-in way
to represent lists.
2024-06-12 19:56:59 -07:00
Charles Hall
9b115b4110
require config path via cli, remove env var 2024-06-12 19:56:59 -07:00
Charles Hall
3650fde0ac
rename src/{clap -> args}.rs 2024-06-12 19:56:59 -07:00
Charles Hall
b34e001997
remove unused Clone derives 2024-06-12 19:56:59 -07:00
Charles Hall
0643a3f081
remove pointless pub(crate) and use self::
And also fix the ordering of things in state_compressor.
2024-06-12 19:56:56 -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
273ab33809
reintroduce rooms::alias::Serivce struct
We're going to need it.
2024-06-12 16:41:52 -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
Matthias Ahouansou
da99b0706e
fix(edus): ensure sender server is the same as the user in the content
Original patch by Matthias. Benjamin modified the logic to include
logging when an event was rejected, for consistency with the existing
check on device key updates.

Co-authored-by: Benjamin Lee <benjamin@computer.surgery>
2024-06-12 10:36:41 -07:00
Benjamin Lee
83cdc9c708
drop redacted events from search results 2024-06-12 10:32:36 -07:00
Matthias Ahouansou
f74043df9a
fix: de-index pdus when redacted 2024-06-12 10:27:39 -07:00
Benjamin Lee
cc5a9d3440
factor search tokenization out into a function
This ensures that the tokenization algorithm will remain in sync between
querying, indexing, and deindexing. The existing code had slightly
different behavior for querying, because it did not discard words with
>50 bytes. This was inconsequential, because >50 byte tokens are never
present in the index.
2024-06-12 10:26:14 -07:00
Charles Hall
0c2094a56f
record FoundIn with metrics instead of traces
This is much more efficient in terms of network use and data storage,
and also easier to visualize.
2024-06-06 20:56:36 -07:00
Charles Hall
9364d44ce2
use strum instead 2024-06-05 17:41:39 -07:00
Charles Hall
792300d220
derive Copy on FoundIn 2024-06-05 17:41:39 -07:00
Charles Hall
784b86a1f6
make stringified names mirror variant names 2024-06-05 17:41:39 -07:00
Charles Hall
38382128ac
rename FoundIn::{value -> as_str} 2024-06-05 17:41:39 -07:00
Charles Hall
22dd7f1a54
move FoundIn to observability.rs 2024-06-05 17:41:36 -07:00
Charles Hall
0bd2c43dab
don't strip binary for dev builds 2024-06-05 16:42:40 -07:00
Charles Hall
972c25beca
remove unnecessary whitespace 2024-06-05 16:42:16 -07:00
Charles Hall
71f3d84115
rename password-related utils functions 2024-06-04 19:35:25 -07:00
Charles Hall
aa4cd8b1e1
switch to RustCrypto's argon2 crate 2024-06-04 19:35:21 -07:00
Lambda
60d32ddf48
Fix tracing in fetch_signing_keys() 2024-06-04 13:32:32 -07:00
Lambda
7dbae9ac2b
Fix tracing in send_request() 2024-06-04 13:32:32 -07:00
Lambda
c6f75a1b93
Add tracing span for Ar::from_request()
The fact that this is called for every request is somewhat obscured, it
should be obvious in tracing at least.
2024-06-04 13:32:32 -07:00
Lambda
dd6cda4519
Useful span names for incoming HTTP requests
Usually it's not possible to make span names dynamic, but the magic
otel.name attribute changes the span name in the OpenTelemetry tracing
backend.
2024-06-04 13:32:32 -07:00
Lambda
0b9e43cbdd
Record authentication info in incoming requests 2024-06-04 13:32:32 -07:00
Lambda
f7a0e3012b
server_server: log ignored signing key updates 2024-06-04 13:32:32 -07:00
Lambda
88bb2ea600
Remove redundant span attributes
There's no need to record attributes that are already present in all
callers.
2024-06-04 13:32:31 -07:00
Lambda
f35cbfd89e
More tracing spans 2024-06-04 13:32:31 -07:00