Commit graph

1804 commits

Author SHA1 Message Date
Jonas Platte
c713e9f21f
Remove no-op #[async_trait] attribute 2025-07-31 20:44:54 +02:00
Jonas Platte
a3da77ce2c
Add a couple extra Sync bounds
Not necessary right now, but required for axum 0.8.
2025-07-31 20:44:54 +02:00
Charles Hall
e6dbc293f1 remove jemalloc support
It's no longer being developed and it is very very annoying to maintain
support for.
2025-07-21 21:48:57 -07:00
Olivia Lee
55a01e7113
don't strip unknown keys when copying redacts property to/from content
Servers are required to preserve unknown properties in event content,
since they may be added by a future version of the spec. Round-tripping
through RoomRedactionEventContent results in dropping all unknown
properties.
2025-07-20 18:07:30 -07:00
Olivia Lee
9a142c7557
refactor Pdu::copy_redacts to use early returns 2025-07-20 12:46:06 -07:00
Olivia Lee
88ad596e8d
add type-safe accessors to account_data service 2025-06-02 11:07:21 -07:00
Olivia Lee
b82458a460
use event content in account_data service api instead of full events
This eliminates the possibility of passing an event that has a
mismatching type, reducing the space of possible invalid states.
2025-06-02 11:07:21 -07:00
Olivia Lee
66210bc32d
separate account_data service methods for room vs global events
Previously we were mashing everything together as RoomAccountDataEvent,
even the global events. This technically worked, because of the hidden
custom fields on the ruma event types, but it's confusing and easy to
mess up. Separate methods with appropriate types are preferable.
2025-06-02 11:07:21 -07:00
Olivia Lee
6897f0ba34
clarify behavior in service::account_data::changes_since docs 2025-06-02 11:07:21 -07:00
Olivia Lee
fe14300d91
reintroduce account_data::Service struct
In preparation for adding some additional methods at the service level.

Dropping the tracing spans for the data methods, because two duplicate
spans here seems kinda excessive.
2025-06-02 11:07:21 -07:00
LordMZTE
868bb44adf
support listening on Unix sockets 2025-06-01 22:16:48 +02:00
Olivia Lee
188eac5cfd include ban reasons when banning a user that already had a member event
The case where the user never had a member event in the room is already
handled correctly.
2025-06-01 09:38:27 +00:00
Lambda
c965c9747b Send User-Agent header in outbound requests 2025-05-29 19:53:02 +00:00
Lambda
d425ba72f8
Update ruma to 0.12.2 2025-05-04 14:03:46 -07:00
avdb13
48ecf50973 update documentation of service::users::Data::iter 2025-04-20 03:47:07 +00:00
Charles Hall
d1370f9834
refactor fetch_unknown_prev_events
Early returns (or continues, in this case) good.
2025-04-16 19:16:57 -07:00
Olivia Lee
6cb7896e17
use trust-dns for all DNS queries
Previously we were only using trust-dns for resolving SRV records in
server discovery, and then for resolving the hostname from the SRV
record target if one exists. With the previous behavior, admins need to
ensure that both their system resolver and trust-dns are working
correctly in order for outgoing traffic to work reliably. This can be
confusing to debug, because it's not obvious to the admin if or when
each resolver are being used. Now, everything goes through trust-dns and
outgoing federation DNS should fail/succeed more predictably.

I also expect some performance improvement from having an in-process DNS
cache, but haven't taken measurements yet.
2025-04-14 15:56:33 -07:00
Olivia Lee
e249aed1cb
rename Resolver -> FederationResolver and document 2025-04-14 15:50:04 -07:00
Olivia Lee
e98dd5b9a3
put global trust-dns resolver in an Arc
This allows us to reference it in reqwest clients configuration.
2025-04-14 15:50:04 -07:00
Olivia Lee
33f3592612
fix starting the server when db/media dirs do not exist yet
This used to be supported, as we explicitly call std::fs::create_dir_all
when initializing these, but it was broken in
b01b70fc20, which attempts to canonicalize
the paths to check for overlap before creating them.
2025-04-14 15:28:31 -07:00
Olivia Lee
abb1b5681e
add partial_canonicalize helper function
This is useful for checking for potential overlap between paths that
have not been fully created yet.
2025-04-14 15:28:31 -07:00
Lambda
6bcc4e310e
Immediately trigger EDU sending after client read receipt
Previously, read receipts would only be forwarded via federation
incidentally when some PDU was later sent to the destination server.
Trigger a send without any event to collect EDUs and get read receipts
out directly.
2025-03-30 16:48:06 -07:00
Lambda
81c5f09919
service/sending: tiny refactors, NFC 2025-03-30 16:48:06 -07:00
Lambda
d9c7fbbd82
services/sending: avoid unnecessary clone 2025-03-30 16:48:06 -07:00
Lambda
ed12b0bf67
services/sending: guard against federation requests to ourselves
These would always fail and get stuck/retried forever.
2025-03-30 16:48:02 -07:00
Charles Hall
d6475eee6d
remove redundant condition 2025-03-21 16:48:56 -07:00
Charles Hall
a04951541a
don't check canonicalized paths while sandboxed
Because the configured paths won't exist in the sandbox, so
canonicalization would fail.
2025-03-21 16:25:42 -07:00
Charles Hall
50583bc93e
reject overlapping non-canonical paths too
For example, if the database path is `/foo` and the media path is
`/foo/bar`, but `/foo/bar` is a symlink or hardlink to `/baz`, the
previous check would pass. The whole point of this check is to ensure
that the database and media data can't step on each other, so this check
is needed to deny that kind of situation as well.

It would probably be good to add a test for this behavior.
2025-03-21 16:25:31 -07:00
Charles Hall
b01b70fc20
reject overlapping media and database paths 2025-03-20 11:33:59 -07:00
Charles Hall
81a449d1d2
make database path a pathbuf
I'm guessing it wasn't like this already because of one of the admin
commands I deleted.
2025-03-20 11:33:59 -07:00
Charles Hall
5a5608e088
separate media and database paths
The primary motivation for this change is to support databases that
don't take a path, e.g. out of process databases.

This configuration structure leaves the door open for other media
storage mechanisms in the future, such as S3.

It's also structured to avoid `#[serde(flatten)]` so that we can use
`#[serde(deny_unknown_fields)]`.
2025-03-20 11:33:59 -07:00
Charles Hall
ae920fdbe8
make option name less redundant 2025-03-20 10:40:20 -07:00
Charles Hall
0a6d2b2731
make a media section in the config file 2025-03-20 10:40:20 -07:00
Charles Hall
f6b0a10e6e
implement _file in terms of _folder
what the heck lol
2025-03-20 10:40:16 -07:00
Lambda
175a62007d Update MSRV to 1.84.0
And appease clippy (`__CARGO_FIX_YOLO=1 cargo clippy --fix` plus some
manual type shuffling).
2025-02-18 17:06:08 +00:00
Lambda
5616510727 Use UInt instead of u32 for max request size
Sometimes you just really want to upload a full disk image as media.
2025-02-18 16:48:47 +00:00
Lambda
99924e5779 Add admin commands to get and reset tracing filters 2025-02-17 17:41:14 +00:00
Lambda
5eab758bd2 Make tracing filter reload handles mutable
Makes the following diff nicer.
2025-02-17 17:40:55 +00:00
Olivia Lee
472f51c350
allow adding canonical aliases from remote servers
Like is mentioned in the comment, this isn't explicitly required by the
spec, but it's reasonable and what synapse does.
2025-01-23 09:20:10 -08:00
Olivia Lee
29d8fbaefa
only validate canonical aliases that are new
Previously we required every alias in a canonical alias event sent by a
client to be valid, and would only validate local aliases. This
prevented clients from adding/removing canonical aliases if there were
existing remote or invalid aliases.
2025-01-23 09:20:10 -08:00
Olivia Lee
50c1e77cd6
factor canonical alias event validation into a helper function
Not all the semantics from the spec quote in the doc comment are
implemented yet.
2025-01-23 09:20:10 -08:00
Olivia Lee
051221c0ab
validate schema of new canonical alias events sent by clients
Previously, we would only attempt to validate the aliases in the event
content if we were able to parse the event, and would silently allow it
otherwise.
2025-01-23 09:20:10 -08:00
Olivia Lee
c748c7c188
return M_BAD_ALIAS when trying to set non-existent canonical aliases
This is the error code named in the spec.
2025-01-20 16:59:01 -08:00
Olivia Lee
795ce42518
return M_NOT_YET_UPLOADED when backing files are missing for a thumbnail
This was done for fetching original media files in
c70cfd3d25, but the change for thumbnails
was missed.
2024-12-13 01:21:14 -08:00
Olivia Lee
f216112455
don't treat media file open errors other than NotFound as missing media
For example, we want to return M_UNKNOWN and propagate the error if
somebody set up their database directory permissions wrong.
2024-12-13 01:21:05 -08:00
Olivia Lee
67f0689d73
move media file read/write logic to a helper function 2024-12-13 01:18:46 -08:00
Olivia Lee
ba72616672
do not backoff remote device key queries when a request fails due to backoff
The previous logic would increment the backoff counter both when a
request actually fails and when we do not make a request because the
server was already in backoff. This lead to a positive feedback loop
where every request made while a server is in backoff increases the
backoff delay, making it impossible to recover from backoff unless the
entire backoff delay elapses with zero requests.
2024-12-11 13:02:11 -08:00
Olivia Lee
4ee8312068
reset device key query backoff after a successful request
Failing to reset the backoff state resulted in a monotonically
increasing backoff delay. If a remote server was temporarily
unavailable, we would have a persistently increased rate of key query
failures until the backoff state was reset by a server restart. If
enough key queries were attempted while the remote was unavailable, it
can accumulate an arbitrarily long backoff delay and effectively block
all future key queries to this server.
2024-12-11 13:02:10 -08:00
Olivia Lee
79cedccdb6
factor remote device key request logic into helper functions
This is pure code-motion, with no behavior changes. The new structure
will make it easier to fix the backoff behavior, and makes the code
somewhat less of a nightmare to follow.
2024-12-11 13:02:10 -08:00
Lambda
daceadb310 sync/v3: factor out into separate functions
This is both easier to read and produces much better tracing spans.
2024-12-11 17:38:49 +00:00