Compare commits

...
196 Commits
Author SHA1 Message Date
Jason Volk e106e50ed0 Update the since token to skip empty range from prior iteration.
Log and discard presence ping errors without preventing sync.

Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-06 08:06:39 +00:00
Jason Volk 00f11a9e8f Additional instrumentation around global counter events. 2025-08-06 06:45:43 +00:00
Jason Volk bf48c7b1b4 Move active and finished request counters out of span field.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-06 00:11:26 +00:00
Jason Volk 8a8a5d598e Fix sync loop watcher ABA.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-05 10:51:56 +00:00
Jason Volk fa84a7e6c2 Bump 1.3.0
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-05 07:02:31 +00:00
Jason Volk 2bdeca0ed3 ci: Fix missing condition for Push Branch. (#103)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-05 07:02:31 +00:00
Jason Volk c337ea1864 Fixes for sync v3 protocol compliance.
Add sync v3 filter support.

Fix events duplicated between state and timeline; cleanup some lets.

Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-04 18:55:37 +00:00
Jason Volk b00361d274 Add specific shorteventid to shortstatehash query function.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-04 18:55:37 +00:00
Jason Volk fb17aa19bf Add configs for creating the admin room and granting first user.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-04 18:55:37 +00:00
Jason Volk fc28e8e1dd Update flakes list; unflake several packages as fail.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-04 18:55:37 +00:00
Jason Volk cea25c6580 docker: Make the complement defaults more accessible.
commit newly uncovered tests.

Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-04 05:13:06 +00:00
Jason Volk a0dc37e024 Fetch prev_events concurrently.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-04 05:13:06 +00:00
Jason Volk 003257693b Fetch outlier and auth chains concurrently.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-04 00:48:30 +00:00
Jason Volk bc898efcce Uncomment generated-config's global section header, comment all others. (#116)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-03 21:55:36 +00:00
Jason Volk fa8ad1d629 Update the router log truncator for new axum syntax.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-03 00:53:53 +00:00
Jason Volk 44b60050b3 Reorder auth match cases; add todo for AppserviceTokenOptional.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-02 22:02:26 +00:00
Jason Volk 4b84e7c31a Flatten and dedup append_incoming branch in upgrade_outlier.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-02 18:00:20 +00:00
Jason Volk 4237f21903 Renames for several event_handler service files, fn's and args.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-02 18:00:20 +00:00
Jason Volk 4ac61fd87b Remove federation_handletime for now.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-02 18:00:20 +00:00
Jason Volk d217927000 Split fetch_outlier; abstract backoff stanzas into fn.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-02 18:00:20 +00:00
Jason Volk 4b9b85f671 ABI encapsulations; generate leaf code in pub fn's rather than inling them.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-02 18:00:20 +00:00
Jason Volk fa3b72947a Eliminate rooms outlier service, duplicate subset of timeline service.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-02 18:00:20 +00:00
Jason Volk 5d963abda6 Combine rooms timeline service data unit into mod; eliminate wrappers.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-02 18:00:20 +00:00
ObiomaAtWanagu a91380ac17 Change from the error 'No more rooms.' to the output 'No rooms are published.' if there are no rooms.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-02 18:00:20 +00:00
Jason Volk 1664a2c225 Implement refresh-tokens. (resolves #50)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-01 09:14:58 +00:00
Jason Volk 0d7eeb7766 Extend the append count guards over subsequent operations.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-01 09:14:58 +00:00
Jason Volk 16447f7383 Handle defaulting trailing elements in truncated database records.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-01 05:30:40 +00:00
Jason Volk 3612b04890 Add timepoint_from_epoch to time utils.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-08-01 03:40:27 +00:00
Jason Volk e6f1b98d6a Improve tracing of request error responses.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-31 14:31:28 +00:00
Jason Volk 6742e1d206 Sort misc cargo list entries, database maps.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-31 07:02:59 +00:00
Jason Volk dc0976a2e5 Respond with 403 instead of 404 for non-existing user.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-31 07:02:59 +00:00
Jason Volk f3f23ee7ee Fix missing counter retirements (51931de94c).
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-30 23:34:21 +00:00
Jason Volk 0b15ab2006 Ensure unwind safety in dispatch sequence.
Ensure await safety/efficiency in retirement sequence.

Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-30 23:34:21 +00:00
Jason Volk bd0c3e33e2 Loop syncv3 for robust response without re-request overhead.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-30 23:34:21 +00:00
Jason Volk 1bb16c8b73 Additional span logging of counter state; trace logging of contents.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-30 23:34:21 +00:00
Jason Volk 59b62b1453 Fix partial v3 syncs on post-timeout pass; fix partial state on room join.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-30 23:34:21 +00:00
Jason Volk 2e0b156de0 Fix missing user account data sync watcher.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-30 19:28:16 +00:00
Jason Volk 3593b8ebf7 Implement Debug for RawPduId.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-30 19:09:46 +00:00
Jason Volk 80015a6a30 Fix missed rustfmt let due to comment in chain.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-30 19:09:46 +00:00
Jason Volk 95e49d3cb8 Fix map_or calling function.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-30 19:09:46 +00:00
Jason Volk 25164e030d Hide own user from user directory search results.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-30 19:09:46 +00:00
Jason Volk f04924d6be docker: Extract complement logs on failure.
docker: Sort config options used during complement.

Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-29 14:34:42 +00:00
Jason Volk df7cd58618 Support matching room_id as publicrooms search term.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-29 04:18:21 +00:00
Jason Volk bf12e05dae Add meta iteration for public rooms.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-29 04:18:21 +00:00
Jason Volk e53366a492 Fix missing sync watcher not added for knocking feature.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-29 04:18:21 +00:00
Jason Volk ce25d79e66 Flatten authorised-join check queries.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-29 04:18:21 +00:00
Jason Volk 71ef093edc Unbox and pin various either-or futures.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-29 04:18:21 +00:00
Jason Volk 066097a83d Optimize user and appservice token queries.
Split/cleanup api::router auth delegator.

Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-29 04:18:20 +00:00
Jason Volk 1c24ed09fa Fix misuse of try_select in logical-or future util.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-29 04:18:20 +00:00
Jason Volk d3dbe09380 Add SystemTimeError to core error enum.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-27 13:09:30 +00:00
Jason Volk e9d0baa32e Add granular timeout configs for sync longpolling.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-27 11:34:15 +00:00
Jason Volk 7dd10ebc6c docs: Add note to configuration doc.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-27 11:03:12 +00:00
Jason Volk 29ac62ec27 Fix zero since-token value not used as initial sync condition.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-27 11:03:12 +00:00
Jason Volk 8c8985e8f2 Add user_id to v3 sync span; add span for sync token association.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-27 11:03:12 +00:00
Jason Volk 730920b571 Collect v5 typing events concurrent with other extensions.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-27 07:04:10 +00:00
Jason Volk 66334bdd53 Move syncv3 typings event for user.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-27 07:04:10 +00:00
Jason Volk 6b7bf80de5 Disable legacy media request fallbacks by default.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-27 07:04:09 +00:00
Jason Volk 4c35bfbda4 Fix M_UNKNOWN error which should be M_BAD_ALIAS.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-26 07:29:30 +00:00
Jason Volk ba51748ad3 Add missing upper-bounded calls; improve snake-sync windowing.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-26 05:52:30 +00:00
Jason Volk 63dfe8f7e3 Add upper-bound for presence_since().
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-26 05:36:19 +00:00
Jason Volk c6836e51b2 Add upper-bound to readreceipts_since() and callsites.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-26 04:44:09 +00:00
Jason Volk 33a9fce828 dedup room directory banned server check.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-26 02:26:09 +00:00
Jason Volk 267fd4de5b Enable additional complement parallel tests.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-25 22:52:29 +00:00
Jason Volk ce30f83052 Optimize sync watchers and key serializations.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-25 21:55:37 +00:00
Jason Volk e09a2c0e0f Window sync ranges below any partially completed writes.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-25 21:55:37 +00:00
Jason Volk 992abfab8f Separate cached body from request body in snake-sync; cleanup.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-25 21:55:37 +00:00
Jason Volk 51931de94c Add release-sequence for counter retirements.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-25 21:55:37 +00:00
Jason Volk 85a84f93c7 Fix misinterpretation of filter.room.include_leave in sync v3.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-25 21:55:37 +00:00
Jason Volk e58ef326d4 Refactor legacy database watcher system.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-25 20:07:21 +00:00
Jason Volk 0d439188e8 Fix sequence windowing for sync v3 invite/leave/knock rooms.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-25 20:07:21 +00:00
Jason Volk 22ef704ac6 Fix bug from roomuserid_knockedcount vs. roomid_knockedcount.
The use of "count" instead of "sequence" leads to confusion with
i.e. counting the elements of a set e.g. Iterator::count().

Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-25 20:07:21 +00:00
Jason Volk 7bdd4065c8 Split database::Map put/del from insert.rs and remove.rs
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-25 20:07:18 +00:00
Jason Volk 0fcb072239 Refactor counter increment sites for TwoPhaseCounter.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-25 10:32:52 +00:00
Jason Volk 05bb1f4ac7 Add TwoPhaseCounter to core utils.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-25 10:32:52 +00:00
Jason Volk 89e3a8c182 Add common editor temps to gitignore.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-25 10:32:52 +00:00
Jason Volk f0576f8d7d Remove unused deprecated sliding sync service code.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 23:13:01 +00:00
Jason Volk 11f77defc7 Handle AuthData::FallbackAcknowledgement; mute error for now.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 23:13:01 +00:00
Jason Volk 23c75855ba Split api/client/register from api/client/account suite.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 23:13:01 +00:00
Jason Volk 5253a8d36a Inline and apply must_use to remaining services globals wrappers.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 22:31:11 +00:00
Jason Volk c9adee86f5 Unify calculate_state_changes in syncv3
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 22:17:30 +00:00
Jason Volk 3c47516c85 Pipeline private read receipt fetch; cleanup tuples syncv3.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 22:17:30 +00:00
Jason Volk 299d3230a1 Optimize typing event collection.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 22:17:30 +00:00
Tyler MayoffandJade Ellis 9ea8fbc482 Add typing indicators to sync v5.
Co-authored-by: Jade Ellis <jade@ellis.link>
2025-07-24 22:17:30 +00:00
Jason Volk f7877d122b List #tuwunel:matrix.org; simplify readme.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:28 +00:00
Jason Volk 17119670c0 Add admin debug command to manually resync with primary. (#35)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:28 +00:00
Jason Volk 535fcab4b5 ci: Create multi-arch manifest for each release tag (fixes #103).
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:28 +00:00
Jason Volk cbe34affa3 Add unique id counter to request tracing span. (fixes #112)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:28 +00:00
Jason Volk ed0b3c764e Parallelize state_at_incoming sstatehash/prev_event fetches.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:28 +00:00
Jason Volk 190269f616 Simplify Pdu Hashes struct.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:28 +00:00
Jason Volk 3ea8c82ef0 Follow-up to admin channel change (7d2d42542c).
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:28 +00:00
Jason Volk 2a627baa96 Fix excessive nesting.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:27 +00:00
Jason Volk 50de6277b8 Split/cleanup backfill stream stanza.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:27 +00:00
Jason Volk 4429323e11 Flatten threads_until().
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:27 +00:00
Jason Volk 18f8d6c65c Rebox future segmentations.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:27 +00:00
Jason Volk aac49b09c7 Improve mutable state in sender closure captures.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:27 +00:00
Jason Volk c8d35cca57 Refactor to async closures.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:27 +00:00
Jason Volk cca0f20148 Replace several expects with error coercions.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:27 +00:00
Jason Volk 23d188f612 Spacing/formatting adjustments.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:27 +00:00
Jason Volk ae707ab465 Simplify default Result generics.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:27 +00:00
Jason Volk 8244d78cb2 Make Event trait Send+Sync.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:27 +00:00
Jason Volk b0315da3d7 Fix branches sharing code.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:27 +00:00
Jason Volk eca01cfb3f Fix useless if let seq.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:27 +00:00
Jason Volk cf13f5afc1 Allow clippy::map_unwrap_or.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:27 +00:00
Jason Volk c944f1124a Additional BoolExt utils.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:27 +00:00
Jason Volk 70fc95e800 Fix same generic used for separate closures in BoolExt.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:27 +00:00
Jason Volk 507bd1edc7 Update complement; mask new tests.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-24 04:07:27 +00:00
coolGi ee0e594aef Fixed nix cached shasum for rust-toolchain.toml 2025-07-21 21:05:36 -07:00
ObiomaAtWanagu fd080914c2 Enhanced docu for configuration
Include that more than one config file can be named.
Describe the relevance of ordering for setting the value.
2025-07-09 20:38:27 +00:00
dasha_uwu 9dd2b28605 Add base64 output for admin query command.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-08 23:49:18 +00:00
Jade Ellis 34abe1cce4 fix: Allow joining via invite for knock_restricted rooms 2025-07-08 23:38:18 +00:00
Tyler Mayoff a340e6786d use room names first and only fallback to heroes if not available 2025-07-07 07:36:51 +00:00
June Strawberry c37ee97351 allow nightly unstable_name_collisions lint due to BoolExt conflict
Signed-off-by: June Strawberry <june@basednetworking.com>
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-07 07:36:51 +00:00
Jason Volk 7d2d42542c Simplify admin channel type.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-07 07:09:49 +00:00
Jason Volk fd0082fd2c Add ready_try_skip_while() to stream utils.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-07 07:09:49 +00:00
Jason Volk ca8f3ae057 Add gitignores for -Zself-profile output.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-07 07:09:49 +00:00
Jason Volk 8a748e02df Fix into_recv_seek lifetime flow to match into_recv_get.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-07 07:09:49 +00:00
Jason Volk 79ee7838e7 Rename elided_named_lifetimes to mismatched_lifetime_syntaxes.
Reapply is_multiple_of().

Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-07 07:09:49 +00:00
Jason Volk e9a441fb6e Bump tokio to 1.46
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-07 02:44:18 +00:00
Jason Volk 93f5557232 Bump rust to 1.88.0
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-07 02:23:25 +00:00
Jason Volk 3d88767977 Bump 1.2.0
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-04 02:00:07 +00:00
Jason Volk b68cff3b2f Fix clippy::manual-is-multiple-of.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-04 01:49:57 +00:00
Jason Volk 36c3845ff6 Comment section headers in generated example config. (fixes #96)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-04 00:31:09 +00:00
Jason Volk 7f1c7b964e Add missing display/default attributes to appservice example config.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-04 00:13:30 +00:00
Jason Volk 1cbcd3fc88 Add Result traits map_ref()/and_then_ref().
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-03 22:18:44 +00:00
Jason Volk ad9ddd91cd Add broad_find_map() to stream utils.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-03 22:18:44 +00:00
Jason Volk a2b4c07cf7 Additional internal pdu getters.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-07-03 22:18:44 +00:00
orhtej2 2ead282bec Dedup entries returned by LDAP 2025-06-29 04:02:41 +00:00
Jason Volk 9496d05cd2 ci: Pass package build condition as workflow arg.
ci: Add defaults for init matrix; branch conditions for pulls.

Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-29 04:02:41 +00:00
Jason Volk c8ab1713c3 Fix errant ldap3 dependency in src/core.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-29 04:02:41 +00:00
orhtej2 84acdccb93 Other typo 2025-06-29 01:20:02 +02:00
orhtej2 6164f62395 Fix optional admin config 2025-06-29 01:16:51 +02:00
Jason Volk b36ad9cfef docker: use OCI media types for registry images. (fixes #79)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-26 01:01:56 +00:00
Jason Volk d557f0f456 README: soften warning to tip. [ci skip]
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-26 01:01:56 +00:00
Jason Volk d858c5c1f4 docker: Add Instruction Set Architectures to build matrix.
ci: Publish multi-arch images for both branch and tag refs.

Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-25 17:21:55 +00:00
Jason Volk 972201da60 Add warning when listening=false. (fixes #81)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-25 01:04:18 +00:00
Jason Volk 56d9c9a8b5 Handle empty std::env::args() for FreeBSD. (fixes #75)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-25 01:04:18 +00:00
Jason Volk 84ce3e0d0e Change default emoji due to inconsistent support. (closes #80)
Move config item to more prominent location.

Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-25 01:04:18 +00:00
Jason Volk 578cf9d2d7 Fix missing lz4 and bz2; tweak feature projection. (closes #78)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-25 01:04:18 +00:00
Jason Volk ca69af97c1 docker: Re-relax cargo cache expectations. (#53)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-24 23:45:08 +00:00
Jason Volk ac26193ffe Check appservice registrations for unique as_token. (#72)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-20 18:08:19 +00:00
Jason Volk a84e559640 Implement declarative appservices. (closes #67)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-20 18:08:19 +00:00
Jason Volk 2e559a0d3e docker: Use zstd for all compressions.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-20 13:51:35 +00:00
Jason Volk 2634fed2d4 Tweak readme wording.
Fix actual typo.

Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-20 13:04:02 +00:00
Jason Volk 31a3676cd8 ci: Publish multi-arch manifest. (fixes #74)
ci: Toggle package install checks via vars.

docker: Disable provenance attestations which auto-generate manifests.

Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-20 10:52:35 +00:00
Jason Volk aa1609d611 Fix RELEASE notes formatting for GH.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-20 01:21:07 +00:00
Jason Volk 8e13f07d2a ci: Fix distro package generation for tags.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-19 13:05:49 +00:00
Jason Volk ab6da09c02 Bump 1.1.0
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-19 09:03:17 +00:00
Jason Volk 18b9d7bc1f Add org.matrix.login.jwt support.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-18 11:53:25 +00:00
Jason Volk b5dc933880 Additional epoch time convenience utils.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-18 09:50:22 +00:00
Jason Volk f68038a826 Restrict password login to accounts of type 'password' or legacy untyped.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-18 09:50:22 +00:00
Jason Volk b3a47566ff Move and rename 'token' to 'access_token' where applicable.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-18 01:02:22 +00:00
Jason Volk 61cbd38284 Fix unrecognized prof_active jemalloc_conf on aarch64.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-18 01:02:22 +00:00
Jason Volk 6cc251796e ci: Remove unnecessary/unused condition.
docker: Fix readme typo; link.

Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-17 22:05:07 +00:00
Jason Volk 7e8c4c8883 Fix password reset regression. (78a02edbbf) (fixes #70)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-17 03:41:27 +00:00
Jason Volk 73c179b20a docker: Adjust rpm and deb packaging for multi-platform.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-17 03:41:27 +00:00
Jason Volk cd8648dce5 Auth related cleanups.
Cleanup; additional error macros.

Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-17 03:41:27 +00:00
Jason Volk 83ceda808c ci: Add multi-runner/multi-arch to matrices. (closes #55)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-17 03:41:27 +00:00
Jason Volk fc3fcf4526 docker: Determine nproc for darwin. (closes #52)
docker: Further separate apt and rust cache mounts.

Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-17 00:22:50 +00:00
Jason Volk f4e6807a3c Fix hard-coded well-known IP address.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-16 22:43:47 +00:00
Jason Volk 13e0113587 Fix nightly coerce-container-to-any.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-16 22:43:47 +00:00
Jason Volk 51778b9354 ci: Remove the deps workflow.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-16 04:25:58 +00:00
Jason Volk 8fef40a37e docker: Add assertion for dynamic or static executable upon install.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-16 04:25:58 +00:00
Jason Volk ee6524b803 docker: Fix erroneous sys_ variable names. (#52)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-16 04:25:53 +00:00
Jason Volk 1645518859 Add link to nixpkgs request. [ci skip]
docker: Add apt command for getting-started section. [ci skip]
2025-06-15 02:36:07 +00:00
Jason Volk 6088d0e295 Update nix flake. (closes #64)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-14 23:28:54 +00:00
Jason Volk 5a717266b8 Add new sentry endpoint. (closes #66)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-14 22:48:49 +00:00
Wojciech Kordalski f2c5314296 Fix building RocksDB on Nix 2025-06-14 22:48:49 +00:00
Jason Volk 814d3b903e Update NixOS related. [ci skip]
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-14 22:48:49 +00:00
Jason Volk a114ab3ab6 Fix use of inherent_str_constructors (#64 #65)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-14 22:18:21 +00:00
Jason Volk b01c5d5ef1 docker: Use specific msrv for stable toolchain.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-14 22:10:00 +00:00
Jason Volk 21c0e4176b Add security disclosure policy. [ci skip]
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-14 09:52:30 +00:00
Jason Volk f1f31eff17 Detailed version string. (closes #62)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-13 01:27:28 +00:00
Jason Volk b0b441d534 Add macro to get rustc version. (#62)
Add macro to query git-describe. (#62)

Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-13 01:27:28 +00:00
Jason Volk 5799059196 Abstract get_crate_name() into macro utils. 2025-06-12 21:31:44 +00:00
Jason Volk 026d756ef4 Adjust SmallVec buffer sizes to account for overhead.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-12 11:08:29 +00:00
Jason Volk 37afdb0e90 docker: Fix typo. [ci skip]
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-12 02:39:02 +00:00
Jason Volk 2a2486182a Split login case bodies into handlers.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-11 01:21:11 +00:00
Jason Volk 3056b60159 Bundle systemd service and post-install script for RPM package. (#59 #60)
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-11 01:21:11 +00:00
Jason Volk 000b876dcb Updates for Arch package related.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-11 00:50:49 +00:00
Jason Volk fcd51ef30e docker: Simplify target names for distro packages.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-11 00:50:49 +00:00
Jason Volk 7edbe11eb8 docker: Dedup cargo and chef dockerfiles.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-10 20:32:58 +00:00
Jason Volk 0f256d7191 Split api::client::session into units.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-08 20:02:53 +00:00
Jason Volk 72c231c613 Bump various additional dependencies.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-08 19:34:21 +00:00
Jason Volk 66b36563b6 docker: Reformat cargo build rustflags.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-08 09:22:43 +00:00
Jason Volk e6d782c701 Bump rocksdb.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-08 06:03:23 +00:00
Jason Volk f63cc84c98 Bump opentelemetry.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-08 03:39:24 +00:00
Jason Volk 83fe14c522 Bump core_affinity.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-08 03:08:57 +00:00
Jason Volk 46ce426b87 Bump rebased rustyline-async.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-08 03:08:57 +00:00
9a975c0304 chore: Migrate to axum 0.8
Co-authored-by: dasha_uwu
Co-authored-by: Jason Volk <jason@zemos.net>
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-08 03:08:57 +00:00
Jason Volk dc8bab9bcd Disable tokio-console for Axum dependency conflicts.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-08 03:08:57 +00:00
Jason Volk ceb0f8f933 Bump trivial dependencies; rebase hyper-util.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-08 03:08:57 +00:00
Jason Volk 53f2ea8e58 ci: Rename NEWS.md to RELEASE.md.
ci: Build fewer packages in non-main branch.

ci: Add lint phase for rust-check.

Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-08 03:08:57 +00:00
Jason Volk 8a83c23537 Split tuwunel_service::users into units.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-06 22:41:01 +00:00
Jason Volk b0048fec6d Add target platform to artifact names.
Use better gzip input name which is preserved by metadata.

Add chmod for input file and use for executables.

Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-06 19:27:18 +00:00
Jason Volk 9bad2fa1eb ci: Use fatter layer caching; make script output consistent.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-06 19:27:18 +00:00
Jason Volk 06f37e9e8a Use all-features for special-tag preview and latest images.
Signed-off-by: Jason Volk <jason@zemos.net>
2025-06-06 17:03:23 +00:00
252 changed files with 9287 additions and 6943 deletions

No files matched your search

+14 -6
View File
@@ -30,6 +30,10 @@ on:
machines:
type: string
description: Hardware platforms
runner:
type: string
description: Runner mask
default: 'self-hosted'
excludes:
type: string
default: '[]'
@@ -86,7 +90,7 @@ jobs:
${{matrix.sys_version}}
${{matrix.sys_target}}
runs-on: ${{matrix.machine}}
runs-on: ["${{matrix.machine}}", "${{inputs.runner}}"]
strategy:
fail-fast: ${{inputs.fail_fast}}
max-parallel: ${{inputs.max-parallel}}
@@ -141,12 +145,14 @@ jobs:
iid: ${{matrix.bake_target}}--${{matrix.cargo_profile}}--${{matrix.rust_toolchain}}--${{matrix.rust_target}}--${{matrix.feat_set}}--${{matrix.sys_name}}--${{matrix.sys_version}}--${{matrix.sys_target}}
dst: ${{ fromJSON(inputs.artifact)[matrix.bake_target].dst }}
src: ${{ fromJSON(inputs.artifact)[matrix.bake_target].src || fromJSON(inputs.artifact)[matrix.bake_target].dst }}
mod: ${{ fromJSON(inputs.artifact)[matrix.bake_target].chmod || 'u+r' }}
run: |
cid=$(docker create "$iid" /)
rm -rf _artifact
mkdir -p "_artifact"
docker cp "$cid:$src" "_artifact/$dst"
chmod "$mod" "_artifact/$dst"
# Optionally extract the image itself as an artifact.
- name: Extract Image Artifact
@@ -174,11 +180,13 @@ jobs:
env:
dst: ${{ fromJSON(inputs.artifact)[matrix.bake_target].dst }}
src: ${{ fromJSON(inputs.artifact)[matrix.bake_target].src || fromJSON(inputs.artifact)[matrix.bake_target].dst }}
mod: ${{ fromJSON(inputs.artifact)[matrix.bake_target].chmod || 'u+r' }}
run: |
rm -rf _artifact
mkdir -p "_artifact"
mv "$src" "_artifact/$dst"
chmod "$mod" "_artifact/$dst"
# Optionally compress extracted artifact
- name: Compress Artifact
@@ -194,9 +202,9 @@ jobs:
run: |
if test -n "$gzlev"; then
mv "_artifact/$dst" "_artifact/foo"
gzip "-$gzlev" "_artifact/foo"
mv "_artifact/foo.gz" "_artifact/$dst"
mv "_artifact/$dst" "_artifact/$dst.artifact"
gzip "-$gzlev" "_artifact/$dst.artifact"
mv "_artifact/$dst.artifact.gz" "_artifact/$dst"
elif test -n "$zstlev"; then
zstd "-$zstlev" "_artifact/$dst"
mv "_artifact/$dst.zst" "_artifact/$dst"
@@ -211,7 +219,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
path: _artifact/*
name: ${{matrix.cargo_profile}}-${{matrix.feat_set}}-${{fromJSON(inputs.artifact)[matrix.bake_target].dst}}
name: ${{matrix.cargo_profile}}-${{matrix.feat_set}}-${{matrix.sys_target}}-${{fromJSON(inputs.artifact)[matrix.bake_target].dst}}
# Optionally upload artifact as pages-artifact
- name: Upload Pages Artifact
@@ -240,5 +248,5 @@ jobs:
with:
upload_url: ${{inputs.release_url}}
asset_path: _artifact/${{fromJSON(inputs.artifact)[matrix.bake_target].dst}}
asset_name: ${{github.ref_name}}-${{matrix.cargo_profile}}-${{matrix.feat_set}}-${{fromJSON(inputs.artifact)[matrix.bake_target].dst}}
asset_name: ${{github.ref_name}}-${{matrix.cargo_profile}}-${{matrix.feat_set}}-${{matrix.sys_target}}-${{fromJSON(inputs.artifact)[matrix.bake_target].dst}}
asset_content_type: ${{fromJSON(inputs.artifact)[matrix.bake_target].mime || 'application/octet-stream'}}
-163
View File
@@ -1,163 +0,0 @@
name: Dependencies
on:
workflow_call:
inputs:
cargo_profiles:
type: string
description: Cargo profiles
feat_sets:
type: string
description: Cargo feature groups
rust_toolchains:
type: string
description: Rust toolchains
sys_names:
type: string
description: System names
sys_versions:
type: string
description: System versions
rust_targets:
type: string
description: Rust targets
sys_targets:
type: string
description: System targets
machines:
type: string
description: Hardware platform vector
excludes:
type: string
default: '[]'
description: Matrix exclusions
includes:
type: string
default: '[]'
description: Matrix inclusions
show_systems:
type: boolean
default: true
description: Pre-build systems dependency targets
show_sources:
type: boolean
default: true
description: Pre-build sources dependency targets
show_rocksdb:
type: boolean
default: true
description: Pre-build rocksdb dependency targets
show_cargo:
type: boolean
default: true
description: Pre-build cargo dependency targets
jobs:
systems:
if: >
!failure() && !cancelled()
&& inputs.show_systems
name: System
uses: ./.github/workflows/bake.yml
with:
bake_targets: '["systems"]'
cargo_profiles: ${{inputs.cargo_profiles}}
feat_sets: ${{inputs.feat_sets}}
rust_toolchains: ${{inputs.rust_toolchains}}
sys_names: ${{inputs.sys_names}}
sys_versions: ${{inputs.sys_versions}}
rust_targets: ${{inputs.rust_targets}}
sys_targets: ${{inputs.sys_targets}}
machines: ${{inputs.machines}}
excludes: ${{inputs.excludes}}
includes: ${{inputs.includes}}
buildsys:
if: >
!failure() && !cancelled()
&& inputs.show_systems
name: Builder
needs: [systems]
uses: ./.github/workflows/bake.yml
with:
bake_targets: '["rust"]'
cargo_profiles: ${{inputs.cargo_profiles}}
feat_sets: ${{inputs.feat_sets}}
rust_toolchains: ${{inputs.rust_toolchains}}
sys_names: ${{inputs.sys_names}}
sys_versions: ${{inputs.sys_versions}}
rust_targets: ${{inputs.rust_targets}}
sys_targets: ${{inputs.sys_targets}}
machines: ${{inputs.machines}}
excludes: ${{inputs.excludes}}
includes: ${{inputs.includes}}
sources:
if: >
!failure() && !cancelled()
&& inputs.show_sources
name: Acquire
needs: [buildsys]
uses: ./.github/workflows/bake.yml
with:
bake_targets: '["sources"]'
cargo_profiles: ${{inputs.cargo_profiles}}
feat_sets: ${{inputs.feat_sets}}
rust_toolchains: ${{inputs.rust_toolchains}}
sys_names: ${{inputs.sys_names}}
sys_versions: ${{inputs.sys_versions}}
rust_targets: ${{inputs.rust_targets}}
sys_targets: ${{inputs.sys_targets}}
machines: ${{inputs.machines}}
excludes: ${{inputs.excludes}}
includes: ${{inputs.includes}}
rocksdb:
if: >
!failure() && !cancelled()
&& inputs.show_rocksdb
name: RocksDB
needs: [sources]
uses: ./.github/workflows/bake.yml
with:
bake_targets: '["rocksdb"]'
cargo_profiles: ${{inputs.cargo_profiles}}
feat_sets: ${{inputs.feat_sets}}
rust_toolchains: ${{inputs.rust_toolchains}}
sys_names: ${{inputs.sys_names}}
sys_versions: ${{inputs.sys_versions}}
rust_targets: ${{inputs.rust_targets}}
sys_targets: ${{inputs.sys_targets}}
machines: ${{inputs.machines}}
excludes: ${{inputs.excludes}}
includes: ${{inputs.includes}}
deps:
if: >
!failure() && !cancelled()
&& inputs.show_cargo
name: Build
needs: [rocksdb]
uses: ./.github/workflows/bake.yml
with:
bake_targets: >
[
"deps-clippy",
"deps-build-tests",
"deps-build-bins"
]
cargo_profiles: ${{inputs.cargo_profiles}}
feat_sets: ${{inputs.feat_sets}}
rust_toolchains: ${{inputs.rust_toolchains}}
sys_names: ${{inputs.sys_names}}
sys_versions: ${{inputs.sys_versions}}
rust_targets: ${{inputs.rust_targets}}
sys_targets: ${{inputs.sys_targets}}
machines: ${{inputs.machines}}
excludes: ${{inputs.excludes}}
includes: ${{inputs.includes}}
+31 -4
View File
@@ -43,6 +43,7 @@ jobs:
&& contains(fromJSON(inputs.cargo_profiles), fromJSON('["test"]')[0])
&& contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0])
&& contains(fromJSON(inputs.rust_toolchains), fromJSON('["nightly"]')[0])
&& contains(fromJSON(inputs.sys_targets), fromJSON('["x86_64-v1-linux-gnu"]')[0])
name: Format
uses: ./.github/workflows/bake.yml
@@ -53,8 +54,8 @@ jobs:
rust_toolchains: '["nightly"]'
rust_targets: ${{inputs.rust_targets}}
sys_names: ${{inputs.sys_names}}
sys_targets: ${{inputs.sys_targets}}
sys_versions: ${{inputs.sys_versions}}
sys_targets: '["x86_64-v1-linux-gnu"]'
machines: ${{inputs.machines}}
excludes: ${{inputs.excludes}}
includes: ${{inputs.includes}}
@@ -65,6 +66,7 @@ jobs:
&& contains(fromJSON(inputs.cargo_profiles), fromJSON('["test"]')[0])
&& contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0])
&& contains(fromJSON(inputs.rust_toolchains), fromJSON('["nightly"]')[0])
&& contains(fromJSON(inputs.sys_targets), fromJSON('["x86_64-v1-linux-gnu"]')[0])
name: Typos
uses: ./.github/workflows/bake.yml
@@ -76,7 +78,7 @@ jobs:
sys_names: ${{inputs.sys_names}}
sys_versions: ${{inputs.sys_versions}}
rust_targets: ${{inputs.rust_targets}}
sys_targets: ${{inputs.sys_targets}}
sys_targets: '["x86_64-v1-linux-gnu"]'
machines: ${{inputs.machines}}
excludes: ${{inputs.excludes}}
includes: ${{inputs.includes}}
@@ -87,6 +89,7 @@ jobs:
&& contains(fromJSON(inputs.cargo_profiles), fromJSON('["test"]')[0])
&& contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0])
&& contains(fromJSON(inputs.rust_toolchains), fromJSON('["nightly"]')[0])
&& contains(fromJSON(inputs.sys_targets), fromJSON('["x86_64-v1-linux-gnu"]')[0])
name: Audit
uses: ./.github/workflows/bake.yml
@@ -98,7 +101,7 @@ jobs:
sys_names: ${{inputs.sys_names}}
sys_versions: ${{inputs.sys_versions}}
rust_targets: ${{inputs.rust_targets}}
sys_targets: ${{inputs.sys_targets}}
sys_targets: '["x86_64-v1-linux-gnu"]'
machines: ${{inputs.machines}}
excludes: ${{inputs.excludes}}
includes: ${{inputs.includes}}
@@ -109,6 +112,7 @@ jobs:
&& contains(fromJSON(inputs.cargo_profiles), fromJSON('["test"]')[0])
&& contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0])
&& contains(fromJSON(inputs.rust_toolchains), fromJSON('["nightly"]')[0])
&& contains(fromJSON(inputs.sys_targets), fromJSON('["x86_64-v1-linux-gnu"]')[0])
name: Lychee
uses: ./.github/workflows/bake.yml
@@ -120,7 +124,30 @@ jobs:
sys_names: ${{inputs.sys_names}}
sys_versions: ${{inputs.sys_versions}}
rust_targets: ${{inputs.rust_targets}}
sys_targets: ${{inputs.sys_targets}}
sys_targets: '["x86_64-v1-linux-gnu"]'
machines: ${{inputs.machines}}
excludes: ${{inputs.excludes}}
includes: ${{inputs.includes}}
check:
if: >
!failure() && !cancelled()
&& contains(fromJSON(inputs.cargo_profiles), fromJSON('["test"]')[0])
&& contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0])
&& contains(fromJSON(inputs.rust_toolchains), fromJSON('["nightly"]')[0])
&& contains(fromJSON(inputs.sys_targets), fromJSON('["x86_64-v1-linux-gnu"]')[0])
name: Check
uses: ./.github/workflows/bake.yml
with:
bake_targets: '["check"]'
cargo_profiles: '["test"]'
feat_sets: '["all"]'
rust_toolchains: '["nightly"]'
sys_names: ${{inputs.sys_names}}
sys_versions: ${{inputs.sys_versions}}
rust_targets: ${{inputs.rust_targets}}
sys_targets: '["x86_64-v1-linux-gnu"]'
machines: ${{inputs.machines}}
excludes: ${{inputs.excludes}}
includes: ${{inputs.includes}}
+114 -46
View File
@@ -18,7 +18,7 @@ concurrency:
jobs:
init:
name: Init
runs-on: self-hosted
runs-on: ${{matrix.runner}}
env:
default_cargo_profiles: '["test", "release"]'
default_feat_sets: '["none", "default", "all"]'
@@ -26,8 +26,8 @@ jobs:
default_sys_names: '["debian"]'
default_sys_versions: '["testing-slim"]'
default_rust_targets: '["x86_64-unknown-linux-gnu"]'
default_sys_targets: '["x86_64-linux-gnu"]'
default_machines: '["x86_64"]'
default_sys_targets: '["x86_64-v1-linux-gnu"]'
default_machines: '["X64"]'
outputs:
cargo_profiles: ${{vars.CARGO_PROFILES || env.default_cargo_profiles}}
@@ -38,10 +38,28 @@ jobs:
sys_targets: ${{vars.SYS_TARGETS || env.default_sys_targets}}
sys_versions: ${{vars.SYS_VERSIONS || env.default_sys_versions}}
machines: ${{vars.MACHINES || env.default_machines}}
package: ${{vars.PACKAGE || !contains(github.ref, 'refs/pull/')}}
publish: ${{vars.PUBLISH || !contains(github.ref, 'refs/pull/')}}
build_pkgs: ${{vars.BUILD_PKGS || github.ref == 'refs/heads/main' || contains(github.ref, 'tags/v')}}
check_pkgs: ${{vars.CHECK_PKGS || 'false'}}
complement: ${{vars.COMPLEMENT || 'true'}}
complement_runner: 'het'
docker_repo: ${{vars.DOCKER_REPO}}
release_url: ${{steps.release.outputs.upload_url}}
strategy:
fail-fast: true
matrix:
runner: ${{fromJSON(vars.RUNNERS || '["het"]')}}
machine: ${{fromJSON(vars.MACHINES || '["X64"]')}}
exclude: ${{fromJSON(vars.RUNNERS_EXCLUDES || '[]')}}
steps:
- name: Initialize Builder
env:
runner: ${{matrix.runner}}
reserved_space: '{"het": "384GB", "aws": "48GB", "gcp": "160GB"}'
max_used_space: '{"het": "512GB", "aws": "64GB", "gcp": "192GB"}'
run: |
set +e
docker buildx inspect "${GITHUB_ACTOR}"
@@ -49,7 +67,9 @@ jobs:
exit 0
fi
set -e
set -eux
reserved_space=$(echo -n "$reserved_space" | jq -r ".$runner")
max_used_space=$(echo -n "$max_used_space" | jq -r ".$runner")
cat <<EOF > ./buildkitd.toml
[system]
platformsCacheMaxAge = "504h"
@@ -57,11 +77,11 @@ jobs:
enabled = true
rootless = false
gc = true
reservedSpace = "256GB"
maxUsedSpace = "576GB"
reservedSpace = "${reserved_space}"
maxUsedSpace = "${max_used_space}"
[[worker.oci.gcpolicy]]
reservedSpace = "256GB"
maxUsedSpace = "576GB"
reservedSpace = "${reserved_space}"
maxUsedSpace = "${max_used_space}"
filters = ["label!=cache==pin"]
all = true
EOF
@@ -76,6 +96,7 @@ jobs:
- if: >
!failure() && !cancelled()
&& contains(github.ref, 'refs/tags/v')
&& matrix.runner == 'het'
id: release
name: Create Release
@@ -85,32 +106,10 @@ jobs:
with:
release_name: Release ${{github.ref_name}}
tag_name: ${{github.ref}}
body_path: NEWS.md
body_path: RELEASE.md
draft: ${{ contains(github.ref, '-draft') }}
prerelease: ${{ contains(github.ref, '-rc') }}
## commented due to https://github.com/orgs/community/discussions/18001
#deps:
# if: ${{fromJSON(vars.CI_VERBOSE_DEPS || 'false')}}
# name: Deps
# needs: [init]
# uses: ./.github/workflows/deps.yml
# with:
# cargo_profiles: ${{needs.init.outputs.cargo_profiles}}
# feat_sets: ${{needs.init.outputs.feat_sets}}
# rust_toolchains: ${{needs.init.outputs.rust_toolchains}}
# rust_targets: ${{needs.init.outputs.rust_targets}}
# sys_names: ${{needs.init.outputs.sys_names}}
# sys_targets: ${{needs.init.outputs.sys_targets}}
# sys_versions: ${{needs.init.outputs.sys_versions}}
# machines: ${{needs.init.outputs.machines}}
# excludes: >
# [
# {"cargo_profile": "release-debuginfo", "rust_toolchain": "nightly"},
# {"cargo_profile": "release-native", "rust_toolchain": "stable"},
# {"cargo_profile": "release-native", "feat_set": "none"}
# ]
lint:
if: >
!failure() && !cancelled()
@@ -130,13 +129,28 @@ jobs:
machines: ${{needs.init.outputs.machines}}
excludes: >
[
{"cargo_profile": "test", "rust_toolchain": "stable", "feat_set": "none"},
{"cargo_profile": "test", "rust_target": "aarch64-unknown-linux-gnu"},
{"cargo_profile": "release", "rust_toolchain": "nightly", "feat_set": "none"},
{"cargo_profile": "release", "rust_toolchain": "nightly", "feat_set": "default"},
{"cargo_profile": "release-debuginfo"},
{"cargo_profile": "release-native", "rust_toolchain": "stable"},
{"cargo_profile": "release-native", "feat_set": "none"},
{"cargo_profile": "release-native", "feat_set": "default"},
{"cargo_profile": "test", "rust_toolchain": "stable", "feat_set": "none"},
{"cargo_profile": "release", "rust_toolchain": "nightly", "feat_set": "none"},
{"cargo_profile": "release", "rust_toolchain": "nightly", "feat_set": "default"}
{"cargo_profile": "release-native", "rust_target": "aarch64-unknown-linux-gnu"},
{"rust_target": "aarch64-unknown-linux-gnu", "feat_set": "none"},
{"rust_target": "aarch64-unknown-linux-gnu", "feat_set": "default"},
{"rust_target": "aarch64-unknown-linux-gnu", "rust_toolchain": "nightly"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v1-linux-gnu"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v2-linux-gnu"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v3-linux-gnu"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v4-linux-gnu"},
{"rust_target": "x86_64-unknown-linux-gnu", "sys_target": "aarch64-v8-linux-gnu"},
{"sys_target": "aarch64-v8-linux-gnu", "machine": "X64"},
{"sys_target": "x86_64-v1-linux-gnu", "machine": "ARM64"},
{"sys_target": "x86_64-v2-linux-gnu"},
{"sys_target": "x86_64-v3-linux-gnu"},
{"sys_target": "x86_64-v4-linux-gnu"},
]
test:
@@ -148,7 +162,8 @@ jobs:
needs: [init, lint]
uses: ./.github/workflows/test.yml
with:
complement: ${{fromJSON(vars.COMPLEMENT || 'true')}}
complement: ${{fromJSON(needs.init.outputs.complement)}}
complement_runner: ${{needs.init.outputs.complement_runner}}
cargo_profiles: ${{needs.init.outputs.cargo_profiles}}
feat_sets: ${{needs.init.outputs.feat_sets}}
rust_toolchains: ${{needs.init.outputs.rust_toolchains}}
@@ -160,21 +175,45 @@ jobs:
excludes: >
[
{"cargo_profile": "test", "rust_toolchain": "stable", "feat_set": "none"},
{"cargo_profile": "test", "rust_target": "aarch64-unknown-linux-gnu"},
{"cargo_profile": "release-debuginfo"},
{"cargo_profile": "release-native", "rust_toolchain": "stable"},
{"cargo_profile": "release-native", "feat_set": "default"},
{"cargo_profile": "release-native", "feat_set": "none"},
{"cargo_profile": "release-debuginfo"}
{"cargo_profile": "release-native", "rust_target": "aarch64-unknown-linux-gnu"},
{"rust_target": "aarch64-unknown-linux-gnu", "feat_set": "none"},
{"rust_target": "aarch64-unknown-linux-gnu", "feat_set": "default"},
{"rust_target": "aarch64-unknown-linux-gnu", "rust_toolchain": "nightly"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v1-linux-gnu"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v2-linux-gnu"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v3-linux-gnu"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v4-linux-gnu"},
{"rust_target": "x86_64-unknown-linux-gnu", "sys_target": "aarch64-v8-linux-gnu"},
{"sys_target": "aarch64-v8-linux-gnu", "machine": "X64"},
{"sys_target": "x86_64-v1-linux-gnu", "machine": "ARM64"},
{"sys_target": "x86_64-v2-linux-gnu", "machine": "ARM64"},
{"sys_target": "x86_64-v2-linux-gnu", "feat_set": "none"},
{"sys_target": "x86_64-v2-linux-gnu", "feat_set": "default"},
{"sys_target": "x86_64-v3-linux-gnu", "machine": "ARM64"},
{"sys_target": "x86_64-v3-linux-gnu", "feat_set": "none"},
{"sys_target": "x86_64-v3-linux-gnu", "feat_set": "default"},
{"sys_target": "x86_64-v4-linux-gnu", "machine": "ARM64"},
{"sys_target": "x86_64-v4-linux-gnu", "feat_set": "none"},
{"sys_target": "x86_64-v4-linux-gnu", "feat_set": "default"},
]
package:
if: >
!failure() && !cancelled()
&& needs.init.outputs.package
name: Package
needs: [init, lint]
uses: ./.github/workflows/package.yml
with:
release_url: ${{needs.init.outputs.release_url}}
check_pkgs: ${{needs.init.outputs.check_pkgs}}
build_pkgs: ${{needs.init.outputs.build_pkgs}}
cargo_profiles: ${{needs.init.outputs.cargo_profiles}}
feat_sets: ${{needs.init.outputs.feat_sets}}
rust_toolchains: ${{needs.init.outputs.rust_toolchains}}
@@ -187,26 +226,41 @@ jobs:
[
{"feat_set": "none"},
{"cargo_profile": "test"},
{"cargo_profile": "release-native"},
{"cargo_profile": "release-debuginfo", "feat_set": "default"},
{"cargo_profile": "release-debuginfo", "rust_toolchain": "nightly"},
{"cargo_profile": "release-debuginfo", "bake_target": "oci"},
{"cargo_profile": "release-native", "feat_set": "default"},
{"cargo_profile": "release-native", "rust_toolchain": "stable"},
{"cargo_profile": "release-native", "feat_set": "default"},
{"cargo_profile": "release-native", "bake_target": "docker"},
{"cargo_profile": "release-native", "bake_target": "oci"},
{"cargo_profile": "release", "rust_toolchain": "nightly"}
{"cargo_profile": "release-debuginfo", "rust_target": "aarch64-unknown-linux-gnu"},
{"cargo_profile": "release-debuginfo", "sys_target": "x86_64-v2-linux-gnu"},
{"cargo_profile": "release-debuginfo", "sys_target": "x86_64-v3-linux-gnu"},
{"cargo_profile": "release-debuginfo", "sys_target": "x86_64-v4-linux-gnu"},
{"cargo_profile": "release", "rust_toolchain": "nightly"},
{"rust_target": "aarch64-unknown-linux-gnu", "feat_set": "default"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v1-linux-gnu"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v2-linux-gnu"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v3-linux-gnu"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v4-linux-gnu"},
{"rust_target": "x86_64-unknown-linux-gnu", "sys_target": "aarch64-v8-linux-gnu"},
{"sys_target": "aarch64-v8-linux-gnu", "machine": "X64"},
{"sys_target": "x86_64-v1-linux-gnu", "machine": "ARM64"},
{"sys_target": "x86_64-v2-linux-gnu", "machine": "ARM64"},
{"sys_target": "x86_64-v2-linux-gnu", "feat_set": "default"},
{"sys_target": "x86_64-v3-linux-gnu", "machine": "ARM64"},
{"sys_target": "x86_64-v3-linux-gnu", "feat_set": "default"},
{"sys_target": "x86_64-v4-linux-gnu", "machine": "ARM64"},
{"sys_target": "x86_64-v4-linux-gnu", "feat_set": "default"},
]
publish:
if: >
!failure() && !cancelled()
&& needs.init.outputs.publish
name: Publish
needs: [init, package, test]
needs: [init, test, package]
uses: ./.github/workflows/publish.yml
with:
docker_repo: ${{vars.DOCKER_REPO}}
docker_repo: ${{needs.init.outputs.docker_repo}}
release_url: ${{needs.init.outputs.release_url}}
cargo_profiles: ${{needs.init.outputs.cargo_profiles}}
feat_sets: ${{needs.init.outputs.feat_sets}}
@@ -220,9 +274,23 @@ jobs:
[
{"feat_set": "none"},
{"cargo_profile": "test"},
{"rust_toolchain": "nightly", "cargo_profile": "release"},
{"cargo_profile": "release-debuginfo"},
{"cargo_profile": "release-native"}
{"cargo_profile": "release-native"},
{"cargo_profile": "release", "rust_toolchain": "nightly"},
{"rust_target": "aarch64-unknown-linux-gnu", "feat_set": "default"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v1-linux-gnu"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v2-linux-gnu"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v3-linux-gnu"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v4-linux-gnu"},
{"rust_target": "x86_64-unknown-linux-gnu", "sys_target": "aarch64-v8-linux-gnu"},
{"sys_target": "aarch64-v8-linux-gnu", "machine": "X64"},
{"sys_target": "x86_64-v1-linux-gnu", "machine": "ARM64"},
{"sys_target": "x86_64-v2-linux-gnu", "machine": "ARM64"},
{"sys_target": "x86_64-v2-linux-gnu", "feat_set": "default"},
{"sys_target": "x86_64-v3-linux-gnu", "machine": "ARM64"},
{"sys_target": "x86_64-v3-linux-gnu", "feat_set": "default"},
{"sys_target": "x86_64-v4-linux-gnu", "machine": "ARM64"},
{"sys_target": "x86_64-v4-linux-gnu", "feat_set": "default"},
]
secrets:
+17 -9
View File
@@ -38,6 +38,12 @@ on:
release_url:
type: string
description: For release assets
build_pkgs:
type: string
default: 'true'
check_pkgs:
type: string
default: 'false'
jobs:
book:
@@ -46,6 +52,7 @@ jobs:
&& contains(fromJSON(inputs.cargo_profiles), fromJSON('["release"]')[0])
&& contains(fromJSON(inputs.feat_sets), fromJSON('["default"]')[0])
&& contains(fromJSON(inputs.rust_toolchains), fromJSON('["stable"]')[0])
&& contains(fromJSON(inputs.sys_targets), fromJSON('["x86_64-v1-linux-gnu"]')[0])
name: Book
uses: ./.github/workflows/bake.yml
@@ -56,9 +63,10 @@ jobs:
rust_toolchains: '["stable"]'
rust_targets: ${{inputs.rust_targets}}
sys_names: ${{inputs.sys_names}}
sys_targets: ${{inputs.sys_targets}}
sys_versions: ${{inputs.sys_versions}}
sys_targets: '["x86_64-v1-linux-gnu"]'
machines: ${{inputs.machines}}
runner: 'het'
excludes: ${{inputs.excludes}}
includes: ${{inputs.includes}}
release_url: ${{inputs.release_url}}
@@ -96,7 +104,8 @@ jobs:
"dst": "tuwunel.zst",
"src": "/usr/bin/tuwunel",
"mime": "application/zstd",
"zstd": 11
"zstd": 11,
"chmod": "a+x"
}
}
@@ -141,11 +150,12 @@ jobs:
&& contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0])
&& contains(fromJSON(inputs.cargo_profiles), fromJSON('["release"]')[0])
&& contains(fromJSON(inputs.rust_toolchains), fromJSON('["stable"]')[0])
&& fromJSON(inputs.build_pkgs)
name: Distro Packages
uses: ./.github/workflows/bake.yml
with:
bake_targets: '["pkg-deb", "pkg-rpm"]'
bake_targets: '["deb", "rpm"]'
cargo_profiles: '["release"]'
feat_sets: '["all"]'
rust_toolchains: '["stable"]'
@@ -159,14 +169,12 @@ jobs:
release_url: ${{inputs.release_url}}
artifact: >
{
"pkg-deb": {
"deb": {
"dst": "tuwunel.deb",
"src": "tuwunel_1.0.0-1_amd64.deb",
"mime": "application/vnd.debian.binary-package"
},
"pkg-rpm": {
"rpm": {
"dst": "tuwunel.rpm",
"src": "tuwunel-1.0.0-1.x86_64.rpm",
"mime": "application/x-rpm"
}
}
@@ -177,13 +185,13 @@ jobs:
&& contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0])
&& contains(fromJSON(inputs.cargo_profiles), fromJSON('["release"]')[0])
&& contains(fromJSON(inputs.rust_toolchains), fromJSON('["stable"]')[0])
&& false
&& fromJSON(inputs.check_pkgs)
name: Check Packages
needs: [pkgs]
uses: ./.github/workflows/bake.yml
with:
bake_targets: '["pkg-deb-install", "pkg-rpm-install"]'
bake_targets: '["deb-install", "rpm-install"]'
cargo_profiles: '["release"]'
feat_sets: '["all"]'
rust_toolchains: '["stable"]'
+201 -7
View File
@@ -49,12 +49,12 @@ jobs:
documents:
if: >
!failure() && !cancelled()
&& inputs.machines
&& contains(fromJSON(inputs.sys_targets), fromJSON('["X64"]')[0])
&& (github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags/v'))
&& !contains(github.ref, '-draft')
name: Documents
runs-on: self-hosted
runs-on: ['X64', 'het']
permissions:
pages: write
id-token: write
@@ -70,16 +70,14 @@ jobs:
&& inputs.machines
&& inputs.docker_repo != ''
&& (github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags/v'))
&& !contains(github.ref, '-draft')
name: Containers
runs-on: ${{matrix.machine}}
permissions: write-all
continue-on-error: false
strategy:
fail-fast: true
matrix:
bake_target: ${{fromJSON('["github", "dockerhub"]')}}
bake_target: ${{fromJSON('["docker_io", "ghcr_io"]')}}
cargo_profile: ${{fromJSON(inputs.cargo_profiles)}}
rust_toolchain: ${{fromJSON(inputs.rust_toolchains)}}
feat_set: ${{fromJSON(inputs.feat_sets)}}
@@ -92,6 +90,10 @@ jobs:
include: ${{fromJSON(inputs.includes)}}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: GitHub Login
uses: docker/login-action@v3
with:
@@ -120,8 +122,200 @@ jobs:
acct: ${{github.actor}}
repo: ${{github.repository}}
docker_repo: ${{inputs.docker_repo}}
docker_tag_preview: ${{ contains(github.ref, 'refs/tags/v') }}
docker_tag_latest: ${{ contains(github.ref, 'refs/tags/v') && !contains(github.ref, '-rc') }}
run: |
docker/bake.sh "${{matrix.bake_target}}"
bundles:
if: >
!failure() && !cancelled()
&& inputs.machines
&& inputs.docker_repo != ''
&& contains(fromJSON(inputs.cargo_profiles), fromJSON('["release"]')[0])
&& contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0])
&& contains(fromJSON(inputs.rust_toolchains), fromJSON('["stable"]')[0])
&& (github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags/v'))
name: Bundles
needs: [containers]
runs-on: 'het'
permissions: write-all
strategy:
fail-fast: true
matrix:
bake_target: ${{fromJSON('["docker_io", "ghcr_io"]')}}
cargo_profile: ${{fromJSON('["release"]')}}
feat_set: ${{fromJSON('["all"]')}}
rust_toolchain: ${{fromJSON('["stable"]')}}
sys_name: ${{fromJSON(inputs.sys_names)}}
sys_version: ${{fromJSON(inputs.sys_versions)}}
rust_target: ${{fromJSON(inputs.rust_targets)}}
sys_target: ${{fromJSON(inputs.sys_targets)}}
machine: ${{fromJSON(inputs.machines)}}
exclude: ${{fromJSON(inputs.excludes)}}
include: ${{fromJSON(inputs.includes)}}
steps:
- name: GitHub Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.ghcr_token }}
- name: DockerHub Login
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ github.actor }}
password: ${{ secrets.dockerhub_token }}
- name: Release Branch
if: >
!failure() && !cancelled()
&& (github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags/v'))
env:
acct: ${{github.actor}}
ghcr_repo: ${{github.repository}}
docker_repo: ${{inputs.docker_repo}}
registry: ${{matrix.bake_target}}
cargo_profile: ${{matrix.cargo_profile}}
feat_set: ${{matrix.feat_set}}
sys_target: ${{matrix.sys_target}}
ref_name: ${{github.ref_name}}
run: |
registry="$(echo -n $registry | sed s/_/./)"
if test "$registry" = "ghcr.io"; then
repo="$ghcr_repo"
else
repo="$docker_repo"
fi
docker manifest create "${registry}/${repo}:${ref_name}" \
--amend "${registry}/${repo}:${ref_name}-${cargo_profile}-${feat_set}-${sys_target}"
- name: Release Preview
if: >
!failure() && !cancelled()
&& contains(github.ref, 'refs/tags/v')
&& !contains(github.ref, '-draft')
env:
acct: ${{github.actor}}
ghcr_repo: ${{github.repository}}
docker_repo: ${{inputs.docker_repo}}
registry: ${{matrix.bake_target}}
cargo_profile: ${{matrix.cargo_profile}}
feat_set: ${{matrix.feat_set}}
sys_target: ${{matrix.sys_target}}
ref_name: ${{github.ref_name}}
run: |
registry="$(echo -n $registry | sed s/_/./)"
if test "$registry" = "ghcr.io"; then
repo="$ghcr_repo"
else
repo="$docker_repo"
fi
docker manifest create "${registry}/${repo}:preview" \
--amend "${registry}/${repo}:${ref_name}-${cargo_profile}-${feat_set}-${sys_target}"
- name: Release Latest
if: >
!failure() && !cancelled()
&& contains(github.ref, 'refs/tags/v')
&& !contains(github.ref, '-draft')
&& !contains(github.ref, '-rc')
env:
acct: ${{github.actor}}
ghcr_repo: ${{github.repository}}
docker_repo: ${{inputs.docker_repo}}
registry: ${{matrix.bake_target}}
cargo_profile: ${{matrix.cargo_profile}}
feat_set: ${{matrix.feat_set}}
sys_target: ${{matrix.sys_target}}
ref_name: ${{github.ref_name}}
run: |
registry="$(echo -n $registry | sed s/_/./)"
if test "$registry" = "ghcr.io"; then
repo="$ghcr_repo"
else
repo="$docker_repo"
fi
docker manifest create "${registry}/${repo}:latest" \
--amend "${registry}/${repo}:${ref_name}-${cargo_profile}-${feat_set}-${sys_target}"
delivery:
if: >
!failure() && !cancelled()
&& inputs.machines
&& inputs.docker_repo != ''
&& (github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags/v'))
name: Delivery
needs: [bundles, documents]
runs-on: 'het'
permissions: write-all
steps:
- name: GitHub Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.ghcr_token }}
- name: DockerHub Login
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ github.actor }}
password: ${{ secrets.dockerhub_token }}
- name: Push Branch
if: >
!failure() && !cancelled()
&& (github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags/v'))
env:
ref_name: ${{github.ref_name}}
ghcr_repo: ${{github.repository}}
docker_repo: ${{inputs.docker_repo}}
run: |
docker manifest push -p "ghcr.io/${ghcr_repo}:${ref_name}"
docker manifest push -p "docker.io/${docker_repo}:${ref_name}"
- name: Push Preview
if: >
!failure() && !cancelled()
&& contains(github.ref, 'refs/tags/v')
&& !contains(github.ref, '-draft')
env:
ghcr_repo: ${{github.repository}}
docker_repo: ${{inputs.docker_repo}}
run: |
docker manifest push -p "ghcr.io/${ghcr_repo}:preview"
docker manifest push -p "docker.io/${docker_repo}:preview"
- name: Push Latest
if: >
!failure() && !cancelled()
&& contains(github.ref, 'refs/tags/v')
&& !contains(github.ref, '-draft')
&& !contains(github.ref, '-rc')
env:
ghcr_repo: ${{github.repository}}
docker_repo: ${{inputs.docker_repo}}
run: |
docker manifest push -p "ghcr.io/${ghcr_repo}:latest"
docker manifest push -p "docker.io/${docker_repo}:latest"
+64 -13
View File
@@ -41,6 +41,8 @@ on:
complement_feat_sets:
type: string
default: '["all"]'
complement_runner:
type: string
jobs:
unit:
@@ -48,6 +50,7 @@ jobs:
contains(fromJSON(inputs.cargo_profiles), fromJSON('["test"]')[0])
&& contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0])
&& contains(fromJSON(inputs.rust_toolchains), fromJSON('["nightly"]')[0])
&& contains(fromJSON(inputs.sys_targets), fromJSON('["x86_64-v1-linux-gnu"]')[0])
name: Unit
uses: ./.github/workflows/bake.yml
@@ -59,13 +62,17 @@ jobs:
sys_names: ${{inputs.sys_names}}
sys_versions: ${{inputs.sys_versions}}
rust_targets: ${{inputs.rust_targets}}
sys_targets: ${{inputs.sys_targets}}
sys_targets: '["x86_64-v1-linux-gnu"]'
machines: ${{inputs.machines}}
excludes: ${{inputs.excludes}}
includes: ${{inputs.includes}}
smoke:
if: inputs.cargo_profiles
if: >
!failure() && !cancelled()
&& inputs.cargo_profiles
&& inputs.machines
name: Smoke
uses: ./.github/workflows/bake.yml
with:
@@ -82,26 +89,55 @@ jobs:
excludes: >
[
{"cargo_profile": "test", "feat_set": "default"},
{"cargo_profile": "test", "rust_toolchain": "stable"},
{"cargo_profile": "test", "feat_set": "none", "bake_target": "smoke-valgrind"},
{"cargo_profile": "test", "rust_toolchain": "stable"},
{"cargo_profile": "test", "rust_target": "aarch64-unknown-linux-gnu"},
{"cargo_profile": "test", "sys_target": "x86_64-v2-linux-gnu", "bake_target": "smoke-valgrind"},
{"cargo_profile": "release", "rust_toolchain": "nightly"},
{"cargo_profile": "release", "rust_toolchain": "stable", "feat_set": "none"},
{"cargo_profile": "release", "bake_target": "smoke-valgrind"},
{"cargo_profile": "release-debuginfo", "rust_toolchain": "nightly"},
{"cargo_profile": "release-debuginfo", "rust_toolchain": "stable", "feat_set": "none"},
{"cargo_profile": "release-debuginfo", "bake_target": "smoke"},
{"cargo_profile": "release-debuginfo", "rust_target": "aarch64-unknown-linux-gnu"},
{"cargo_profile": "release-native", "rust_toolchain": "stable"},
{"cargo_profile": "release-native", "feat_set": "none"},
{"cargo_profile": "release-native", "feat_set": "default"},
{"cargo_profile": "release-native", "bake_target": "smoke-valgrind"}
{"cargo_profile": "release-native", "bake_target": "smoke-valgrind"},
{"cargo_profile": "release-native", "rust_target": "aarch64-unknown-linux-gnu"},
{"cargo_profile": "release-native", "sys_target": "x86_64-v2-linux-gnu"},
{"cargo_profile": "release-native", "sys_target": "x86_64-v3-linux-gnu"},
{"cargo_profile": "release-native", "sys_target": "x86_64-v4-linux-gnu"},
{"rust_target": "aarch64-unknown-linux-gnu", "feat_set": "none"},
{"rust_target": "aarch64-unknown-linux-gnu", "feat_set": "default"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v1-linux-gnu"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v2-linux-gnu"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v3-linux-gnu"},
{"rust_target": "aarch64-unknown-linux-gnu", "sys_target": "x86_64-v4-linux-gnu"},
{"rust_target": "x86_64-unknown-linux-gnu", "sys_target": "aarch64-v8-linux-gnu"},
{"sys_target": "aarch64-v8-linux-gnu", "machine": "X64"},
{"sys_target": "x86_64-v1-linux-gnu", "machine": "ARM64"},
{"sys_target": "x86_64-v2-linux-gnu", "machine": "ARM64"},
{"sys_target": "x86_64-v2-linux-gnu", "feat_set": "none"},
{"sys_target": "x86_64-v2-linux-gnu", "feat_set": "default"},
{"sys_target": "x86_64-v3-linux-gnu", "machine": "ARM64"},
{"sys_target": "x86_64-v3-linux-gnu", "feat_set": "none"},
{"sys_target": "x86_64-v3-linux-gnu", "feat_set": "default"},
{"sys_target": "x86_64-v3-linux-gnu", "bake_target": "smoke-valgrind"},
{"sys_target": "x86_64-v4-linux-gnu", "machine": "ARM64"},
{"sys_target": "x86_64-v4-linux-gnu", "feat_set": "none"},
{"sys_target": "x86_64-v4-linux-gnu", "feat_set": "default"},
{"sys_target": "x86_64-v4-linux-gnu", "bake_target": "smoke-valgrind"},
]
complement:
if: >
inputs.complement
!failure() && !cancelled()
&& inputs.complement
&& contains(fromJSON(inputs.cargo_profiles), fromJSON('["test"]')[0])
&& contains(fromJSON(inputs.complement_feat_sets), fromJSON('["all"]')[0])
&& contains(fromJSON(inputs.rust_toolchains), fromJSON('["nightly"]')[0])
&& contains(fromJSON(inputs.sys_targets), fromJSON('["x86_64-v1-linux-gnu"]')[0])
name: Complement
uses: ./.github/workflows/bake.yml
@@ -113,21 +149,25 @@ jobs:
sys_names: ${{inputs.sys_names}}
sys_versions: ${{inputs.sys_versions}}
rust_targets: ${{inputs.rust_targets}}
sys_targets: ${{inputs.sys_targets}}
sys_targets: '["x86_64-v1-linux-gnu"]'
machines: ${{inputs.machines}}
runner: ${{inputs.complement_runner}}
excludes: ${{inputs.excludes}}
includes: ${{inputs.includes}}
compliance:
if: >
inputs.complement
!failure() && !cancelled()
&& inputs.complement
&& inputs.machines
&& contains(fromJSON(inputs.cargo_profiles), fromJSON('["test"]')[0])
&& contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0])
&& contains(fromJSON(inputs.rust_toolchains), fromJSON('["nightly"]')[0])
&& contains(fromJSON(inputs.sys_targets), fromJSON('["x86_64-v1-linux-gnu"]')[0])
name: Matrix Compliance
needs: [complement]
runs-on: ${{matrix.machine}}
runs-on: ["${{matrix.machine}}", "${{inputs.complement_runner}}"]
concurrency:
group: complement-cant-walk-and-chew-bubblegum
cancel-in-progress: false
@@ -141,7 +181,7 @@ jobs:
sys_name: ${{fromJSON(inputs.sys_names)}}
sys_version: ${{fromJSON(inputs.sys_versions)}}
rust_target: ${{fromJSON(inputs.rust_targets)}}
sys_target: ${{fromJSON(inputs.sys_targets)}}
sys_target: ${{fromJSON('["x86_64-v1-linux-gnu"]')}}
machine: ${{fromJSON(inputs.machines)}}
exclude: ${{fromJSON(inputs.excludes)}}
include: ${{fromJSON(inputs.includes)}}
@@ -163,7 +203,8 @@ jobs:
run: |
docker/complement.sh
- name: Extract
- if: success() || failure() && steps.execute.outcome == 'failure'
name: Extract
id: extract
env:
name: complement_tester__${{matrix.sys_name}}__${{matrix.sys_version}}__${{matrix.sys_target}}
@@ -173,13 +214,23 @@ jobs:
cid=$(cat "$name")
docker cp "$cid:/usr/src/complement/new_results.jsonl" tests/test_results/complement/test_results.jsonl
- name: Upload
id: upload
- if: success() || failure() && steps.execute.outcome == 'failure'
name: Upload New Results
id: upload-result
uses: actions/upload-artifact@v4
with:
name: test_results.${{matrix.feat_set}}.${{matrix.sys_name}}.${{matrix.sys_target}}.jsonl
name: complement_results-${{matrix.feat_set}}-${{matrix.sys_name}}-${{matrix.sys_target}}.jsonl
path: ./tests/test_results/complement/test_results.jsonl
- if: failure() && steps.execute.outcome == 'failure'
name: Upload Failure Output
id: upload-output
uses: actions/upload-artifact@v4
with:
name: complement_output-${{matrix.feat_set}}-${{matrix.sys_name}}-${{matrix.sys_target}}.jsonl
path: ./complement.jsonl
if-no-files-found: ignore
- name: Accept
id: accept
run: |
+7
View File
@@ -95,3 +95,10 @@ rustc-ice-*
# complement test logs are huge
tests/test_results/complement/test_logs.jsonl
# cargo profiles from -Z self-profile
*.mm_profdata
# Editor crashfiles
*.save
*.swp
Generated
+589 -715
View File
File diff suppressed because it is too large. Load diff
+74 -55
View File
@@ -28,8 +28,8 @@ keywords = [
license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/matrix-construct/tuwunel"
rust-version = "1.86.0"
version = "1.0.0"
rust-version = "1.88.0"
version = "1.3.0"
[workspace.metadata.crane]
name = "tuwunel"
@@ -57,7 +57,7 @@ version = "2.3.1"
version = "0.1.88"
[workspace.dependencies.axum]
version = "0.7.9"
version = "0.8.4"
default-features = false
features = [
"form",
@@ -70,10 +70,10 @@ features = [
]
[workspace.dependencies.axum-client-ip]
version = "0.6.1"
version = "0.7"
[workspace.dependencies.axum-extra]
version = "0.9.6"
version = "0.10.1"
default-features = false
features = [
"typed-header",
@@ -86,6 +86,7 @@ default-features = false
[workspace.dependencies.axum-server-dual-protocol]
version = "0.7"
default-features = false
[workspace.dependencies.base64]
version = "0.22.1"
@@ -103,10 +104,10 @@ features = [
version = "1.10.1"
[workspace.dependencies.bytesize]
version = "2.0"
version = "2.0.1"
[workspace.dependencies.cargo_toml]
version = "0.21"
version = "0.22.1"
default-features = false
features = ["features"]
@@ -114,12 +115,12 @@ features = ["features"]
version = "0.1"
[workspace.dependencies.chrono]
version = "0.4.38"
version = "0.4.41"
features = ["alloc", "std"]
default-features = false
[workspace.dependencies.clap]
version = "4.5.35"
version = "4.5.39"
default-features = false
features = [
"derive",
@@ -131,17 +132,18 @@ features = [
"usage",
]
[workspace.dependencies.console-subscriber]
version = "0.4"
# Disabled until Axum updated. Remember to remove cfgs for tuwunel_disable.
#[workspace.dependencies.console-subscriber]
#version = "0.4"
[workspace.dependencies.core_affinity]
version = "0.8.1"
version = "0.8.3"
[workspace.dependencies.const-str]
version = "0.6.2"
[workspace.dependencies.ctor]
version = "0.2.9"
version = "0.4.2"
[workspace.dependencies.cyborgtime]
version = "2.1.1"
@@ -171,7 +173,7 @@ features = [
]
[workspace.dependencies.hickory-resolver]
version = "0.25.1"
version = "0.25.2"
default-features = false
features = [
"serde",
@@ -199,7 +201,7 @@ features = [
]
[workspace.dependencies.hyper-util]
version = "0.1.11"
version = "0.1.14"
default-features = false
features = [
"server-auto",
@@ -208,7 +210,7 @@ features = [
]
[workspace.dependencies.image]
version = "0.25.5"
version = "0.25.6"
default-features = false
features = [
"jpeg",
@@ -223,6 +225,11 @@ version = "0.1.3"
[workspace.dependencies.itertools]
version = "0.14.0"
[workspace.dependencies.jsonwebtoken]
version = "9.3.1"
default-features = false
features = ["use_pem"]
[workspace.dependencies.ldap3]
git = "https://github.com/matrix-construct/ldap3"
rev = "7d423314b9dbc66347284e38fc2b78c3d8f3d494"
@@ -230,17 +237,17 @@ default-features = false
features = ["sync", "tls-rustls"]
[workspace.dependencies.libc]
version = "0.2"
version = "0.2.172"
[workspace.dependencies.libloading]
version = "0.8.6"
version = "0.8.8"
[workspace.dependencies.log]
version = "0.4.27"
default-features = false
[workspace.dependencies.loole]
version = "0.4.0"
version = "0.4.1"
[workspace.dependencies.lru-cache]
version = "0.1.2"
@@ -249,37 +256,38 @@ version = "0.1.2"
version = "1.0.2"
[workspace.dependencies.minicbor]
version = "0.26.3"
version = "1.0.0"
features = ["std"]
[workspace.dependencies.minicbor-serde]
version = "0.4.1"
version = "0.5.0"
features = ["std"]
[workspace.dependencies.nix]
version = "0.29.0"
version = "0.30.1"
default-features = false
features = ["resource"]
[workspace.dependencies.num-traits]
version = "0.2"
version = "0.2.19"
[workspace.dependencies.opentelemetry]
version = "0.21.0"
version = "0.30.0"
[workspace.dependencies.opentelemetry-jaeger]
version = "0.20.0"
features = ["rt-tokio"]
# Disabled until they move to opentelemetry 0.30
#[workspace.dependencies.opentelemetry-jaeger]
#version = "0.22.0"
#features = ["rt-tokio"]
[workspace.dependencies.opentelemetry_sdk]
version = "0.21.2"
version = "0.30.0"
features = ["rt-tokio"]
[workspace.dependencies.proc-macro2]
version = "1.0"
version = "1.0.95"
[workspace.dependencies.quote]
version = "1.0"
version = "1.0.40"
[workspace.dependencies.rand]
version = "0.8.5"
@@ -288,7 +296,7 @@ version = "0.8.5"
version = "1.11.1"
[workspace.dependencies.reqwest]
version = "0.12.15"
version = "0.12.19"
default-features = false
features = [
"rustls-tls-native-roots",
@@ -303,7 +311,7 @@ default-features = false
[workspace.dependencies.ruma]
git = "https://github.com/matrix-construct/ruma"
rev = "920148dca1076454ca0ca5d43b5ce1aa708381d4"
rev = "0155c2b33233bec9dece79d5134a9574b347f4c1"
features = [
"compat",
"rand",
@@ -341,24 +349,24 @@ features = [
]
[workspace.dependencies.rustls]
version = "0.23.25"
version = "0.23.27"
default-features = false
features = ["aws_lc_rs"]
[workspace.dependencies.rustyline-async]
version = "0.4.3"
version = "0.4.6"
default-features = false
[workspace.dependencies.rust-rocksdb]
git = "https://github.com/matrix-construct/rust-rocksdb"
rev = "cca241c5ca48f7c7f5c1469294f11dc156dd987a"
rev = "225a42519276e502205bdc845cebdb22d70ee245"
default-features = false
features = [
"bzip2",
"lz4",
"multi-threaded-cf",
"mt_static",
"lz4",
"zstd",
"bzip2",
]
[workspace.dependencies.sanitize-filename]
@@ -369,7 +377,7 @@ version = "0.4.5"
default-features = false
[workspace.dependencies.sentry]
version = "0.37.0"
version = "0.38.1"
default-features = false
features = [
"backtrace",
@@ -385,10 +393,10 @@ features = [
]
[workspace.dependencies.sentry-tower]
version = "0.37.0"
version = "0.38.1"
[workspace.dependencies.sentry-tracing]
version = "0.37.0"
version = "0.38.1"
[workspace.dependencies.serde]
version = "1.0.219"
@@ -414,7 +422,7 @@ version = "0.10.6"
default-features = false
[workspace.dependencies.sha2]
version = "0.10.8"
version = "0.10.9"
default-features = false
[workspace.dependencies.smallstr]
@@ -426,7 +434,7 @@ features = [
]
[workspace.dependencies.smallvec]
version = "1.14.0"
version = "1.15.1"
features = [
"const_generics",
"const_new",
@@ -436,7 +444,7 @@ features = [
]
[workspace.dependencies.syn]
version = "2.0"
version = "2.0.101"
default-features = false
features = [
"extra-traits",
@@ -447,7 +455,7 @@ features = [
]
[workspace.dependencies.termimad]
version = "0.31.2"
version = "0.33.0"
default-features = false
[workspace.dependencies.thiserror]
@@ -456,7 +464,7 @@ default-features = false
[workspace.dependencies.tikv-jemallocator]
git = "https://github.com/matrix-construct/jemallocator"
rev = "82af58d6a13ddd5dcdc7d4e91eae3b63292995b8"
rev = "03bed96afbbc898bef4d4f7d335c0519e3d1afad"
default-features = false
features = [
"background_threads_runtime_support",
@@ -465,13 +473,13 @@ features = [
[workspace.dependencies.tikv-jemalloc-ctl]
git = "https://github.com/matrix-construct/jemallocator"
rev = "82af58d6a13ddd5dcdc7d4e91eae3b63292995b8"
rev = "03bed96afbbc898bef4d4f7d335c0519e3d1afad"
default-features = false
features = ["use_std"]
[workspace.dependencies.tikv-jemalloc-sys]
git = "https://github.com/matrix-construct/jemallocator"
rev = "82af58d6a13ddd5dcdc7d4e91eae3b63292995b8"
rev = "03bed96afbbc898bef4d4f7d335c0519e3d1afad"
default-features = false
features = [
"background_threads_runtime_support",
@@ -479,7 +487,7 @@ features = [
]
[workspace.dependencies.tokio]
version = "1.44.2"
version = "1.46.0"
default-features = false
features = [
"fs",
@@ -494,10 +502,10 @@ features = [
]
[workspace.dependencies.tokio-metrics]
version = "0.4.0"
version = "0.4.2"
[workspace.dependencies.toml]
version = "0.8.14"
version = "0.8.23"
default-features = false
features = ["parse"]
@@ -507,7 +515,7 @@ default-features = false
features = ["util"]
[workspace.dependencies.tower-http]
version = "0.6.2"
version = "0.6.6"
default-features = false
features = [
"add-extension",
@@ -532,7 +540,7 @@ default-features = false
version = "0.2.0"
[workspace.dependencies.tracing-opentelemetry]
version = "0.22.0"
version = "0.31.0"
[workspace.dependencies.tracing-subscriber]
version = "0.3.19"
@@ -582,7 +590,7 @@ rev = "1e64095a8051a1adf0d1faa307f9f030889ec2aa"
# https://github.com/girlbossceo/rustyline-async/commit/67d8c49aeac03a5ef4e818f663eaa94dd7bf339b
[patch.crates-io.rustyline-async]
git = "https://github.com/matrix-construct/rustyline-async"
rev = "deaeb0694e2083f53d363b648da06e10fc13900c"
rev = "ba743cae940659e95d7b8604bbd6fdd755171c8c"
# adds LIFO queue scheduling; this should be updated with PR progress.
[patch.crates-io.event-listener]
@@ -595,12 +603,12 @@ rev = "92e5e74063bf2a3b10414bcc8a0d68b235644280"
# adds affinity masks for selecting more than one core at a time
[patch.crates-io.core_affinity]
git = "https://github.com/matrix-construct/core_affinity_rs"
rev = "9c8e51510c35077df888ee72a36b4b05637147da"
rev = "ff148c2985cbaff3e6e953d45cda4d7696f38d75"
# reverts hyperium#148 conflicting with our delicate federation resolver hooks
[patch.crates-io.hyper-util]
git = "https://github.com/matrix-construct/hyper-util"
rev = "e4ae7628fe4fcdacef9788c4c8415317a4489941"
rev = "c4fd9b4cd3a59fcfd28ca3802d68a8ea8988d9a3"
# allows no-aaaa option in resolv.conf
# bumps rust edition and toolchain to 1.86.0 and 2024
@@ -848,6 +856,7 @@ unused-qualifications = "warn"
## some sadness
elided_named_lifetimes = "allow" # TODO!
mismatched_lifetime_syntaxes = "allow" # TODO!
let_underscore_drop = "allow"
missing_docs = "allow"
# cfgs cannot be limited to expected cfgs or their de facto non-transitive/opt-in use-case e.g.
@@ -863,6 +872,15 @@ variant_size_differences = "allow"
# we check nightly clippy lints
unknown_lints = "allow"
# rust claims elided_named_lifetimes has been replaced by
# mismatched_lifetime_syntaxes but it actually has not.
renamed_and_removed_lints = "allow"
# nightly has a new lint that conflicts with our BoolExt trait at
# src/core/utils/bool.rs:68:48
# <https://github.com/rust-lang/rust/issues/142748>
unstable_name_collisions = "allow" # TODO
#######################################
#
# Clippy lints
@@ -902,6 +920,7 @@ enum_glob_use = { level = "allow", priority = 1 }
if_not_else = { level = "allow", priority = 1 }
if_then_some_else_none = { level = "allow", priority = 1 }
inline_always = { level = "allow", priority = 1 }
map_unwrap_or = { level = "allow", priority = 1 }
match_bool = { level = "allow", priority = 1 }
missing_docs_in_private_items = { level = "allow", priority = 1 }
missing_errors_doc = { level = "allow", priority = 1 }
-17
View File
@@ -1,17 +0,0 @@
# One Tuwunel
June 6, 2025
### New Features
- LDAP authentication. Thanks @RatCornu!
- Podman systemd. Thanks @everypizza1!
### Bug Fixes
- Several panics fixed by Jade Ellis (@JadedBlueEyes) et al. Thank you 🙏
### Honorable Mentions
- Special thanks to Peter Gervai (@grinapo) for hosting the fanclub room; also
for documentation and wiki contributions.
+14 -18
View File
@@ -1,4 +1,4 @@
# Tuwunel <sup>🎔</sup>
# Tuwunel<sup>💕</sup>
![GitHub License](https://img.shields.io/github/license/matrix-construct/tuwunel?style=flat&color=%238A2BE2)
![GitHub Created At](https://img.shields.io/github/created-at/matrix-construct/tuwunel?style=flat&color=%238A2BE2)
@@ -35,9 +35,10 @@ development. It is now maintained by full-time staff.
- [Sourcecode](https://github.com/matrix-construct/tuwunel/) `git clone https://github.com/matrix-construct/tuwunel.git`
- [DockerHub](https://hub.docker.com/r/jevolk/tuwunel) or `docker pull jevolk/tuwunel:latest`
- [GHCR](https://github.com/matrix-construct/tuwunel/pkgs/container/tuwunel) or `docker pull ghcr.io/matrix-construct/tuwunel:latest`
- Static binaries available as [releases](https://github.com/matrix-construct/tuwunel/releases) or [build artifacts](https://github.com/matrix-construct/tuwunel/actions?query=branch%3Amain).
- Deb and RPM packages available as [releases](https://github.com/matrix-construct/tuwunel/releases) or [build artifacts](https://github.com/matrix-construct/tuwunel/actions?query=branch%3Amain).
- Static binaries also available as [releases](https://github.com/matrix-construct/tuwunel/releases) or [build artifacts](https://github.com/matrix-construct/tuwunel/actions?query=branch%3Amain).
- Arch package is expected shortly. Nix package still needs some love.
- Arch package available as [tuwunel](https://aur.archlinux.org/packages/tuwunel) or [tuwunel-git](https://aur.archlinux.org/packages/tuwunel-git).
- Nix package still [needs some love](https://github.com/NixOS/nixpkgs/issues/415469).
**1.** [Configure](https://matrix-construct.github.io/tuwunel/configuration.html) by
copying and editing the `tuwunel-example.toml`. The `server_name` and `database_path` must be
@@ -46,7 +47,7 @@ configured. **Most users deploy via docker or a distribution package and should
This is just a summary for the impatient. See the full
[documentation](https://matrix-construct.github.io/tuwunel/).
> [!WARNING]
> [!TIP]
> Avoid using a sub-domain for your `server_name`. You can always delegate later with a [`.well-known`](https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/docs/configuring-well-known.md)
> file, but you can never change your `server_name`.
@@ -139,31 +140,26 @@ turbulence limited to release-time.
### Getting Help & Support
The official community will be found at [#tuwunel:tuwunel.chat](https://matrix.to/#/#tuwunel:tuwunel.chat).
If this is currently inaccessible please be patient as it's still coming online at the time of
the first release; we will have updates to this section. This is a fully moderated space to protect
the wellbeing of our users and create a non-toxic work environment for staff. If you require assistance
with anything that is not remedied by the documentation, don't hesitate to open an issue on github.
If you are opposed to using github, or private discussion is required, or for any other reason,
I would be happy to receive your DM at [@jason:tuwunel.me](https://matrix.to/#/@jason:tuwunel.me),
you will not be bothering me and it would be my pleasure to help you anytime. As an emergency contact
you can send an email to jasonzemos@gmail.com.
If you are opposed to using github, or if private discussion is required such as for security
disclosures, or for any other reason, I would be happy to receive your DM at
[@jason:tuwunel.me](https://matrix.to/#/@jason:tuwunel.me). This will not be bothering me as it would
be my pleasure to help you when possible. As an emergency contact you can send an email to
jasonzemos@gmail.com.
##### Tuwunel Fanclub
We also have an unofficial community-run chat which is publicly accessible at
[#tuwunel:grin.hu](https://matrix.to/#/#tuwunel:grin.hu). The members, content, or moderation
We have an unofficial community-run chat which is publicly accessible at
[#tuwunel:matrix.org](https://matrix.to/#/#tuwunel:matrix.org). The members, content, or moderation
decisions of this room are not in any way related or endorsed by this project or its sponsors,
and not all project staff will be present there. There will be at least some presence by staff to
offer assistance so long as the room remains in minimally good standing.
## Tuwunel <sup>🎔</sup>
## Tuwunel<sup>💕</sup>
Tuwunel's theme is **empathy** in communication defined by the works of
[Edith Stein](https://plato.stanford.edu/entries/stein/). Empathy is the basis for how we approach
every message, and a reminder for how we should all conduct ourselves in every conversation.
every message and our responsibility to the other in every conversation.
<!-- ANCHOR_END: body -->
+59
View File
@@ -0,0 +1,59 @@
# Tuwunel 1.3.0
August 4, 2025
Preparations for [Project Hydra](https://matrix.org/blog/2025/07/security-predisclosure/) have taken place. Users should be prepared to upgrade to `v1.4.0-rc` next week. Due to the comprehensive low-level changes which have taken place, and the inability to develop them in public with your feedback, the release will undergo an extended `-rc` period. Due to the time difference and scheduling conflicts our release may be published between 12 to 36 hours after the suggested time; though well before the written disclosure of the issues.
Some foundational work for `v1.4.0` was backported into this release after the announcement was made mid-July to further extend Hydra. An unexpected performance improvement drastically reduced CPU usage. As a result, integration tests began to flake, uncovering latent concurrency bugs which were addressed. These fixes primarily impact the legacy and sliding-sync systems, and further fixes improve performance and compliance, though mostly in the legacy system as sliding-sync lacks adequate test coverage.
This release fixes many bugs and improves performance but at the cost of planned features further rescheduled to either `v1.4.1` or `v1.5.0`.
### New Features
- Refresh tokens (MSC2918) have been implemented. Supporting clients can now timeout their access tokens with a soft-logout after a configured `access_token_ttl`. This feature was commissioned and made public by an enterprise sponsor.
- Typing indicators have been added to sliding-sync thanks to @tmayoff. This feature (and the whole of sliding-sync) is still experimental and the indicator may not always appear or disappear as intended, nevertheless the effort will be enhanced by foundational fixes improving sliding-sync requested soon by the project's sponsor.
### Enhancements
- @dasha_uwu maintains their streak as a serial contributor by patching the `!admin query raw` command with a base64 option allowing for low-level debugging of database records.
- @obioma has improved the documentation explaining how to use multiple configuration files with precedence.
- Upon recommendation of @grin a basic request ID has been added to the tracing logs to uniquely distinguish each request while it's interleaved among others.
- Requested by @fruzitent this and future releases are tagged by version as multi-arch docker images to be properly archived in the registry rather than simply overwriting `:latest`.
- Event processing performance has been improved by fetching and processing `prev_events` and `auth_events` concurrently. This reduces the impact of recursing large graphs while the room's mutex is locked.
- An experimental command `!admin debug resync-database` has been added for developers curious about #35
### Bug Fixes
- Thanks to @tmayoff room avatars are properly calculated and no longer the same for all spaces (https://github.com/matrix-construct/tuwunel/pull/102).
- Courtesy of @coolGi69 our bump to Rust 1.88 was properly updated for Nix. Apologies to the Nix community for getting this wrong the first time.
- Invite rejections have been fixed, this was due to a misinterpretation of the spec in legacy sync.
- Knock rooms might have been buggy from the ambiguous overuse of the word "count" in the codebase. Database records which expected a summation of the users in a room instead received the sequence number of the server, both are called "count."
- Room knocks failed to wakeup the sync systems; some cases of account_data changes also failed to wakeup the sync systems. These have been addressed.
- The main sequence number fundamental to the entire server's operation (the "count" or counter) has been refactored after having exceeded architectural limitations. It has been replaced by a two-phase counter ensuring read-after-write consistency, and quasi-transactions grouping multiple writes.
- Sequence issues have been addressed in both legacy and sliding sync. These systems operate using a "snapshot" approach which intentionally ignores new data received by the server after the sync request has started; the snapshot approach replaced the complex of mutexes used by Conduit. The server was not originally designed for this approach and some information "from the future" continued to leak into the snapshot's window; these leaks have been sealed.
- Protocol compliance issues in legacy sync have been addressed. Additional compliance tests for device list updates now pass. The `state` and `timeline` on incremental sync provide expected results in more (if not all) cases.
- Errors requiring M_BAD_ALIAS instead of M_UNKNOWN when sending `m.room.canonical_alias` are now conforming.
### Deprecations
- Unauthenticated media fallbacks are no longer requested by default. This can still be enabled with `request_legacy_media` if desired.
- Legacy Sliding-Sync has been removed in favor of Simplified Sliding-Sync. Clients which exclusively using Sliding-Sync have already migrated around the start of this year, so this removal should have no impact now.
+1 -1
View File
@@ -59,7 +59,7 @@ StateDirectory=tuwunel
RuntimeDirectory=tuwunel
RuntimeDirectoryMode=0750
Environment="CONDUWUIT_CONFIG=/etc/tuwunel/tuwunel.toml"
Environment="TUWUNEL_CONFIG=/etc/tuwunel/tuwunel.toml"
BindPaths=/var/lib/private/tuwunel:/var/lib/conduwuit
BindPaths=/var/lib/private/tuwunel:/var/lib/private/conduwuit
BindPaths=/var/lib/private/tuwunel:/var/lib/matrix-conduit
+2 -2
View File
@@ -1,7 +1,7 @@
array-size-threshold = 4096
cognitive-complexity-threshold = 100 # TODO reduce me ALARA
excessive-nesting-threshold = 11 # TODO reduce me to 4 or 5
future-size-threshold = 7745 # TODO reduce me ALARA
excessive-nesting-threshold = 8
future-size-threshold = 8192
stack-size-threshold = 196608 # TODO reduce me ALARA
too-many-lines-threshold = 780 # TODO reduce me to <= 100
type-complexity-threshold = 250 # reduce me to ~200
+49 -8
View File
@@ -1,9 +1,10 @@
# syntax = docker/dockerfile:1.11-labs
FROM input AS cargo
ARG sys_target
ARG sys_triple
ARG rust_target
ARG rust_toolchain
ARG RUST_HOME
ARG RUSTUP_HOME
ARG CARGO_HOME
ARG CARGO_TARGET
@@ -11,19 +12,50 @@ ARG CARGO_TARGET_DIR
ARG cargo_target_profile
ARG cargo_target_artifact
ARG cargo_target_share
ARG CARGO_TERM_VERBOSE=0
ARG RUST_BACKTRACE
ARG JEMALLOC_OVERRIDE
ARG ROCKSDB_LIB_DIR
ARG CARGO_BUILD_RUSTFLAGS
ARG CARGO_PROFILE_TEST_DEBUG
ARG CARGO_PROFILE_TEST_INCREMENTAL
ARG CARGO_PROFILE_BENCH_DEBUG
ARG CARGO_PROFILE_BENCH_LTO
ARG CARGO_PROFILE_RELEASE_LTO
ARG CARGO_PROFILE_RELEASE_DEBUGINFO_DEBUG
ARG CARGO_PROFILE_RELEASE_DEBUGINFO_LTO
ARG cargo_profile
ARG cargo_features
ARG cargo_spec_features
ARG cargo_cmd
ARG color_args="--color always"
ARG recipe_args=""
ARG cargo_args=""
ARG git_checkout
WORKDIR /
COPY --link --from=input . .
COPY --link --from=rust ${RUST_HOME} ${RUST_HOME}
COPY --link --from=deps /usr/src/tuwunel /usr/src/tuwunel
WORKDIR /usr/lib/${sys_target}
WORKDIR /usr/lib/${sys_triple}
COPY --link --from=rocksdb . .
WORKDIR /usr/src/tuwunel
ENV PATH="${CARGO_HOME}/bin:$PATH"
ENV CARGO_TERM_VERBOSE="${CARGO_TERM_VERBOSE}"
ENV RUST_BACKTRACE="${RUST_BACKTRACE}"
ENV JEMALLOC_OVERRIDE="${JEMALLOC_OVERRIDE}"
ENV ROCKSDB_LIB_DIR="${ROCKSDB_LIB_DIR}"
ENV CARGO_PROFILE_TEST_DEBUG="${CARGO_PROFILE_TEST_DEBUG}"
ENV CARGO_PROFILE_TEST_INCREMENTAL="${CARGO_PROFILE_TEST_INCREMENTAL}"
ENV CARGO_PROFILE_BENCH_DEBUG="${CARGO_PROFILE_BENCH_DEBUG}"
ENV CARGO_PROFILE_BENCH_LTO="${CARGO_PROFILE_BENCH_LTO}"
ENV CARGO_PROFILE_RELEASE_LTO="${CARGO_PROFILE_RELEASE_LTO}"
ENV CARGO_PROFILE_RELEASE_DEBUGINFO_DEBUG="${CARGO_PROFILE_RELEASE_DEBUGINFO_DEBUG}"
ENV CARGO_PROFILE_RELEASE_DEBUGINFO_LTO="${CARGO_PROFILE_RELEASE_DEBUGINFO_LTO}"
ENV CARGO_BUILD_RUSTFLAGS="${CARGO_BUILD_RUSTFLAGS}"
ENV CARGO_TARGET_DIR="${CARGO_TARGET_DIR}"
ENV targ_dir="${CARGO_TARGET_DIR}/${cargo_target_profile}"
ENV targ_targ_dir="${CARGO_TARGET_DIR}/${rust_target}/${cargo_target_profile}"
RUN \
@@ -48,11 +80,20 @@ RUN \
--locked \
--workspace \
"${cargo_spec_features}" \
--features "${cargo_features}" \
--profile "${cargo_profile}" \
--target "${CARGO_TARGET}" \
--target-dir "${CARGO_TARGET_DIR}" \
--manifest-path Cargo.toml \
--color always \
"--features=${cargo_features}" \
"--profile=${cargo_profile}" \
"--target=${CARGO_TARGET}" \
"--target-dir=${CARGO_TARGET_DIR}" \
"--manifest-path=Cargo.toml" \
${recipe_args} \
${color_args} \
${cargo_args}
# If this image is further reused with other cargo commands, all
# modifications made by cargo chef cook outside of target-dir have to be
# cleared. If not, resulting build artifacts will link incorrectly, even
# without error. For example, a target executable may be produced which
# does nothing except exit(0). If you have observed a smoketest failing in
# such a manner, investigate this as a cause of the issue.
git restore -W -S --source=${git_checkout} .
EOF
+3 -4
View File
@@ -1,7 +1,6 @@
# syntax = docker/dockerfile:1.11-labs
FROM input AS audit
ARG sys_target
ARG rust_toolchain="nightly"
ARG RUSTUP_HOME
ARG CARGO_HOME
@@ -12,9 +11,9 @@ COPY --link --from=input . .
WORKDIR /usr/src/tuwunel
RUN \
--mount=type=cache,dst=${RUSTUP_HOME}/downloads,sharing=shared,ro \
--mount=type=cache,dst=${CARGO_HOME}/registry,sharing=shared,ro \
--mount=type=cache,dst=${CARGO_HOME}/git,sharing=shared,ro \
--mount=type=cache,dst=${RUSTUP_HOME}/downloads,sharing=shared \
--mount=type=cache,dst=${CARGO_HOME}/registry,sharing=shared \
--mount=type=cache,dst=${CARGO_HOME}/git,sharing=shared \
<<EOF
set -eux
rustup run ${rust_toolchain} \
+11 -11
View File
@@ -1,7 +1,6 @@
# syntax = docker/dockerfile:1.11-labs
FROM input AS deb
ARG sys_target
FROM input AS build-deb
ARG rust_target
ARG rust_toolchain
ARG RUSTUP_HOME
@@ -55,28 +54,29 @@ RUN \
--output "${pkg_dir}" \
${deb_args}
dpkg --info ${pkg_dir}/*
dpkg --contents ${pkg_dir}/*
mv ${pkg_dir}/* "${pkg_dir}/tuwunel.deb"
dpkg --info "${pkg_dir}/tuwunel.deb"
dpkg --contents "${pkg_dir}/tuwunel.deb"
EOF
FROM scratch AS pkg-deb
FROM scratch AS deb
ARG pkg_dir
COPY --from=input ${pkg_dir}/* .
COPY --from=input ${pkg_dir}/tuwunel.deb .
FROM input AS pkg-deb-install
FROM input AS deb-install
ARG pkg_dir
WORKDIR /
COPY --link --from=input . .
WORKDIR ${pkg_dir}
COPY --from=pkg-deb . .
COPY --from=deb . .
RUN <<EOF
set -eux
dpkg --info *
dpkg --contents *
dpkg --install *
dpkg --info tuwunel.deb
dpkg --contents tuwunel.deb
dpkg --install tuwunel.deb
EOF
-84
View File
@@ -1,84 +0,0 @@
# syntax = docker/dockerfile:1.11-labs
FROM input AS deps
ARG sys_target
ARG rust_target
ARG rust_toolchain
ARG RUSTUP_HOME
ARG CARGO_HOME
ARG CARGO_TARGET
ARG CARGO_TARGET_DIR
ARG cargo_target_profile
ARG cargo_target_artifact
ARG cargo_target_share
ARG CARGO_BUILD_RUSTFLAGS
ARG CARGO_PROFILE_TEST_DEBUG
ARG CARGO_PROFILE_TEST_INCREMENTAL
ARG CARGO_PROFILE_BENCH_DEBUG
ARG CARGO_PROFILE_BENCH_LTO
ARG CARGO_PROFILE_RELEASE_LTO
ARG CARGO_PROFILE_RELEASE_DEBUGINFO_DEBUG
ARG CARGO_PROFILE_RELEASE_DEBUGINFO_LTO
ARG cargo_profile
ARG cargo_features
ARG cargo_spec_features
ARG cook_args
ARG git_checkout
WORKDIR /
COPY --link --from=input . .
WORKDIR /usr/lib/${sys_target}
COPY --link --from=rocksdb . .
WORKDIR /usr/src/tuwunel
COPY --link --from=recipe recipe.json .
ENV CARGO_PROFILE_TEST_DEBUG="${CARGO_PROFILE_TEST_DEBUG}"
ENV CARGO_PROFILE_TEST_INCREMENTAL="${CARGO_PROFILE_TEST_INCREMENTAL}"
ENV CARGO_PROFILE_BENCH_DEBUG="${CARGO_PROFILE_BENCH_DEBUG}"
ENV CARGO_PROFILE_BENCH_LTO="${CARGO_PROFILE_BENCH_LTO}"
ENV CARGO_PROFILE_RELEASE_LTO="${CARGO_PROFILE_RELEASE_LTO}"
ENV CARGO_PROFILE_RELEASE_DEBUGINFO_DEBUG="${CARGO_PROFILE_RELEASE_DEBUGINFO_DEBUG}"
ENV CARGO_PROFILE_RELEASE_DEBUGINFO_LTO="${CARGO_PROFILE_RELEASE_DEBUGINFO_LTO}"
ENV CARGO_BUILD_RUSTFLAGS="${CARGO_BUILD_RUSTFLAGS}"
ENV CARGO_TARGET_DIR="${CARGO_TARGET_DIR}"
ENV targ_dir="${CARGO_TARGET_DIR}/${cargo_target_profile}"
ENV targ_targ_dir="${CARGO_TARGET_DIR}/${rust_target}/${cargo_target_profile}"
RUN \
--mount=type=cache,dst=${RUSTUP_HOME}/downloads,sharing=shared \
--mount=type=cache,dst=${CARGO_HOME}/registry,sharing=shared \
--mount=type=cache,dst=${CARGO_HOME}/git,sharing=shared \
--mount=type=cache,dst=${targ_dir}/deps,id=${cargo_target_share}/deps,sharing=locked \
--mount=type=cache,dst=${targ_dir}/build,id=${cargo_target_share}/build,sharing=locked \
--mount=type=cache,dst=${targ_dir}/examples,id=${cargo_target_share}/examples,sharing=locked \
--mount=type=cache,dst=${targ_dir}/incremental,id=${cargo_target_share}/incremental,sharing=locked \
--mount=type=cache,dst=${targ_dir}/.fingerprint,id=${cargo_target_share}/fingerprint,sharing=locked \
--mount=type=cache,dst=${targ_targ_dir}/deps,id=${cargo_target_share}/deps,sharing=locked \
--mount=type=cache,dst=${targ_targ_dir}/build,id=${cargo_target_share}/build,sharing=locked \
--mount=type=cache,dst=${targ_targ_dir}/examples,id=${cargo_target_share}/examples,sharing=locked \
--mount=type=cache,dst=${targ_targ_dir}/incremental,id=${cargo_target_share}/incremental,sharing=locked \
--mount=type=cache,dst=${targ_targ_dir}/.fingerprint,id=${cargo_target_share}/fingerprint,sharing=locked \
<<EOF
set -eux
rustup run ${rust_toolchain} \
cargo chef cook ${cook_args} \
--verbose \
--locked \
--workspace \
"${cargo_spec_features}" \
--features "${cargo_features}" \
--profile "${cargo_profile}" \
--target "${CARGO_TARGET}" \
--target-dir "${CARGO_TARGET_DIR}" \
--manifest-path Cargo.toml \
--recipe-path recipe.json
# If this image is further reused with other cargo commands, all
# modifications made by cargo chef cook outside of target-dir have to be
# cleared. If not, resulting build artifacts will link incorrectly, even
# without error. For example, a target executable may be produced which
# does nothing except exit(0). If you have observed a smoketest failing in
# such a manner, investigate this as a cause of the issue.
git restore -W -S --source=${git_checkout} .
EOF
+3 -4
View File
@@ -1,7 +1,6 @@
# syntax = docker/dockerfile:1.11-labs
FROM input AS fmt
ARG sys_target
ARG rust_toolchain="nightly"
ARG RUSTUP_HOME
ARG CARGO_HOME
@@ -12,9 +11,9 @@ COPY --link --from=input . .
WORKDIR /usr/src/tuwunel
RUN \
--mount=type=cache,dst=${RUSTUP_HOME}/downloads,sharing=shared,ro \
--mount=type=cache,dst=${CARGO_HOME}/registry,sharing=shared,ro \
--mount=type=cache,dst=${CARGO_HOME}/git,sharing=shared,ro \
--mount=type=cache,dst=${RUSTUP_HOME}/downloads,sharing=shared \
--mount=type=cache,dst=${CARGO_HOME}/registry,sharing=shared \
--mount=type=cache,dst=${CARGO_HOME}/git,sharing=shared \
<<EOF
set -eux
rustup run ${rust_toolchain} \
+3 -4
View File
@@ -1,7 +1,6 @@
# syntax = docker/dockerfile:1.11-labs
FROM input AS lychee
ARG sys_target
ARG rust_toolchain="nightly"
ARG RUSTUP_HOME
ARG CARGO_HOME
@@ -16,9 +15,9 @@ COPY --link --from=input . .
WORKDIR /usr/src/
RUN \
--mount=type=cache,dst=${RUSTUP_HOME}/downloads,sharing=shared,ro \
--mount=type=cache,dst=${CARGO_HOME}/registry,sharing=shared,ro \
--mount=type=cache,dst=${CARGO_HOME}/git,sharing=shared,ro \
--mount=type=cache,dst=${RUSTUP_HOME}/downloads,sharing=shared \
--mount=type=cache,dst=${CARGO_HOME}/registry,sharing=shared \
--mount=type=cache,dst=${CARGO_HOME}/git,sharing=shared \
--mount=type=cache,dst=lychee,sharing=locked \
<<EOF
set -eux
+9 -8
View File
@@ -1,7 +1,6 @@
# syntax = docker/dockerfile:1.11-labs
FROM input AS rpm
ARG sys_target
FROM input AS build-rpm
ARG rust_toolchain
ARG RUSTUP_HOME
ARG CARGO_HOME
@@ -47,25 +46,27 @@ RUN \
--payload-compress zstd \
--output "${pkg_dir}" \
${gen_rpm_args}
mv ${pkg_dir}/* "${pkg_dir}/tuwunel.rpm"
EOF
FROM scratch AS pkg-rpm
FROM scratch AS rpm
ARG pkg_dir
COPY --link --from=input ${pkg_dir}/* .
COPY --from=input ${pkg_dir}/tuwunel.rpm .
FROM input AS pkg-rpm-install
FROM input AS rpm-install
ARG pkg_dir
WORKDIR /
COPY --link --from=input . .
WORKDIR ${pkg_dir}
COPY --link --from=pkg-rpm . .
COPY --link --from=rpm . .
RUN <<EOF
set -eux
rpm -i --test *
rpm -i *
rpm -i --test tuwunel.rpm
rpm -i tuwunel.rpm
EOF
+3 -3
View File
@@ -11,9 +11,9 @@ COPY --link --from=input . .
WORKDIR /usr/src/tuwunel
RUN \
--mount=type=cache,dst=${RUSTUP_HOME}/downloads,sharing=shared,ro \
--mount=type=cache,dst=${CARGO_HOME}/registry,sharing=shared,ro \
--mount=type=cache,dst=${CARGO_HOME}/git,sharing=shared,ro \
--mount=type=cache,dst=${RUSTUP_HOME}/downloads,sharing=shared \
--mount=type=cache,dst=${CARGO_HOME}/registry,sharing=shared \
--mount=type=cache,dst=${CARGO_HOME}/git,sharing=shared \
<<EOF
set -eux
rustup run ${rust_toolchain} \
+52 -48
View File
@@ -8,8 +8,8 @@ WORKDIR /
COPY --link --from=input . .
RUN \
--mount=type=cache,dst=${var_cache},sharing=locked \
--mount=type=cache,dst=${var_lib_apt},sharing=locked \
--mount=type=cache,dst=/var/cache,id=${var_cache},sharing=locked \
--mount=type=cache,dst=/var/lib/apt,id=${var_lib_apt},sharing=locked \
<<EOF
set -eux
apt-get -y -U install --no-install-recommends openssl gawk
@@ -66,49 +66,51 @@ COPY --from=source /usr/src/tuwunel/tests/test_results/complement/test_results.j
COPY <<EOF complement.toml
[global]
address = "0.0.0.0"
admin_room_notices = false
allow_check_for_updates = false
allow_device_name_federation = true
allow_guest_registration = true
allow_invalid_tls_certificates = true
allow_legacy_media = true
allow_public_room_directory_over_federation = true
allow_public_room_directory_without_auth = true
allow_registration = true
create_admin_room = false
database_path = "/database"
log = "debug,tuwunel=trace,h2=warn,hyper=warn"
port = [8008, 8448]
trusted_servers = []
only_query_trusted_key_servers = false
query_trusted_key_servers_first = false
query_trusted_key_servers_first_on_join = false
yes_i_am_very_very_sure_i_want_an_open_registration_server_prone_to_abuse = true
dns_attempts = 20
dns_timeout = 60
federation_idle_timeout = 300
intentionally_unknown_config_option_for_testing = true
ip_range_denylist = []
url_preview_domain_contains_allowlist = ["*"]
url_preview_domain_explicit_denylist = ["*"]
log = "debug,tuwunel=trace,h2=warn,hyper=warn"
log_colors = false
log_guest_registrations = false
log_span_events = "NONE"
log_thread_ids = true
media_compat_file_link = false
media_startup_check = true
only_query_trusted_key_servers = false
port = [8008, 8448]
prune_missing_media = true
log_colors = false
admin_room_notices = false
allow_check_for_updates = false
intentionally_unknown_config_option_for_testing = true
rocksdb_log_level = "debug"
rocksdb_max_log_files = 1
rocksdb_recovery_mode = 0
rocksdb_paranoid_file_checks = true
log_guest_registrations = false
allow_legacy_media = true
startup_netburst = true
startup_netburst_keep = -1
# valgrind makes things so slow
dns_timeout = 60
dns_attempts = 20
query_trusted_key_servers_first = false
query_trusted_key_servers_first_on_join = false
request_conn_timeout = 60
request_timeout = 120
well_known_conn_timeout = 60
well_known_timeout = 60
federation_idle_timeout = 300
sender_timeout = 300
rocksdb_log_level = "debug"
rocksdb_max_log_files = 1
rocksdb_paranoid_file_checks = true
rocksdb_recovery_mode = 0
sender_idle_timeout = 300
sender_retry_backoff_limit = 300
allow_invalid_tls_certificates = true
sender_timeout = 300
startup_netburst = true
startup_netburst_keep = -1
trusted_servers = []
url_preview_domain_contains_allowlist = ["*"]
url_preview_domain_explicit_denylist = ["*"]
well_known_conn_timeout = 60
well_known_timeout = 60
yes_i_am_very_very_sure_i_want_an_open_registration_server_prone_to_abuse = true
[global.tls]
certs = "/complement/certificate.crt"
@@ -150,14 +152,14 @@ ENTRYPOINT valgrind \
FROM input AS complement-base
ARG var_cache
ARG var_lib_apt
ARG complement_tags="tuwunel_blacklist"
ARG complement_tags="conduwuit_blacklist"
ARG complement_tests="./tests/..."
ARG complement_run=".*"
WORKDIR /
RUN \
--mount=type=cache,dst=${var_cache},sharing=locked \
--mount=type=cache,dst=${var_lib_apt},sharing=locked \
--mount=type=cache,dst=/var/cache,id=${var_cache},sharing=locked \
--mount=type=cache,dst=/var/lib/apt,id=${var_lib_apt},sharing=locked \
--mount=type=cache,dst=/go/pkg/mod/cache,sharing=locked \
<<EOF
set -eux
@@ -165,7 +167,7 @@ RUN \
EOF
WORKDIR /usr/src
ADD https://github.com/matrix-construct/complement.git complement
ADD https://github.com/matrix-construct/complement.git#81f3b61e10ec102a36921890c81b79564ebf6f40 complement
WORKDIR /usr/src/complement
ENV COMPLEMENT_BASE_IMAGE="complement-testee"
@@ -211,6 +213,7 @@ ENV COMPLEMENT_HOST_MOUNTS="/var/run/docker.sock:/var/run/docker.sock"
ENV jq_res='{Action: .Action, Test: .Test}'
ENV jq_sel='select((.Action == \"pass\" or .Action == \"fail\" or .Action == \"skip\") and .Test != null)'
ENV jq_tab='[.Action, .Test] | @tsv'
ENV jq_out='select(.Test != null) | {Test: .Test, Output: .Output}'
COPY --from=complement-config /complement/old_results.jsonl .
COPY <<EOF uwu.sh
env;
@@ -219,22 +222,23 @@ COPY <<EOF uwu.sh
COMPLEMENT_BASE_IMAGE="\${1:-$complement_base_image}"
go test
-json
-shuffle="${complement_shuffle}"
-parallel="${complement_parallel}"
-timeout="${complement_timeout}"
-count="${complement_count}"
-tags="${complement_tags}"
-skip="${complement_skip}"
-run="${complement_run}"
"${complement_tests}"
| jq --unbuffered -c "${jq_sel} | ${jq_res}"
"-shuffle=\$complement_shuffle"
"-parallel=\$complement_parallel"
"-timeout=\$complement_timeout"
"-count=\$complement_count"
"-tags=\$complement_tags"
"-skip=\$complement_skip"
"-run=\$complement_run"
"\$complement_tests"
| jq --unbuffered -c "."
| tee output.jsonl
| jq --unbuffered -c "$jq_sel | $jq_res"
| tee results.jsonl
| jq --unbuffered -r "${jq_tab}"
| jq --unbuffered -r "$jq_tab"
;
jq -s -c "sort_by(.Test)[]" < results.jsonl | uniq > new_results.jsonl;
wc -l old_results.jsonl new_results.jsonl;
diff -w -y -t --width=275 --suppress-common-lines old_results.jsonl new_results.jsonl;
jq -s -c "sort_by(.Test, .Timestamp)[] | $jq_out" < output.jsonl > full_output.jsonl;
EOF
RUN echo $(tr -d '\n' < uwu.sh) > uwu.sh
RUN echo $(tr -d '\n' < uwu.sh) > uwu.sh && chmod a+x uwu.sh
ENTRYPOINT ["/bin/bash", "/usr/src/complement/uwu.sh"]
+8
View File
@@ -5,6 +5,7 @@ ARG rust_target
ARG CARGO_TARGET_DIR
ARG cargo_target_profile
ARG install_prefix
ARG assert_linkage=""
WORKDIR /
COPY --link --from=input . .
@@ -14,6 +15,13 @@ ENV src_path="${CARGO_TARGET_DIR}/${rust_target}/${cargo_target_profile}/tuwunel
ENV dst_path="${install_prefix}/bin/tuwunel"
COPY --from=bins $src_path $dst_path
RUN <<EOF
ret=$(ldd "${dst_path}")
if [ "$ret" = "0" ] && [ "$assert_linkage" = "static" ]; then
exit 1
elif [ "$ret" != "0" ] && [ "$assert_linkage" = "dynamic" ]; then
exit 1
fi
set -eux
ldd -v ${dst_path} || true
du -h ${dst_path}
+10 -6
View File
@@ -1,6 +1,9 @@
# syntax = docker/dockerfile:1.11-labs
FROM input AS rocksdb-fetch
ARG rocksdb_branch="tuwunel-changes"
ARG rust_rocksdb_branch="conduwuit-changes"
ARG librocksdb_submodule="librocksdb-sys/rocksdb"
WORKDIR /
COPY --link --from=input . .
@@ -10,19 +13,20 @@ COPY --link --from=recipe rocksdb.url .
RUN <<EOF
set -eux
submodule="librocksdb-sys/rocksdb"
url="$(cat rocksdb.url)"
rocksdb_url="$(cat rocksdb.url)"
git clone \
--depth 1 \
--recurse-submodules="${submodule}" \
"${url}" \
--single-branch \
--branch "${rust_rocksdb_branch}" \
"--recurse-submodules=${librocksdb_submodule}" \
"${rocksdb_url}" \
/usr/src/rocksdb
EOF
FROM input AS rocksdb-build
ARG rocksdb_shared=0
ARG rocksdb_portable=1
ARG rocksdb_portable="1"
ARG rocksdb_opt_level="3"
ARG rocksdb_build_type="Release"
ARG rocksdb_cxx_flags="-ftls-model=initial-exec"
@@ -81,7 +85,7 @@ RUN <<EOF
cmake \
--build build \
--target install \
--parallel ${nprocs}
--parallel "${nprocs}"
EOF
+5 -4
View File
@@ -3,7 +3,7 @@
FROM input AS rustup
ARG RUST_HOME
ARG rust_target
ARG rustup_version="1.28.1"
ARG rustup_version="1.28.2"
ARG rustup_profile="minimal"
WORKDIR /
@@ -13,9 +13,10 @@ WORKDIR ${RUST_HOME}
RUN <<EOF
set -eux
url="https://static.rust-lang.org/rustup/archive/${rustup_version}/${rust_target}/rustup-init"
var="${rustup_version}/${rust_target}"
url="https://static.rust-lang.org/rustup/archive/$var/rustup-init"
curl -S -O -s "$url"
chmod o+x rustup-init
chmod a+rx rustup-init
EOF
FROM input AS rust
@@ -53,7 +54,7 @@ RUN \
--no-update-default-toolchain \
--no-modify-path
chmod -R go+rw $CARGO_HOME $RUSTUP_HOME
chmod -R a+rw $CARGO_HOME $RUSTUP_HOME
rm rustup-init
rustup component add \
+2 -7
View File
@@ -18,7 +18,6 @@ EOF
FROM input AS ingredients
ARG sys_target
ARG rust_target
ARG rust_toolchain
ARG RUST_HOME
@@ -28,23 +27,18 @@ ARG CARGO_TARGET
ARG CARGO_TERM_VERBOSE=0
ARG RUST_BACKTRACE
ARG JEMALLOC_OVERRIDE
#ARG ZSTD_SYS_USE_PKG_CONFIG=0
ARG ROCKSDB_LIB_DIR
WORKDIR /
COPY --link --from=input . .
WORKDIR /
COPY --link --from=rust ${RUST_HOME} ${RUST_HOME}
COPY --link --from=source /usr/src/tuwunel /usr/src/tuwunel
WORKDIR /usr/src/tuwunel
COPY --link --from=source /usr/src/tuwunel .
ENV PATH="${CARGO_HOME}/bin:$PATH"
ENV CARGO_TERM_VERBOSE="${CARGO_TERM_VERBOSE}"
ENV RUST_BACKTRACE="${RUST_BACKTRACE}"
ENV JEMALLOC_OVERRIDE="${JEMALLOC_OVERRIDE}"
#ENV ZSTD_SYS_USE_PKG_CONFIG="${ZSTD_SYS_USE_PKG_CONFIG}"
ENV ROCKSDB_LIB_DIR="${ROCKSDB_LIB_DIR}"
RUN \
--mount=type=cache,dst=${RUSTUP_HOME}/downloads,sharing=locked \
@@ -91,6 +85,7 @@ RUN \
package="rust-librocksdb-sys"
cmd="cargo tree --manifest-path ${manifest} -f {r} -p ${package}"
url="$(rustup run ${rust_toolchain} ${cmd} | head -n 1)"
url="https://github.com/matrix-construct/rust-rocksdb" #TODO fixme
echo "$url" > rocksdb.url
sha1sum recipe.json rocksdb.url
+2 -2
View File
@@ -17,8 +17,8 @@ COPY --link --from=input . .
ENV DEBIAN_FRONTEND="${DEBIAN_FRONTEND}"
RUN \
--mount=type=cache,dst=${var_cache},sharing=locked \
--mount=type=cache,dst=${var_lib_apt},sharing=locked \
--mount=type=cache,dst=/var/cache,id=${var_cache},sharing=locked \
--mount=type=cache,dst=/var/lib/apt,id=${var_lib_apt},sharing=locked \
<<EOF
echo $(uname -a) $0 $-
set -eux
+5 -5
View File
@@ -14,7 +14,7 @@ variations while only paying the cost of rebuilding the last layer for each one.
This directory is made up of three types of files:
- Shell scripts are the user interface. Use this system through one of the shell scripts. The
bake files can still be docker'ed directly but it's recomended to run the script.
bake files can still be docker'ed directly but it's recommended to run the script.
- The `.hcl` files specify the targets of the tree. This is all standard
[docker bake](https://docs.docker.com/build/bake/reference/). All targets are ordered where each
@@ -30,8 +30,8 @@ many targets to create many variations using the same Dockerfile.
### Getting started
1. You will need to install docker buildx/buildkit and maybe a couple other related things.
I would appreciate if you could contribute exact commands for your platform when you perform
this step.
`apt-get install docker-buildx`
2. You will need to create a builder. There are a few complications that must be explained here
so please be patient.
@@ -62,7 +62,7 @@ so please be patient.
all = true
EOF
BKD_FLAGS="--allow-insecure-entitlement netwok.host"
BKD_FLAGS="--allow-insecure-entitlement network.host"
docker buildx create \
--name owo \
--bootstrap \
@@ -84,7 +84,7 @@ cues from the primary user of this system, the [GitHub CI](https://github.com/ma
5. Defeat the final boss by building and running complement to completion. This will involve
building the targets for `complement-tester` and `complement-testee` using `bake.sh` and then
invoking `complement.sh`. You can take cues again from another user of this in the
[GitHub CI](https://github.com/matrix-construct/tuwunel/blob/main/.github/workflows/test.yml#L79).
[GitHub CI](https://github.com/matrix-construct/tuwunel/blob/7e8c4c8883ca17de91c3323d329541342366ee0c/.github/workflows/test.yml#L140).
## Notes
+322 -178
View File
@@ -16,12 +16,6 @@ variable "repo" {
variable "docker_repo" {
default = "${repo}"
}
variable "docker_tag_preview" {
default = false
}
variable "docker_tag_latest" {
default = false
}
variable "git_ref" {
default = "${GITHUB_REF}"
@@ -36,23 +30,26 @@ variable "git_ref_name" {
cargo_feat_sets = {
none = ""
default = "brotli_compression,element_hacks,gzip_compression,io_uring,jemalloc,jemalloc_conf,media_thumbnail,release_max_log_level,systemd,url_preview,zstd_compression"
all = "blurhashing,brotli_compression,tuwunel_mods,console,default,direct_tls,element_hacks,gzip_compression,hardened_malloc,io_uring,jemalloc,jemalloc_conf,jemalloc_prof,jemalloc_stats,ldap,media_thumbnail,perf_measurements,release_max_log_level,sentry_telemetry,systemd,tokio_console,url_preview,zstd_compression"
all = "blurhashing,brotli_compression,bzip2_compression,tuwunel_mods,console,default,direct_tls,element_hacks,gzip_compression,hardened_malloc,io_uring,jemalloc,jemalloc_conf,jemalloc_prof,jemalloc_stats,ldap,lz4_compression,media_thumbnail,perf_measurements,release_max_log_level,sentry_telemetry,systemd,tokio_console,url_preview,zstd_compression"
}
variable "cargo_features_always" {
default = "direct_tls"
}
variable "feat_sets" {
default = "[\"none\", \"default\", \"all\"]"
}
variable "cargo_profiles" {
default = "[\"test\", \"release\"]"
}
variable "install_prefix" {
default = "/usr"
}
variable "rust_msrv" {
default = "stable"
}
variable "rust_toolchains" {
default = "[\"nightly\", \"stable\"]"
}
@@ -60,19 +57,19 @@ variable "rust_targets" {
default = "[\"x86_64-unknown-linux-gnu\"]"
}
variable "sys_targets" {
default = "[\"x86_64-linux-gnu\"]"
variable "sys_names" {
default = "[\"debian\"]"
}
variable "sys_versions" {
default = "[\"testing-slim\"]"
}
variable "sys_names" {
default = "[\"debian\"]"
variable "sys_targets" {
default = "[\"x86_64-v1-linux-gnu\"]"
}
# RocksDB options
variable "rocksdb_portable" {
default = 1
default = "1"
}
variable "rocksdb_opt_level" {
default = "3"
@@ -149,58 +146,68 @@ variable "git_checkout" {
default = "HEAD"
}
#
# Rustflags
#
rustflags = [
"-C link-arg=--verbose",
"-C link-arg=-Wl,--gc-sections",
]
static_rustflags = [
"-C relocation-model=static",
"-C target-feature=+crt-static",
]
static_libs = [
"-C link-arg=-l:libstdc++.a",
"-C link-arg=-l:libc.a",
"-C link-arg=-l:libm.a",
]
dynamic_rustflags = [
"-C relocation-model=pic",
"-C target-feature=-crt-static",
"-C link-arg=-Wl,--as-needed",
]
dynamic_libs = [
"-C link-arg=-lstdc++",
"-C link-arg=-lc",
"-C link-arg=-lm",
]
nightly_rustflags = [
"--cfg tokio_unstable",
"--cfg tuwunel_bench",
"--allow=unstable-features",
"-Zcrate-attr=feature(test)",
"-Zenforce-type-length-limit",
#"-Ztime-passes",
#"-Ztime-llvm-passes",
]
static_rustflags = [
"-Crelocation-model=static",
"-Ctarget-feature=+crt-static",
"-Clink-arg=--verbose",
"-Clink-arg=-Wl,--gc-sections",
"-Clink-arg=-L/usr/lib/gcc/x86_64-linux-gnu/14", # FIXME
"-Clink-arg=-l:libstdc++.a",
"-Clink-arg=-l:libc.a",
"-Clink-arg=-l:libm.a",
]
dynamic_rustflags = [
"-Crelocation-model=pic",
"-Ctarget-feature=-crt-static",
"-Clink-arg=--verbose",
"-Clink-arg=-Wl,--gc-sections",
"-Clink-arg=-Wl,--as-needed",
"-Clink-arg=-lstdc++",
"-Clink-arg=-lc",
"-Clink-arg=-lm",
"-Z crate-attr=feature(test)",
"-Z enforce-type-length-limit",
#"-Z time-passes",
#"-Z time-llvm-passes",
]
static_nightly_rustflags = [
"-Ztls-model=local-exec",
"-Z tls-model=local-exec",
]
rmp_rustflags = [
"-Ctarget-cpu=native",
"-Ztune-cpu=native",
"-Zinline-mir=true",
"-Zmir-opt-level=3",
native_rustflags = [
"-C target-cpu=native",
"-Z tune-cpu=native",
"-Z inline-mir=true",
"-Z mir-opt-level=3",
]
override_rustflags = [
"-Crelocation-model=pic",
"-Ctarget-feature=-crt-static",
"-Clink-arg=-Wl,--no-gc-sections",
"-C relocation-model=pic",
"-C target-feature=-crt-static",
"-C link-arg=-Wl,--no-gc-sections",
]
macro_rustflags = [
"-Crelocation-model=pic",
"-Ctarget-feature=-crt-static",
"-C relocation-model=pic",
"-C target-feature=-crt-static",
]
#
@@ -266,28 +273,24 @@ group "publish" {
]
}
target "github" {
target "ghcr_io" {
name = elem("github", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
tags = [
"ghcr.io/${repo}:${git_ref_name}-${cargo_profile}-${feat_set}-${sys_target}",
docker_tag_preview? "ghcr.io/${repo}:preview": "",
docker_tag_latest? "ghcr.io/${repo}:latest": "",
]
output = ["type=registry,compression=zstd,mode=min,compression-level=${zstd_image_compress_level}"]
output = ["type=registry,oci-mediatypes=true,compression=zstd,compression-level=${zstd_image_compress_level},force-compression=true,mode=min"]
matrix = cargo_rust_feat_sys
inherits = [
elem("docker", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
]
}
target "dockerhub" {
target "docker_io" {
name = elem("dockerhub", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
tags = [
"${docker_repo}:${git_ref_name}-${cargo_profile}-${feat_set}-${sys_target}",
docker_tag_preview? "${docker_repo}:preview": "",
docker_tag_latest? "${docker_repo}:latest": "",
"docker.io/${docker_repo}:${git_ref_name}-${cargo_profile}-${feat_set}-${sys_target}",
]
output = ["type=registry,compression=zstd,mode=min,compression-level=${zstd_image_compress_level}"]
output = ["type=registry,oci-mediatypes=true,compression=zstd,compression-level=${zstd_image_compress_level},force-compression=true,mode=min"]
matrix = cargo_rust_feat_sys
inherits = [
elem("docker", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
@@ -521,7 +524,7 @@ group "installs" {
install_labels = {
"org.opencontainers.image.authors" = "${package_authors}"
"org.opencontainers.image.created" ="${package_last_modified}"
"org.opencontainers.image.created" = "${package_last_modified}"
"org.opencontainers.image.description" = "Matrix Chat Server in Rust"
"org.opencontainers.image.documentation" = "https://github.com/matrix-construct/tuwunel/tree/main/docs/"
"org.opencontainers.image.licenses" = "Apache-2.0"
@@ -533,12 +536,26 @@ install_labels = {
"org.opencontainers.image.version" = "${package_version}"
}
install_annotations = [
"org.opencontainers.image.authors=${package_authors}",
"org.opencontainers.image.created=${package_last_modified}",
"org.opencontainers.image.description=Matrix Chat Server in Rust",
"org.opencontainers.image.documentation=https://github.com/matrix-construct/tuwunel/tree/main/docs/",
"org.opencontainers.image.licenses=Apache-2.0",
"org.opencontainers.image.revision=${package_revision}",
"org.opencontainers.image.source=https://github.com/matrix-construct/tuwunel",
"org.opencontainers.image.title=${package_name}",
"org.opencontainers.image.url=https://github.com/matrix-construct/tuwunel",
"org.opencontainers.image.vendor=matrix-construct",
"org.opencontainers.image.version=${package_version}",
]
target "oci" {
name = elem("oci", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
tags = [
elem_tag("oci", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target], "latest"),
]
output = ["type=oci,dest=tuwunel-oci.tar.zst,mode=min,compression=zstd,compression-level=${zstd_image_compress_level}"]
output = ["type=oci,dest=tuwunel-oci.tar.zst,compression=zstd,compression-level=${zstd_image_compress_level},force-compression=true,mode=min"]
matrix = cargo_rust_feat_sys
inherits = [
elem("docker", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
@@ -550,7 +567,7 @@ target "docker" {
tags = [
elem_tag("docker", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target], "latest"),
]
output = ["type=docker,compression=gzip,mode=min,compression-level=${gz_image_compress_level}"]
output = ["type=docker,compression=zstd,compression-level=${zstd_image_compress_level},force-compression=true,mode=min"]
matrix = cargo_rust_feat_sys
inherits = [
elem("static", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
@@ -579,7 +596,7 @@ target "static" {
tags = [
elem_tag("static", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target], "latest"),
]
output = ["type=docker,compression=zstd,mode=min,compression-level=${zstd_image_compress_level}"]
output = ["type=docker,compression=uncompressed,mode=min"]
matrix = cargo_rust_feat_sys
inherits = [
elem("install", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
@@ -630,8 +647,9 @@ target "install" {
elem_tag("install", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target], "latest"),
]
labels = install_labels
output = ["type=docker,compression=zstd,mode=min,compression-level=${zstd_image_compress_level}"]
cache_to = ["type=local,compression=zstd,mode=min,compression-level=${cache_compress_level}"]
annotations = install_annotations
output = ["type=docker,compression=zstd,mode=max,compression-level=${zstd_image_compress_level}"]
cache_to = ["type=local,compression=zstd,mode=max,compression-level=${cache_compress_level}"]
dockerfile = "${docker_dir}/Dockerfile.install"
target = "install"
matrix = cargo_rust_feat_sys
@@ -655,43 +673,27 @@ target "install" {
group "pkg" {
targets = [
"pkg-deb",
"pkg-rpm",
"pkg-deb-install",
"pkg-rpm-install",
"deb",
"rpm",
"deb-install",
"rpm-install",
]
}
target "pkg-rpm-install" {
name = elem("pkg-rpm-install", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
target "rpm-install" {
name = elem("rpm-install", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
tags = [
elem_tag("pkg-rpm-install", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target], "latest"),
elem_tag("rpm-install", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target], "latest"),
]
target = "pkg-rpm-install"
target = "rpm-install"
output = ["type=cacheonly,compression=zstd,mode=min,compression-level=${cache_compress_level}"]
matrix = cargo_rust_feat_sys
inherits = [
elem("pkg-rpm", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
]
contexts = {
input = "docker-image://redhat/ubi9"
pkg-rpm = elem("target:pkg-rpm", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
}
}
target "pkg-rpm" {
name = elem("pkg-rpm", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
tags = [
elem_tag("pkg-rpm", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target], "latest"),
]
target = "pkg-rpm"
output = ["type=docker,compression=zstd,mode=min"]
matrix = cargo_rust_feat_sys
inherits = [
elem("rpm", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
]
contexts = {
input = elem("target:rpm", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
input = "docker-image://redhat/ubi9"
rpm = elem("target:rpm", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
}
}
@@ -701,6 +703,22 @@ target "rpm" {
elem_tag("rpm", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target], "latest"),
]
target = "rpm"
output = ["type=docker,compression=zstd,mode=min"]
matrix = cargo_rust_feat_sys
inherits = [
elem("build-rpm", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
]
contexts = {
input = elem("target:build-rpm", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
}
}
target "build-rpm" {
name = elem("build-rpm", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
tags = [
elem_tag("build-rpm", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target], "latest"),
]
target = "build-rpm"
dockerfile = "${docker_dir}/Dockerfile.cargo.rpm"
matrix = cargo_rust_feat_sys
inherits = [
@@ -714,36 +732,20 @@ target "rpm" {
}
}
target "pkg-deb-install" {
name = elem("pkg-deb-install", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
target "deb-install" {
name = elem("deb-install", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
tags = [
elem_tag("pkg-deb-install", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target], "latest"),
elem_tag("deb-install", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target], "latest"),
]
target = "pkg-deb-install"
target = "deb-install"
output = ["type=cacheonly,compression=zstd,mode=min,compression-level=${cache_compress_level}"]
matrix = cargo_rust_feat_sys
inherits = [
elem("pkg-deb", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
]
contexts = {
input = elem("target:runtime", [feat_set, sys_name, sys_version, sys_target])
pkg-deb = elem("target:pkg-deb", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
}
}
target "pkg-deb" {
name = elem("pkg-deb", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
tags = [
elem_tag("pkg-deb", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target], "latest"),
]
target = "pkg-deb"
output = ["type=docker,compression=zstd,mode=min"]
matrix = cargo_rust_feat_sys
inherits = [
elem("deb", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
]
contexts = {
input = elem("target:deb", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
input = elem("target:runtime", [feat_set, sys_name, sys_version, sys_target])
deb = elem("target:deb", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
}
}
@@ -753,6 +755,22 @@ target "deb" {
elem_tag("deb", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target], "latest"),
]
target = "deb"
output = ["type=docker,compression=zstd,mode=min"]
matrix = cargo_rust_feat_sys
inherits = [
elem("build-deb", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
]
contexts = {
input = elem("target:build-deb", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
}
}
target "build-deb" {
name = elem("build-deb", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
tags = [
elem_tag("build-deb", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target], "latest"),
]
target = "build-deb"
dockerfile = "${docker_dir}/Dockerfile.cargo.deb"
matrix = cargo_rust_feat_sys
inherits = [
@@ -828,7 +846,7 @@ target "docs" {
elem("build", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
]
contexts = {
input = (use_chef == "true"?
deps = (use_chef == "true"?
elem("target:deps-build", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]):
elem("target:ingredients", [rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
)
@@ -851,7 +869,7 @@ target "build-bins" {
elem("build", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
]
contexts = {
input = (use_chef == "true"?
deps = (use_chef == "true"?
elem("target:deps-build-bins", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]):
elem("target:build", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
)
@@ -873,7 +891,7 @@ target "build-tests" {
elem("build", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
]
contexts = {
input = (use_chef == "true"?
deps = (use_chef == "true"?
elem("target:deps-build-tests", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]):
elem("target:build", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
)
@@ -895,7 +913,7 @@ target "build" {
elem("cargo", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
]
contexts = {
input = (use_chef == "true"?
deps = (use_chef == "true"?
elem("target:deps-build", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]):
elem("target:ingredients", [rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
)
@@ -917,7 +935,7 @@ target "clippy" {
elem("cargo", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
]
contexts = {
input = (use_chef == "true"?
deps = (use_chef == "true"?
elem("target:deps-clippy", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]):
elem("target:ingredients", [rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
)
@@ -939,7 +957,7 @@ target "check" {
elem("cargo", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]),
]
contexts = {
input = (use_chef == "true"?
deps = (use_chef == "true"?
elem("target:deps-check", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target]):
elem("target:ingredients", [rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
)
@@ -1023,14 +1041,20 @@ target "fmt" {
target "cargo" {
name = elem("cargo", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
target = "cargo"
output = ["type=cacheonly,compression=zstd,mode=min,compression-level=${cache_compress_level}"]
cache_to = ["type=local,compression=zstd,mode=min,compression-level=${cache_compress_level}"]
dockerfile = "${docker_dir}/Dockerfile.cargo"
cache_to = ["type=local,compression=zstd,mode=max,compression-level=${cache_compress_level}"]
matrix = cargo_rust_feat_sys
inherits = [
elem("deps-base", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
]
contexts = {
deps = elem("target:deps-base", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
}
args = {
recipe_args = ""
cargo_args = ""
color_args = "--color=always"
}
}
#
@@ -1057,7 +1081,7 @@ target "deps-build-bins" {
elem("deps-base", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
]
args = {
cook_args = "--bins"
cargo_cmd = "chef cook --bins"
}
}
@@ -1071,7 +1095,7 @@ target "deps-build-tests" {
elem("deps-base", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
]
args = {
cook_args = (cargo_profile == "bench"? "--benches": "--tests")
cargo_cmd = (cargo_profile == "bench"? "chef cook --benches": "chef cook --tests")
}
}
@@ -1085,7 +1109,7 @@ target "deps-build" {
elem("deps-base", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
]
args = {
cook_args = "--all-targets"
cargo_cmd = "chef cook --all-targets"
}
}
@@ -1099,7 +1123,7 @@ target "deps-clippy" {
elem("deps-base", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
]
args = {
cook_args = "--all-targets --clippy"
cargo_cmd = "chef cook --all-targets --clippy"
}
}
@@ -1113,7 +1137,7 @@ target "deps-check" {
elem("deps-base", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
]
args = {
cook_args = "--all-targets --check"
cargo_cmd = "chef cook --all-targets --check"
}
}
@@ -1126,22 +1150,26 @@ target "deps-base" {
tags = [
elem_tag("deps-base", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target], "latest")
]
target = "deps"
target = "cargo"
output = ["type=cacheonly,compression=zstd,mode=min,compression-level=${cache_compress_level}"]
cache_to = ["type=local,compression=zstd,mode=min,compression-level=${cache_compress_level}"]
dockerfile = "${docker_dir}/Dockerfile.cargo.deps"
cache_to = ["type=local,compression=zstd,mode=max,compression-level=${cache_compress_level}"]
dockerfile = "${docker_dir}/Dockerfile.cargo"
matrix = cargo_rust_feat_sys
inherits = [
elem("kitchen", [feat_set, sys_name, sys_version, sys_target]),
elem("rust", [rust_toolchain, rust_target, sys_name, sys_version, sys_target]),
elem("recipe", [rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
]
contexts = {
input = elem("target:ingredients", [rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
recipe = elem("target:recipe", [rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
input = elem("target:kitchen", [feat_set, sys_name, sys_version, sys_target])
deps = elem("target:preparing", [rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
rocksdb = elem("target:rocksdb", [cargo_profile, rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
}
args = {
cargo_profile = cargo_profile
cook_args = "--all-targets --no-build"
cargo_cmd = "chef cook --all-targets --no-build"
recipe_args = "--recipe-path=recipe.json"
color_args = ""
# Base path
CARGO_TARGET_DIR = "${cargo_tgt_dir_base}"
@@ -1167,56 +1195,108 @@ target "deps-base" {
CARGO_BUILD_RUSTFLAGS = (
cargo_profile == "release-native"?
join(" ", [
join(" ", rustflags),
join(" ", nightly_rustflags),
contains(split(",", cargo_feat_sets[feat_set]), "zstd_compression")?
"-Clink-arg=-l:libzstd.a": "",
contains(split(",", cargo_feat_sets[feat_set]), "io_uring")?
"-Clink-arg=-l:liburing.a": "",
join(" ", static_rustflags),
join(" ", static_nightly_rustflags),
join(" ", rmp_rustflags),
join(" ", native_rustflags),
"-C link-arg=-L/usr/lib/gcc/${sys_target_triple(sys_target)}/14", #FIXME
contains(split(",", cargo_feat_sets[feat_set]), "bzip2_compression")?
"-C link-arg=-l:libbz2.a": "",
contains(split(",", cargo_feat_sets[feat_set]), "lz4_compression")?
"-C link-arg=-l:liblz4.a": "",
contains(split(",", cargo_feat_sets[feat_set]), "zstd_compression")?
"-C link-arg=-l:libzstd.a": "",
contains(split(",", cargo_feat_sets[feat_set]), "io_uring")?
"-C link-arg=-l:liburing.a": "",
join(" ", static_libs),
sys_target_triple(sys_target) == "aarch64-linux-gnu"?
"-C link-arg=-l:libgcc.a": "",
]):
cargo_profile == "release" && rust_toolchain == "nightly"?
join(" ", [
join(" ", rustflags),
join(" ", nightly_rustflags),
contains(split(",", cargo_feat_sets[feat_set]), "zstd_compression")?
"-Clink-arg=-l:libzstd.a": "",
contains(split(",", cargo_feat_sets[feat_set]), "io_uring")?
"-Clink-arg=-l:liburing.a": "",
join(" ", static_rustflags),
join(" ", static_nightly_rustflags),
sys_target_triple(sys_target) == "x86_64-linux-gnu"?
"-C target-cpu=${sys_target_isa(sys_target)}": "",
"-C link-arg=-L/usr/lib/gcc/${sys_target_triple(sys_target)}/14", #FIXME
contains(split(",", cargo_feat_sets[feat_set]), "bzip2_compression")?
"-C link-arg=-l:libbz2.a": "",
contains(split(",", cargo_feat_sets[feat_set]), "lz4_compression")?
"-C link-arg=-l:liblz4.a": "",
contains(split(",", cargo_feat_sets[feat_set]), "zstd_compression")?
"-C link-arg=-l:libzstd.a": "",
contains(split(",", cargo_feat_sets[feat_set]), "io_uring")?
"-C link-arg=-l:liburing.a": "",
join(" ", static_libs),
sys_target_triple(sys_target) == "aarch64-linux-gnu"?
"-C link-arg=-l:libgcc.a": "",
]):
cargo_profile == "release" || cargo_profile == "release-debuginfo"?
join(" ", [
contains(split(",", cargo_feat_sets[feat_set]), "zstd_compression")?
"-Clink-arg=-l:libzstd.a": "",
contains(split(",", cargo_feat_sets[feat_set]), "io_uring")?
"-Clink-arg=-l:liburing.a": "",
join(" ", rustflags),
join(" ", static_rustflags),
sys_target_triple(sys_target) == "x86_64-linux-gnu"?
"-C target-cpu=${sys_target_isa(sys_target)}": "",
"-C link-arg=-L/usr/lib/gcc/${sys_target_triple(sys_target)}/14", #FIXME
contains(split(",", cargo_feat_sets[feat_set]), "bzip2_compression")?
"-C link-arg=-l:libbz2.a": "",
contains(split(",", cargo_feat_sets[feat_set]), "lz4_compression")?
"-C link-arg=-l:liblz4.a": "",
contains(split(",", cargo_feat_sets[feat_set]), "zstd_compression")?
"-C link-arg=-l:libzstd.a": "",
contains(split(",", cargo_feat_sets[feat_set]), "io_uring")?
"-C link-arg=-l:liburing.a": "",
join(" ", static_libs),
sys_target_triple(sys_target) == "aarch64-linux-gnu"?
"-C link-arg=-l:libgcc.a": "",
]):
rust_toolchain == "stable"?
join(" ", [
contains(split(",", cargo_feat_sets[feat_set]), "zstd_compression")?
"-Clink-arg=-l:libzstd.a": "",
contains(split(",", cargo_feat_sets[feat_set]), "io_uring")?
"-Clink-arg=-l:liburing.a": "",
join(" ", rustflags),
join(" ", static_rustflags),
sys_target_triple(sys_target) == "x86_64-linux-gnu"?
"-C target-cpu=${sys_target_isa(sys_target)}": "",
"-C link-arg=-L/usr/lib/gcc/${sys_target_triple(sys_target)}/14", #FIXME
contains(split(",", cargo_feat_sets[feat_set]), "bzip2_compression")?
"-C link-arg=-l:libbz2.a": "",
contains(split(",", cargo_feat_sets[feat_set]), "lz4_compression")?
"-C link-arg=-l:liblz4.a": "",
contains(split(",", cargo_feat_sets[feat_set]), "zstd_compression")?
"-C link-arg=-l:libzstd.a": "",
contains(split(",", cargo_feat_sets[feat_set]), "io_uring")?
"-C link-arg=-l:liburing.a": "",
join(" ", static_libs),
sys_target_triple(sys_target) == "aarch64-linux-gnu"?
"-C link-arg=-l:libgcc.a": "",
]):
rust_toolchain == "nightly"?
join(" ", [
join(" ", rustflags),
join(" ", nightly_rustflags),
contains(split(",", cargo_feat_sets[feat_set]), "zstd_compression")?
"-Clink-arg=-lzstd": "",
contains(split(",", cargo_feat_sets[feat_set]), "io_uring")?
"-Clink-arg=-luring": "",
join(" ", dynamic_rustflags),
sys_target_triple(sys_target) == "x86_64-linux-gnu"?
"-C target-cpu=${sys_target_isa(sys_target)}": "",
contains(split(",", cargo_feat_sets[feat_set]), "bzip2_compression")?
"-C link-arg=-lbz2": "",
contains(split(",", cargo_feat_sets[feat_set]), "lz4_compression")?
"-C link-arg=-llz4": "",
contains(split(",", cargo_feat_sets[feat_set]), "zstd_compression")?
"-C link-arg=-lzstd": "",
contains(split(",", cargo_feat_sets[feat_set]), "io_uring")?
"-C link-arg=-luring": "",
join(" ", dynamic_libs),
]):
join(" ", [])
join(" ", [
join(" ", rustflags),
])
)
}
}
@@ -1256,13 +1336,32 @@ target "rocksdb-build" {
input = elem("target:kitchen", [feat_set, sys_name, sys_version, sys_target])
}
args = {
rocksdb_bz2 = contains(split(",", cargo_feat_sets[feat_set]), "bzip2_compression")? 1: 0
rocksdb_lz4 = contains(split(",", cargo_feat_sets[feat_set]), "lz4_compression")? 1: 0
rocksdb_zstd = contains(split(",", cargo_feat_sets[feat_set]), "zstd_compression")? 1: 0
rocksdb_jemalloc = contains(split(",", cargo_feat_sets[feat_set]), "jemalloc")? 1: 0
rocksdb_iouring = contains(split(",", cargo_feat_sets[feat_set]), "io_uring")? 1: 0
rocksdb_portable = cargo_profile == "release_max_perf"? 0: rocksdb_portable
rocksdb_build_type = rocksdb_build_type
rocksdb_opt_level = rocksdb_opt_level
rocksdb_shared = 0
rocksdb_opt_level = rocksdb_opt_level
rocksdb_build_type = rocksdb_build_type
rocksdb_cxx_flags = (
cargo_profile == "release-native" && sys_target_triple(sys_target) == "aarch64-linux-gnu"?
"-ftls-model=local-exec -mno-outline-atomics":
cargo_profile == "release-native"?
"-ftls-model=local-exec":
sys_target_triple(sys_target) == "aarch64-linux-gnu"?
"-ftls-model=initial-exec -mno-outline-atomics":
sys_target_triple(sys_target) == "x86_64-linux-gnu" && sys_target != "x86_64-v1-linux-gnu"?
"-ftls-model=initial-exec -mpclmul":
"-ftls-model=initial-exec"
)
rocksdb_portable = (
cargo_profile == "release-native"?
"0":
sys_target_triple(sys_target) == "x86_64-linux-gnu"?
"${sys_target_isa(sys_target)}":
rocksdb_portable
)
}
}
@@ -1309,6 +1408,7 @@ target "recipe" {
]
contexts = {
input = elem("target:preparing", [rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
preparing = elem("target:preparing", [rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
}
}
@@ -1324,6 +1424,7 @@ target "preparing" {
]
contexts = {
input = elem("target:ingredients", [rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
ingredients = elem("target:ingredients", [rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target])
}
}
@@ -1332,17 +1433,18 @@ target "ingredients" {
tags = [
elem_tag("ingredients", [rust_toolchain, rust_target, feat_set, sys_name, sys_version, sys_target], "latest"),
]
cache_to = ["type=local,compression=zstd,mode=max"]
target = "ingredients"
cache_to = ["type=local,compression=zstd,mode=min"]
dockerfile = "${docker_dir}/Dockerfile.source"
matrix = rust_feat_sys
inherits = [
elem("source", [sys_name, sys_version, sys_target]),
elem("kitchen", [feat_set, sys_name, sys_version, sys_target]),
elem("rust", [rust_toolchain, rust_target, sys_name, sys_version, sys_target]),
elem("source", [sys_name, sys_version, sys_target]),
]
contexts = {
rust = elem("target:rust", [rust_toolchain, rust_target, sys_name, sys_version, sys_target])
input = elem("target:kitchen", [feat_set, sys_name, sys_version, sys_target])
rust = elem("target:rust", [rust_toolchain, rust_target, sys_name, sys_version, sys_target])
source = elem("target:source", [sys_name, sys_version, sys_target])
}
args = {
@@ -1355,8 +1457,8 @@ target "ingredients" {
"--all-features": "--no-default-features"
)
RUST_BACKTRACE = "full"
ROCKSDB_LIB_DIR="/usr/lib/${sys_target}"
JEMALLOC_OVERRIDE="/usr/lib/${sys_target}/libjemalloc.a"
ROCKSDB_LIB_DIR="/usr/lib/${sys_target_triple(sys_target)}"
JEMALLOC_OVERRIDE="/usr/lib/${sys_target_triple(sys_target)}/libjemalloc.a"
ZSTD_SYS_USE_PKG_CONFIG = (
contains(split(",", cargo_feat_sets[feat_set]), "zstd_compression")? 1: 0
)
@@ -1400,7 +1502,7 @@ cargo_installs = [
"cargo-chef",
"cargo-audit",
"cargo-deb",
"cargo-arch",
#"cargo-arch",
"cargo-generate-rpm",
"lychee",
"mdbook",
@@ -1429,13 +1531,16 @@ target "rust" {
input = elem("target:rustup", [rust_target, sys_name, sys_version, sys_target])
}
args = {
rust_toolchain = rust_toolchain
rust_toolchain = (rust_toolchain == "stable"?
rust_msrv: rust_toolchain
)
rustup_components = join(" ", rustup_components)
cargo_installs = join(" ", cargo_installs)
CARGO_TERM_VERBOSE = CARGO_TERM_VERBOSE
RUSTUP_HOME = "/opt/rust/rustup/${sys_name}"
CARGO_HOME = "/opt/rust/cargo/${sys_name}/${sys_target}"
RUSTUP_HOME = "/opt/rust/rustup/${sys_name}/${sys_target_triple(sys_target)}"
CARGO_HOME = "/opt/rust/cargo/${sys_name}/${sys_target_triple(sys_target)}"
}
}
@@ -1483,6 +1588,7 @@ kitchen_packages = [
"cmake",
"curl",
"git",
"gzip",
"libc6-dev",
"libssl-dev",
"make",
@@ -1506,10 +1612,12 @@ target "kitchen" {
}
args = {
packages = join(" ", [
contains(split(",", cargo_feat_sets[feat_set]), "io_uring")? "liburing-dev": "",
contains(split(",", cargo_feat_sets[feat_set]), "zstd_compression")? "libzstd-dev": "",
contains(split(",", cargo_feat_sets[feat_set]), "jemalloc")? "libjemalloc-dev": "",
contains(split(",", cargo_feat_sets[feat_set]), "bzip2_compression")? "libbz2-dev": "",
contains(split(",", cargo_feat_sets[feat_set]), "hardened_malloc")? "g++": "",
contains(split(",", cargo_feat_sets[feat_set]), "io_uring")? "liburing-dev": "",
contains(split(",", cargo_feat_sets[feat_set]), "jemalloc")? "libjemalloc-dev": "",
contains(split(",", cargo_feat_sets[feat_set]), "lz4_compression")? "liblz4-dev": "",
contains(split(",", cargo_feat_sets[feat_set]), "zstd_compression")? "libzstd-dev": "",
])
}
}
@@ -1609,18 +1717,18 @@ target "runtime" {
}
args = {
packages = join(" ", [
contains(split(",", cargo_feat_sets[feat_set]), "bzip2_compression")? "bzip2": "",
contains(split(",", cargo_feat_sets[feat_set]), "io_uring")? "liburing2": "",
contains(split(",", cargo_feat_sets[feat_set]), "zstd_compression")? "libzstd1": "",
contains(split(",", cargo_feat_sets[feat_set]), "jemalloc")? "libjemalloc2": "",
contains(split(",", cargo_feat_sets[feat_set]), "lz4_compression")? "liblz4-1": "",
contains(split(",", cargo_feat_sets[feat_set]), "zstd_compression")? "libzstd1": "",
])
}
}
base_pkgs = [
"adduser",
"bzip2",
"ca-certificates",
"gzip",
]
target "base" {
@@ -1639,8 +1747,8 @@ target "base" {
}
args = {
DEBIAN_FRONTEND="noninteractive"
var_lib_apt = "/var/lib/apt"
var_cache = "/var/cache"
var_lib_apt = "/var/lib/apt/${sys_name}/${sys_version}/${sys_target_triple(sys_target)}"
var_cache = "/var/cache/${sys_name}/${sys_version}/${sys_target_triple(sys_target)}"
packages = join(" ", base_pkgs)
}
}
@@ -1657,15 +1765,24 @@ target "system" {
]
target = "system"
output = ["type=cacheonly,compression=zstd,mode=min,compression-level=${cache_compress_level}"]
cache_to = ["type=local,compression=zstd,mode=min,compression-level=${cache_compress_level}"]
cache_to = ["type=local,compression=zstd,mode=max,compression-level=${cache_compress_level}"]
cache_from = ["type=local"]
dockerfile = "${docker_dir}/Dockerfile.system"
matrix = sys
context = "."
matrix = sys
platforms = (
sys_target_triple(sys_target) == "x86_64-linux-gnu"?
["linux/amd64/${sys_target_ver(sys_target)}"]:
sys_target_triple(sys_target) == "aarch64-linux-gnu"?
["linux/arm64"]:
["local"]
)
args = {
sys_name = sys_name
sys_version = sys_version
sys_target = sys_target
sys_triple = sys_target_triple(sys_target)
sys_isa = sys_target_isa(sys_target)
}
}
@@ -1674,6 +1791,33 @@ target "system" {
# Utils
#
function "sys_target_isa" {
params = [sys_target]
result = (
sys_target_ver(sys_target) != "v1"?
join("-",
[
replace(split("-", sys_target)[0], "_", "-"),
sys_target_ver(sys_target)
]):
replace(split("-", sys_target)[0], "_", "-")
)
}
function "sys_target_triple" {
params = [sys_target]
result = join("-", [
split("-", sys_target)[0],
split("-", sys_target)[2],
split("-", sys_target)[3],
])
}
function "sys_target_ver" {
params = [sys_target]
result = split("-", sys_target)[1]
}
function "elem_tag" {
params = [prefix, matrix, tag]
result = join(":", [elem(prefix, matrix), tag])
+10 -21
View File
@@ -14,8 +14,8 @@ default_feat_sets='["all"]'
default_rust_toolchains='["nightly"]'
default_rust_targets='["x86_64-unknown-linux-gnu"]'
default_sys_names='["debian"]'
default_sys_targets='["x86_64-linux-gnu"]'
default_sys_versions='["testing-slim"]'
default_sys_targets='["x86_64-v1-linux-gnu"]'
if test ! -z "$cargo_profile"; then
env_cargo_profiles="[\"${cargo_profile}\"]"
@@ -34,15 +34,15 @@ if test ! -z "$rust_toolchain"; then
fi
if test ! -z "$sys_name"; then
env_sys_name="[\"${sys_name}\"]"
env_sys_names="[\"${sys_name}\"]"
fi
if test ! -z "$sys_target"; then
env_sys_target="[\"${sys_target}\"]"
env_sys_targets="[\"${sys_target}\"]"
fi
if test ! -z "$sys_version"; then
env_sys_version="[\"${sys_version}\"]"
env_sys_versions="[\"${sys_version}\"]"
fi
set -a
@@ -56,23 +56,13 @@ sys_targets="${env_sys_targets:-$default_sys_targets}"
sys_versions="${env_sys_versions:-$default_sys_versions}"
docker_dir="$PWD/$BASEDIR"
runner_name=$(echo $RUNNER_NAME | cut -d"." -f1)
runner_num=$(echo $RUNNER_NAME | cut -d"." -f2)
builder_name="${GITHUB_ACTOR:-owo}"
toolchain_toml="$docker_dir/../rust-toolchain.toml"
rust_msrv=$(grep "channel = " "$toolchain_toml" | cut -d'=' -f2 | sed 's/\s"\|"$//g')
rocksdb_opt_level=3
rocksdb_portable=1
git_checkout="HEAD"
use_chef="true"
complement_count=1
complement_skip="TestPartialStateJoin.*"
complement_skip="${complement_skip}|TestRoomDeleteAlias/Pa.*/Can_delete_canonical_alias"
complement_skip="${complement_skip}|TestUnbanViaInvite.*"
complement_skip="${complement_skip}|TestRoomDeleteAlias/Pa.*/Regular_users_can_add_and_delete_aliases_when.*"
complement_skip="${complement_skip}|TestToDeviceMessagesOverFederation/stopped_server"
complement_skip="${complement_skip}|TestLogin/parallel/POST_/login_as_non-existing_user_is_rejected"
complement_skip="${complement_skip}|TestRoomState/Parallel/GET_/publicRooms_lists_newly-created_room"
complement_skip="${complement_skip}|TestThreadReceiptsInSyncMSC4102"
complement_run=".*"
set +a
###############################################################################
@@ -83,6 +73,7 @@ if test "$CI" = "true"; then
fi
args=""
args="$args --provenance=false"
args="$args --builder ${builder_name}"
#args="$args --set *.platform=${sys_platform}"
@@ -90,11 +81,9 @@ if test "$CI" = "true"; then
args="$args --allow=network.host"
fi
if test ! -z "$runner_num"; then
#cpu_num=$(expr $runner_num % $(nproc))
#args="$args --cpuset-cpus=${cpu_num}"
#args="$args --set *.args.nprocs=1"
# https://github.com/moby/buildkit/issues/1276
if test "$(uname)" = "Darwin"; then
nprocs=$(sysctl -n hw.logicalcpu)
args="$args --set *.args.nprocs=${nprocs}"
:
else
nprocs=$(nproc)
+49 -12
View File
@@ -12,9 +12,26 @@ default_feat_set="all"
default_rust_toolchain="nightly"
default_rust_target="x86_64-unknown-linux-gnu"
default_sys_name="debian"
default_sys_target="x86_64-linux-gnu"
default_sys_target="x86_64-v1-linux-gnu"
default_sys_version="testing-slim"
default_complement_verbose=0
default_complement_count=1
default_complement_parallel=1
default_complement_shuffle=0
default_complement_timeout="1h"
default_complement_run=".*"
run="${1:-$default_complement_run}"
skip=""
skip="${skip}TestToDeviceMessagesOverFederation/stopped_server"
skip="${skip}|TestToDeviceMessagesOverFederation/interrupted_connectivity"
skip="${skip}|TestRoomCreate/Parallel/POST_/createRoom_makes_a_room_with_a_topic_and_writes_rich_topic_representation"
skip="${skip}|TestRoomCreate/Parallel/POST_/createRoom_makes_a_room_with_a_topic_via_initial_state_overwritten_by_topic"
skip="${skip}|TestLogin/parallel/POST_/"
skip="${skip}|TestUnbanViaInvite"
skip="${skip}|TestRoomState/Parallel/GET_/publicRooms_lists_newly-created_room"
set -a
cargo_profile="${cargo_profile:-$default_cargo_profile}"
feat_set="${feat_set:-$default_feat_set}"
@@ -30,12 +47,21 @@ set +a
###############################################################################
envs=""
envs="$envs -e complement_verbose=${complement_verbose:-$default_complement_verbose}"
envs="$envs -e complement_count=${complement_count:-$default_complement_count}"
envs="$envs -e complement_parallel=${complement_parallel:-$default_complement_parallel}"
envs="$envs -e complement_shuffle=${complement_shuffle:-$default_complement_shuffle}"
envs="$envs -e complement_timeout=${complement_timeout:-$default_complement_timeout}"
envs="$envs -e complement_skip=${complement_skip:-$skip}"
envs="$envs -e complement_run=${1:-$default_complement_run}"
set -x
tester_image="complement-tester--${sys_name}--${sys_version}--${sys_target}"
testee_image="complement-testee--${cargo_profile}--${rust_toolchain}--${rust_target}--${feat_set}--${sys_name}--${sys_version}--${sys_target}"
name="complement_tester__${sys_name}__${sys_version}__${sys_target}"
sock="/var/run/docker.sock"
arg="--name $name -v $sock:$sock --network=host $tester_image ${testee_image}"
arg="--name $name -v $sock:$sock --network=host $envs $tester_image ${testee_image}"
set +x
if test "$CI_VERBOSE_ENV" = "true"; then
@@ -45,21 +71,32 @@ fi
docker rm -f "$name" 2>/dev/null
trap 'set +x; date; echo -e "\033[1;41;37mFAIL\033[0m"' ERR
arg="-d $arg"
cid=$(docker run $arg)
if test "$CI" = "true"; then
arg="-d $arg"
cid=$(docker run $arg)
else
arg="--rm -a stdout -a stderr $arg"
docker run $arg
exit $?
echo -n "$cid" > "$name"
fi
echo -n "$cid" > "$name"
output_src="$cid:/usr/src/complement/full_output.jsonl"
output_dst="complement.jsonl"
extract_output() {
docker cp "$output_src" "$output_dst"
}
trap 'docker container stop $cid; set +x; date; echo -e "\033[1;41;37mFAIL\033[0m"' INT
result_src="$cid:/usr/src/complement/new_results.jsonl"
result_dst="tests/test_results/complement/test_results.jsonl"
extract_results() {
docker cp "$result_src" "$result_dst"
}
trap 'extract_output; set +x; date; echo -e "\033[1;41;37mERROR\033[0m"' ERR
trap 'docker container stop $cid; extract_output' INT
docker logs -f "$cid"
docker wait "$cid" 2>/dev/null
echo -e "\033[1;42;30mPASS\033[0m"
extract_results
git diff -U0 --color --shortstat "$result_dst" | (grep "$run" || true)
git diff --quiet --exit-code "$result_dst"
echo -e "\033[1;42;30mACCEPT\033[0m"
+1
View File
@@ -10,6 +10,7 @@
- [Kubernetes](deploying/kubernetes.md)
- [Arch Linux](deploying/arch-linux.md)
- [Debian](deploying/debian.md)
- [Red Hat](deploying/redhat.md)
- [FreeBSD](deploying/freebsd.md)
- [TURN](turn.md)
- [Appservices](appservices.md)
+26 -6
View File
@@ -7,14 +7,20 @@ This chapter describes various ways to configure Tuwunel.
Tuwunel uses a config file for the majority of the settings, but also supports
setting individual config options via commandline.
Please refer to the [example config
file](./configuration/examples.md#example-configuration) for all of those
settings.
Please refer to the [example config file](./configuration/examples.md#example-configuration) for all of those settings.
The config file to use can be specified on the commandline when running
Tuwunel by specifying the `-c`, `--config` flag. Alternatively, you can use
the environment variable `TUWUNEL_CONFIG` to specify the config file to used.
Conduit's environment variables are supported for backwards compatibility.
Tuwunel by specifying the `-c`, `--config` flag. It is also possible to specify
more than one config file.
Alternatively, you can use the environment variable `TUWUNEL_CONFIG` to specify
the config file to used. Conduit's environment variables are supported for
backwards compatibility.
> [!IMPORTANT]
> It is bad practice to uncomment default options without changing them. Many
> defaults are updated by developers as features evolve and can be essential
> to expected server function.
## Option commandline flag
@@ -31,6 +37,20 @@ string. This does not apply to options that take booleans or numbers:
- `--option log=\"debug\"` works ✅
- `--option server_name='"example.com'"` works ✅
## Relevance of configuration settings
There is a specific sequence for reading and overwriting the settings. The
latest setting takes precedence and defines the configuration.
1. Set in `CONDUIT_CONFIG`.
2. Set in `CONDUWUIT_CONFIG`.
3. Set in `TUWUNEL_CONFIG`.
4. Set in the first config file on the command line (e.g. `-c config_file_1.toml`).
5. Set in the second config file on the command line (e.g. `-c config_file_2.toml`).
6. Set in any additional config file on the command line (e.g. `-c config_file_n.toml`).
7. Set within the options (again, the latest option in the list overrides).
## Execute commandline flag
Tuwunel supports running admin commands on startup using the commandline
+1
View File
@@ -6,5 +6,6 @@
- [Kubernetes](kubernetes.md)
- [Arch Linux](arch-linux.md)
- [Debian](debian.md)
- [Red Hat](redhat.md)
- [FreeBSD](freebsd.md)
- [Podman systemd](podman-systemd.md)
+1
View File
@@ -0,0 +1 @@
{{#include ../../rpm/README.md}}
Generated
+54 -71
View File
@@ -10,11 +10,11 @@
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1738524606,
"narHash": "sha256-hPYEJ4juK3ph7kbjbvv7PlU1D9pAkkhl+pwx8fZY53U=",
"lastModified": 1748532342,
"narHash": "sha256-CvaKOUq8G10sghKpZhEB2UYjJoWhEkrDFggDgi7piUI=",
"owner": "zhaofengli",
"repo": "attic",
"rev": "ff8a897d1f4408ebbf4d45fa9049c06b3e1e3f4e",
"rev": "ce9373715fe3fac7a174a65a7e6d6baeba8cb4f9",
"type": "github"
},
"original": {
@@ -32,11 +32,11 @@
"nixpkgs": "nixpkgs_4"
},
"locked": {
"lastModified": 1737621947,
"narHash": "sha256-8HFvG7fvIFbgtaYAY2628Tb89fA55nPm2jSiNs0/Cws=",
"lastModified": 1748883665,
"narHash": "sha256-R0W7uAg+BLoHjMRMQ8+oiSbTq8nkGz5RDpQ+ZfxxP3A=",
"owner": "cachix",
"repo": "cachix",
"rev": "f65a3cd5e339c223471e64c051434616e18cc4f5",
"rev": "f707778d902af4d62d8dd92c269f8e70de09acbe",
"type": "github"
},
"original": {
@@ -63,11 +63,11 @@
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1728672398,
"narHash": "sha256-KxuGSoVUFnQLB2ZcYODW7AVPAh9JqRlD5BrfsC/Q4qs=",
"lastModified": 1744206633,
"narHash": "sha256-pb5aYkE8FOoa4n123slgHiOf1UbNSnKe5pEZC+xXD5g=",
"owner": "cachix",
"repo": "cachix",
"rev": "aac51f698309fd0f381149214b7eee213c66ef0a",
"rev": "8a60090640b96f9df95d1ab99e5763a586be1404",
"type": "github"
},
"original": {
@@ -82,13 +82,13 @@
"locked": {
"lastModified": 1741891349,
"narHash": "sha256-YvrzOWcX7DH1drp5SGa+E/fc7wN3hqFtPbqPjZpOu1Q=",
"owner": "girlbossceo",
"owner": "matrix-construct",
"repo": "complement",
"rev": "e587b3df569cba411aeac7c20b6366d03c143745",
"type": "github"
},
"original": {
"owner": "girlbossceo",
"owner": "matrix-construct",
"ref": "main",
"repo": "complement",
"type": "github"
@@ -117,11 +117,11 @@
},
"crane_2": {
"locked": {
"lastModified": 1739936662,
"narHash": "sha256-x4syUjNUuRblR07nDPeLDP7DpphaBVbUaSoeZkFbGSk=",
"lastModified": 1748970125,
"narHash": "sha256-UDyigbDGv8fvs9aS95yzFfOKkEjx1LO3PL3DsKopohA=",
"owner": "ipetkov",
"repo": "crane",
"rev": "19de14aaeb869287647d9461cbd389187d8ecdb7",
"rev": "323b5746d89e04b22554b061522dfce9e4c49b18",
"type": "github"
},
"original": {
@@ -149,11 +149,11 @@
]
},
"locked": {
"lastModified": 1733323168,
"narHash": "sha256-d5DwB4MZvlaQpN6OQ4SLYxb5jA4UH5EtV5t5WOtjLPU=",
"lastModified": 1748273445,
"narHash": "sha256-5V0dzpNgQM0CHDsMzh+ludYeu1S+Y+IMjbaskSSdFh0=",
"owner": "cachix",
"repo": "devenv",
"rev": "efa9010b8b1cfd5dd3c7ed1e172a470c3b84a064",
"rev": "668a50d8b7bdb19a0131f53c9f6c25c9071e1ffb",
"type": "github"
},
"original": {
@@ -170,11 +170,11 @@
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1740724364,
"narHash": "sha256-D1jLIueJx1dPrP09ZZwTrPf4cubV+TsFMYbpYYTVj6A=",
"lastModified": 1749883145,
"narHash": "sha256-RlcGw3vAnbI3cfZn8aFaovNUd7312VZh+/FDWkqdA7E=",
"owner": "nix-community",
"repo": "fenix",
"rev": "edf7d9e431cda8782e729253835f178a356d3aab",
"rev": "a804172f150bcf81262655324e583bb0cd0f28dd",
"type": "github"
},
"original": {
@@ -203,11 +203,11 @@
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1733328505,
"narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=",
"lastModified": 1747046372,
"narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
"type": "github"
},
"original": {
@@ -219,11 +219,11 @@
"flake-compat_3": {
"flake": false,
"locked": {
"lastModified": 1733328505,
"narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=",
"lastModified": 1747046372,
"narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
"type": "github"
},
"original": {
@@ -306,15 +306,14 @@
"nixpkgs": [
"cachix",
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable_2"
]
},
"locked": {
"lastModified": 1733318908,
"narHash": "sha256-SVQVsbafSM1dJ4fpgyBqLZ+Lft+jcQuMtEL3lQWx2Sk=",
"lastModified": 1747372754,
"narHash": "sha256-2Y53NGIX2vxfie1rOW0Qb86vjRZ7ngizoo+bnXU9D9k=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "6f4e2a2112050951a314d2733a994fbab94864c6",
"rev": "80479b6ec16fefd9c1db3ea13aeb038c60530f46",
"type": "github"
},
"original": {
@@ -364,11 +363,11 @@
"liburing": {
"flake": false,
"locked": {
"lastModified": 1740613216,
"narHash": "sha256-NpPOBqNND3Qe9IwqYs0mJLGTmIx7e6FgUEBAnJ+1ZLA=",
"lastModified": 1749816983,
"narHash": "sha256-p5hXfDe53Y4MVwL2+wKZYpy4OPGvqFFnOEvkMsFAO6c=",
"owner": "axboe",
"repo": "liburing",
"rev": "e1003e496e66f9b0ae06674869795edf772d5500",
"rev": "ad83d3ab64894c16eaf21ef869656a5bddb93ca4",
"type": "github"
},
"original": {
@@ -401,11 +400,11 @@
]
},
"locked": {
"lastModified": 1727438425,
"narHash": "sha256-X8ES7I1cfNhR9oKp06F6ir4Np70WGZU5sfCOuNBEwMg=",
"lastModified": 1745930071,
"narHash": "sha256-bYyjarS3qSNqxfgc89IoVz8cAFDkF9yPE63EJr+h50s=",
"owner": "domenkozar",
"repo": "nix",
"rev": "f6c5ae4c1b2e411e6b1e6a8181cc84363d6a7546",
"rev": "b455edf3505f1bf0172b39a735caef94687d0d9c",
"type": "github"
},
"original": {
@@ -484,29 +483,13 @@
"type": "github"
}
},
"nixpkgs-stable_2": {
"locked": {
"lastModified": 1730741070,
"narHash": "sha256-edm8WG19kWozJ/GqyYx2VjW99EdhjKwbY3ZwdlPAAlo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d063c1dd113c91ab27959ba540c0d9753409edf3",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1730531603,
"narHash": "sha256-Dqg6si5CqIzm87sp57j5nTaeBbWhHFaVyG7V6L8k3lY=",
"lastModified": 1733212471,
"narHash": "sha256-M1+uCoV5igihRfcUKrr1riygbe73/dzNnzPsmaLCmpo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "7ffd9ae656aec493492b44d0ddfb28e79a1ea25d",
"rev": "55d15ad12a74eb7d4646254e13638ad0c4128776",
"type": "github"
},
"original": {
@@ -534,11 +517,11 @@
},
"nixpkgs_4": {
"locked": {
"lastModified": 1733212471,
"narHash": "sha256-M1+uCoV5igihRfcUKrr1riygbe73/dzNnzPsmaLCmpo=",
"lastModified": 1748190013,
"narHash": "sha256-R5HJFflOfsP5FBtk+zE8FpL8uqE7n62jqOsADvVshhE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "55d15ad12a74eb7d4646254e13638ad0c4128776",
"rev": "62b852f6c6742134ade1abdd2a21685fd617a291",
"type": "github"
},
"original": {
@@ -550,11 +533,11 @@
},
"nixpkgs_5": {
"locked": {
"lastModified": 1740547748,
"narHash": "sha256-Ly2fBL1LscV+KyCqPRufUBuiw+zmWrlJzpWOWbahplg=",
"lastModified": 1749871736,
"narHash": "sha256-K9yBph93OLTNw02Q6e9CYFGrUhvEXnh45vrZqIRWfvQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3a05eebede89661660945da1f151959900903b6a",
"rev": "6afe187897bef7933475e6af374c893f4c84a293",
"type": "github"
},
"original": {
@@ -567,16 +550,16 @@
"rocksdb": {
"flake": false,
"locked": {
"lastModified": 1741308171,
"narHash": "sha256-YdBvdQ75UJg5ffwNjxizpviCVwVDJnBkM8ZtGIduMgY=",
"owner": "girlbossceo",
"lastModified": 1749358049,
"narHash": "sha256-ZSjvAZBfZkJrBIpw8ANZMbJVb8AeuogvuAipGVE4Qe4=",
"owner": "matrix-construct",
"repo": "rocksdb",
"rev": "3ce04794bcfbbb0d2e6f81ae35fc4acf688b6986",
"rev": "cf7f65d0b377af019661c240f9165b3ef60640c3",
"type": "github"
},
"original": {
"owner": "girlbossceo",
"ref": "v9.11.1",
"owner": "matrix-construct",
"ref": "tuwunel-changes",
"repo": "rocksdb",
"type": "github"
}
@@ -599,11 +582,11 @@
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1740691488,
"narHash": "sha256-Fs6vBrByuiOf2WO77qeMDMTXcTGzrIMqLBv+lNeywwM=",
"lastModified": 1749829309,
"narHash": "sha256-t6x6/PKg8Shnkd3htrxf3WMgycfRLRWvN9JHAmGWf+s=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "fe3eda77d3a7ce212388bda7b6cec8bffcc077e5",
"rev": "a497f4114ccf24978accb56190e60d1e1659e0c7",
"type": "github"
},
"original": {
+43 -34
View File
@@ -2,14 +2,14 @@
inputs = {
attic.url = "github:zhaofengli/attic?ref=main";
cachix.url = "github:cachix/cachix?ref=master";
complement = { url = "github:girlbossceo/complement?ref=main"; flake = false; };
complement = { url = "github:matrix-construct/complement?ref=main"; flake = false; };
crane = { url = "github:ipetkov/crane?ref=master"; };
fenix = { url = "github:nix-community/fenix?ref=main"; inputs.nixpkgs.follows = "nixpkgs"; };
flake-compat = { url = "github:edolstra/flake-compat?ref=master"; flake = false; };
flake-utils.url = "github:numtide/flake-utils?ref=main";
nix-filter.url = "github:numtide/nix-filter?ref=main";
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixpkgs-unstable";
rocksdb = { url = "github:girlbossceo/rocksdb?ref=v9.11.1"; flake = false; };
rocksdb = { url = "github:matrix-construct/rocksdb?ref=tuwunel-changes"; flake = false; };
liburing = { url = "github:axboe/liburing?ref=master"; flake = false; };
};
@@ -26,7 +26,7 @@
file = ./rust-toolchain.toml;
# See also `rust-toolchain.toml`
sha256 = "sha256-X/4ZBHO3iW0fOenQ3foEvscgAPJYl2abspaBThDOukI=";
sha256 = "sha256-Qxt8XAuaUR2OMdKbN4u8dBJOhSHxS+uS06Wl9+flVEk=";
};
mkScope = pkgs: pkgs.lib.makeScope pkgs.newScope (self: {
@@ -53,7 +53,7 @@
};
rocksdb = (pkgs.rocksdb.override {
liburing = self.liburing;
}).overrideAttrs (old: {
}).overrideAttrs (final: old: {
src = inputs.rocksdb;
version = pkgs.lib.removePrefix
"v"
@@ -62,6 +62,15 @@
# we have this already at https://github.com/girlbossceo/rocksdb/commit/a935c0273e1ba44eacf88ce3685a9b9831486155
# unsetting this so i don't have to revert it and make this nix exclusive
patches = [];
postPatch =
pkgs.lib.optionalString (pkgs.lib.versionOlder final.version "8") ''
# Fix gcc-13 build failures due to missing <cstdint> and
# <system_error> includes, fixed upstream since 8.x
sed -e '1i #include <cstdint>' -i db/compaction/compaction_iteration_stats.h
sed -e '1i #include <cstdint>' -i table/block_based/data_block_hash_index.h
sed -e '1i #include <cstdint>' -i util/string_util.h
sed -e '1i #include <cstdint>' -i include/rocksdb/utilities/checkpoint.h
'';
cmakeFlags = pkgs.lib.subtractLists
[
# no real reason to have snappy or zlib, no one uses this
@@ -197,8 +206,8 @@
"jemalloc_stats"
# this is non-functional on nix for some reason
"hardened_malloc"
# conduwuit_mods is a development-only hot reload feature
"conduwuit_mods"
# tuwunel_mods is a development-only hot reload feature
"tuwunel_mods"
];
};
default-debug = scopeHost.main.override {
@@ -210,8 +219,8 @@
"experimental"
# this is non-functional on nix for some reason
"hardened_malloc"
# conduwuit_mods is a development-only hot reload feature
"conduwuit_mods"
# tuwunel_mods is a development-only hot reload feature
"tuwunel_mods"
];
};
# just a test profile used for things like CI and complement
@@ -223,8 +232,8 @@
"experimental"
# this is non-functional on nix for some reason
"hardened_malloc"
# conduwuit_mods is a development-only hot reload feature
"conduwuit_mods"
# tuwunel_mods is a development-only hot reload feature
"tuwunel_mods"
];
};
all-features = scopeHost.main.override {
@@ -238,8 +247,8 @@
"jemalloc_stats"
# this is non-functional on nix for some reason
"hardened_malloc"
# conduwuit_mods is a development-only hot reload feature
"conduwuit_mods"
# tuwunel_mods is a development-only hot reload feature
"tuwunel_mods"
];
};
all-features-debug = scopeHost.main.override {
@@ -252,8 +261,8 @@
"experimental"
# this is non-functional on nix for some reason
"hardened_malloc"
# conduwuit_mods is a development-only hot reload feature
"conduwuit_mods"
# tuwunel_mods is a development-only hot reload feature
"tuwunel_mods"
];
};
hmalloc = scopeHost.main.override { features = ["hardened_malloc"]; };
@@ -271,8 +280,8 @@
"jemalloc_stats"
# this is non-functional on nix for some reason
"hardened_malloc"
# conduwuit_mods is a development-only hot reload feature
"conduwuit_mods"
# tuwunel_mods is a development-only hot reload feature
"tuwunel_mods"
];
};
};
@@ -287,8 +296,8 @@
"experimental"
# this is non-functional on nix for some reason
"hardened_malloc"
# conduwuit_mods is a development-only hot reload feature
"conduwuit_mods"
# tuwunel_mods is a development-only hot reload feature
"tuwunel_mods"
];
};
};
@@ -352,8 +361,8 @@
"experimental"
# this is non-functional on nix for some reason
"hardened_malloc"
# conduwuit_mods is a development-only hot reload feature
"conduwuit_mods"
# tuwunel_mods is a development-only hot reload feature
"tuwunel_mods"
];
};
}
@@ -372,8 +381,8 @@
"jemalloc_stats"
# this is non-functional on nix for some reason
"hardened_malloc"
# conduwuit_mods is a development-only hot reload feature
"conduwuit_mods"
# tuwunel_mods is a development-only hot reload feature
"tuwunel_mods"
];
};
}
@@ -393,8 +402,8 @@
"jemalloc_stats"
# this is non-functional on nix for some reason
"hardened_malloc"
# conduwuit_mods is a development-only hot reload feature
"conduwuit_mods"
# tuwunel_mods is a development-only hot reload feature
"tuwunel_mods"
];
x86_64_haswell_target_optimised = (if (crossSystem == "x86_64-linux-gnu" || crossSystem == "x86_64-linux-musl") then true else false);
};
@@ -413,8 +422,8 @@
"experimental"
# this is non-functional on nix for some reason
"hardened_malloc"
# conduwuit_mods is a development-only hot reload feature
"conduwuit_mods"
# tuwunel_mods is a development-only hot reload feature
"tuwunel_mods"
];
};
}
@@ -471,8 +480,8 @@
"jemalloc_stats"
# this is non-functional on nix for some reason
"hardened_malloc"
# conduwuit_mods is a development-only hot reload feature
"conduwuit_mods"
# tuwunel_mods is a development-only hot reload feature
"tuwunel_mods"
];
};
};
@@ -494,8 +503,8 @@
"jemalloc_stats"
# this is non-functional on nix for some reason
"hardened_malloc"
# conduwuit_mods is a development-only hot reload feature
"conduwuit_mods"
# tuwunel_mods is a development-only hot reload feature
"tuwunel_mods"
];
x86_64_haswell_target_optimised = (if (crossSystem == "x86_64-linux-gnu" || crossSystem == "x86_64-linux-musl") then true else false);
};
@@ -516,8 +525,8 @@
"experimental"
# this is non-functional on nix for some reason
"hardened_malloc"
# conduwuit_mods is a development-only hot reload feature
"conduwuit_mods"
# tuwunel_mods is a development-only hot reload feature
"tuwunel_mods"
];
};
};
@@ -564,8 +573,8 @@
"jemalloc_stats"
# this is non-functional on nix for some reason
"hardened_malloc"
# conduwuit_mods is a development-only hot reload feature
"conduwuit_mods"
# tuwunel_mods is a development-only hot reload feature
"tuwunel_mods"
];
};
}));
+5 -3
View File
@@ -13,14 +13,16 @@ stdenv.mkDerivation {
root = inputs.self;
include = [
"book.toml"
"conduwuit-example.toml"
"tuwunel-example.toml"
"CODE_OF_CONDUCT.md"
"CONTRIBUTING.md"
"README.md"
"development.md"
"debian/conduwuit.service"
"debian/tuwunel.service"
"debian/README.md"
"arch/conduwuit.service"
"arch/tuwunel.service"
"rpm/tuwunel.service"
"rpm/README.md"
"docs"
"theme"
];
+4 -4
View File
@@ -15,7 +15,7 @@ LOG_FILE="${2:-complement_test_logs.jsonl}"
# A `.jsonl` file to write test results to
RESULTS_FILE="${3:-complement_test_results.jsonl}"
COMPLEMENT_BASE_IMAGE="${COMPLEMENT_BASE_IMAGE:-complement-conduwuit:main}"
COMPLEMENT_BASE_IMAGE="${COMPLEMENT_BASE_IMAGE:-complement-tuwunel:main}"
# Complement tests that are skipped due to flakiness/reliability issues or we don't implement such features and won't for a long time
SKIPPED_COMPLEMENT_TESTS='TestPartialStateJoin.*|TestRoomDeleteAlias/Parallel/Regular_users_can_add_and_delete_aliases_when_m.*|TestRoomDeleteAlias/Parallel/Can_delete_canonical_alias|TestUnbanViaInvite.*|TestRoomState/Parallel/GET_/publicRooms_lists.*"|TestRoomDeleteAlias/Parallel/Users_with_sufficient_power-level_can_delete_other.*'
@@ -35,20 +35,20 @@ toplevel="$(git rev-parse --show-toplevel)"
pushd "$toplevel" > /dev/null
if [ ! -f "complement_oci_image.tar.gz" ]; then
echo "building complement conduwuit image"
echo "building complement tuwunel image"
# if using macOS, use linux-complement
#bin/nix-build-and-cache just .#linux-complement
bin/nix-build-and-cache just .#complement
#nix build -L .#complement
echo "complement conduwuit image tar.gz built at \"result\""
echo "complement tuwunel image tar.gz built at \"result\""
echo "loading into docker"
docker load < result
popd > /dev/null
else
echo "skipping building a complement conduwuit image as complement_oci_image.tar.gz was already found, loading this"
echo "skipping building a complement tuwunel image as complement_oci_image.tar.gz was already found, loading this"
docker load < complement_oci_image.tar.gz
popd > /dev/null
+7 -7
View File
@@ -18,7 +18,7 @@ just() {
return
fi
# historical "conduit" store for compatibility purposes, same as conduwuit
# historical "conduit" store for compatibility purposes, same as tuwunel
nix run --inputs-from "$toplevel" attic -- \
login \
conduit \
@@ -52,26 +52,26 @@ just() {
withattic conduit || withattic conduit || withattic conduit || true
)
# main "conduwuit" store
# main "tuwunel" store
nix run --inputs-from "$toplevel" attic -- \
login \
conduwuit \
"${ATTIC_ENDPOINT:-https://attic.kennel.juneis.dog/conduwuit}" \
tuwunel \
"${ATTIC_ENDPOINT:-https://attic.kennel.juneis.dog/tuwunel}" \
"$ATTIC_TOKEN"
# Upload them to Attic (conduwuit store) and Cachix
# Upload them to Attic (tuwunel store) and Cachix
#
# Use `xargs` and a here-string because something would probably explode if
# several thousand arguments got passed to a command at once. Hopefully no
# store paths include a newline in them.
(
IFS=$'\n'
withattic conduwuit || withattic conduwuit || withattic conduwuit || true
withattic tuwunel || withattic tuwunel || withattic tuwunel || true
# push to cachix if available
if [ "$CACHIX_AUTH_TOKEN" ]; then
nix shell --inputs-from "$toplevel" cachix -c xargs \
cachix push conduwuit <<< "${cache[*]}"
cachix push tuwunel <<< "${cache[*]}"
fi
)
}
+6 -6
View File
@@ -31,7 +31,7 @@ let
"gzip_compression"
"zstd_compression"
# complement doesn't need hot reloading
"conduwuit_mods"
"tuwunel_mods"
# complement doesn't have URL preview media tests
"url_preview"
];
@@ -41,13 +41,13 @@ let
set -euxo pipefail
${lib.getExe' coreutils "env"} \
CONDUWUIT_SERVER_NAME="$SERVER_NAME" \
TUWUNEL_SERVER_NAME="$SERVER_NAME" \
${lib.getExe main'}
'';
in
dockerTools.buildImage {
name = "complement-conduwuit";
name = "complement-tuwunel";
tag = "main";
copyToRoot = buildEnv {
@@ -75,9 +75,9 @@ dockerTools.buildImage {
else [];
Env = [
"CONDUWUIT_TLS__KEY=${./private_key.key}"
"CONDUWUIT_TLS__CERTS=${./certificate.crt}"
"CONDUWUIT_CONFIG=${./config.toml}"
"TUWUNEL_TLS__KEY=${./private_key.key}"
"TUWUNEL_TLS__CERTS=${./certificate.crt}"
"TUWUNEL_CONFIG=${./config.toml}"
"RUST_BACKTRACE=full"
];
+3 -3
View File
@@ -25,8 +25,8 @@
"jemalloc_stats"
# this is non-functional on nix for some reason
"hardened_malloc"
# conduwuit_mods is a development-only hot reload feature
"conduwuit_mods"
# tuwunel_mods is a development-only hot reload feature
"tuwunel_mods"
]
, disable_release_max_log_level ? false
, features ? []
@@ -130,7 +130,7 @@ buildDepsOnlyEnv =
});
buildPackageEnv = {
CONDUWUIT_VERSION_EXTRA = inputs.self.shortRev or inputs.self.dirtyShortRev or "";
TUWUNEL_VERSION_EXTRA = inputs.self.shortRev or inputs.self.dirtyShortRev or "";
} // buildDepsOnlyEnv // {
# Only needed in static stdenv because these are transitive dependencies of rocksdb
CARGO_BUILD_RUSTFLAGS = buildDepsOnlyEnv.CARGO_BUILD_RUSTFLAGS
+36
View File
@@ -0,0 +1,36 @@
# Tuwunel for Red Hat
Information about downloading and deploying the Red Hat package. This may also be
referenced for other `rpm`-based distros such as CentOS.
### Installation
It is recommended to see the [generic deployment guide](../deploying/generic.md)
for further information if needed as usage of the RPM package is generally
related.
No `rpm` repository is currently offered yet, it is in the works/development.
### Configuration
When installed, the example config is placed at `/etc/tuwunel/tuwunel.toml`
as the default config. The config mentions things required to be changed before
starting.
You can tweak more detailed settings by uncommenting and setting the config
options in `/etc/tuwunel/tuwunel.toml`.
### Running
The package uses the [`tuwunel.service`](../configuration/examples.md#example-systemd-unit-file)
systemd unit file to start and stop Tuwunel. The binary is installed at `/usr/sbin/tuwunel`.
This package assumes by default that Tuwunel will be placed behind a reverse
proxy. The default config options apply (listening on `localhost` and TCP port
`8008`). Matrix federation requires a valid domain name and TLS, so you will
need to set up TLS certificates and renewal for it to work properly if you
intend to federate.
Consult various online documentation and guides on setting up a reverse proxy
and TLS. Caddy is documented at the [generic deployment guide](../deploying/generic.md#setting-up-the-reverse-proxy)
as it's the easiest and most user friendly.
+41
View File
@@ -0,0 +1,41 @@
#!/bin/sh
set -e
TUWUNEL_DATABASE_PATH=/var/lib/tuwunel
TUWUNEL_CONFIG_PATH=/etc/tuwunel
case "$1" in
configure)
# Create the `tuwunel` user if it does not exist yet.
if ! getent passwd tuwunel > /dev/null ; then
echo 'Adding system user for the tuwunel Matrix homeserver' 1>&2
useradd --system --user-group \
--create-home --home-dir "$TUWUNEL_DATABASE_PATH" \
--shell "/usr/sbin/nologin" \
tuwunel
fi
# Create the database path if it does not exist yet and fix up ownership
# and permissions for the config.
mkdir -v -p "$TUWUNEL_DATABASE_PATH"
# symlink the previous location for compatibility if it does not exist yet.
if ! test -L "/var/lib/matrix-conduit" ; then
ln -s -v "$TUWUNEL_DATABASE_PATH" "/var/lib/matrix-conduit"
fi
if ! test -L "/var/lib/conduwuit" ; then
ln -s -v "$TUWUNEL_DATABASE_PATH" "/var/lib/conduwuit"
fi
chown -v tuwunel:tuwunel -R "$TUWUNEL_DATABASE_PATH"
chown -v tuwunel:tuwunel -R "$TUWUNEL_CONFIG_PATH"
chmod -v 740 "$TUWUNEL_DATABASE_PATH"
echo ''
echo 'Make sure you edit the example config at /etc/tuwunel/tuwunel.toml before starting!'
echo 'To start the server, run: systemctl start tuwunel.service'
echo ''
;;
esac
+65
View File
@@ -0,0 +1,65 @@
[Unit]
Description=Tuwunel Matrix homeserver
Wants=network-online.target
After=network-online.target
Alias=matrix-tuwunel.service
Documentation=https://tuwunel.chat/
[Service]
DynamicUser=yes
User=tuwunel
Group=tuwunel
Type=notify
Environment="TUWUNEL_CONFIG=/etc/tuwunel/tuwunel.toml"
ExecStart=/usr/sbin/tuwunel
ReadWritePaths=/var/lib/tuwunel /etc/tuwunel
AmbientCapabilities=
CapabilityBoundingSet=
DevicePolicy=closed
LockPersonality=yes
MemoryDenyWriteExecute=yes
NoNewPrivileges=yes
#ProcSubset=pid
ProtectClock=yes
ProtectControlGroups=yes
ProtectHome=yes
ProtectHostname=yes
ProtectKernelLogs=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
ProtectProc=invisible
ProtectSystem=strict
PrivateDevices=yes
PrivateMounts=yes
PrivateTmp=yes
PrivateUsers=yes
PrivateIPC=yes
RemoveIPC=yes
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
RestrictNamespaces=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
SystemCallArchitectures=native
SystemCallFilter=@system-service @resources
SystemCallFilter=~@clock @debug @module @mount @reboot @swap @cpu-emulation @obsolete @timer @chown @setuid @privileged @keyring @ipc
SystemCallErrorNumber=EPERM
RuntimeDirectory=tuwunel
RuntimeDirectoryMode=0750
Restart=on-failure
RestartSec=5
TimeoutStopSec=2m
TimeoutStartSec=2m
StartLimitInterval=1m
StartLimitBurst=5
[Install]
WantedBy=multi-user.target
+1 -1
View File
@@ -9,7 +9,7 @@
# If you're having trouble making the relevant changes, bug a maintainer.
[toolchain]
channel = "1.86.0"
channel = "1.88.0"
profile = "minimal"
components = [
# For rust-analyzer
+13
View File
@@ -22,6 +22,11 @@ brotli_compression = [
"tuwunel-core/brotli_compression",
"tuwunel-service/brotli_compression",
]
bzip2_compression = [
"tuwunel-api/bzip2_compression",
"tuwunel-database/bzip2_compression",
"tuwunel-service/bzip2_compression",
]
gzip_compression = [
"tuwunel-api/gzip_compression",
"tuwunel-core/gzip_compression",
@@ -56,6 +61,11 @@ jemalloc_stats = [
"tuwunel-database/jemalloc_stats",
"tuwunel-service/jemalloc_stats",
]
lz4_compression = [
"tuwunel-api/lz4_compression",
"tuwunel-database/lz4_compression",
"tuwunel-service/lz4_compression",
]
release_max_log_level = [
"tuwunel-api/release_max_log_level",
"tuwunel-core/release_max_log_level",
@@ -74,6 +84,7 @@ zstd_compression = [
]
[dependencies]
base64.workspace = true
clap.workspace = true
tuwunel-api.workspace = true
tuwunel-core.workspace = true
@@ -81,9 +92,11 @@ tuwunel-database.workspace = true
tuwunel-macros.workspace = true
tuwunel-service.workspace = true
const-str.workspace = true
ctor.workspace = true
futures.workspace = true
log.workspace = true
ruma.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_yaml.workspace = true
tokio.workspace = true
+76 -3
View File
@@ -2,6 +2,7 @@ use std::{
collections::HashMap,
fmt::Write,
iter::once,
str::FromStr,
time::{Instant, SystemTime},
};
@@ -11,9 +12,10 @@ use ruma::{
OwnedRoomOrAliasId, OwnedServerName, RoomId, RoomVersionId,
api::federation::event::get_room_state, events::AnyStateEvent, serde::Raw,
};
use serde::Serialize;
use tracing_subscriber::EnvFilter;
use tuwunel_core::{
Err, Result, debug_error, err, info,
Err, Result, debug_error, err, info, jwt,
matrix::{
Event,
pdu::{PduEvent, PduId, RawPduId},
@@ -22,6 +24,7 @@ use tuwunel_core::{
utils::{
stream::{IterStream, ReadyExt},
string::EMPTY,
time::now_secs,
},
warn,
};
@@ -635,7 +638,7 @@ pub(super) async fn force_set_room_state_from_server(
self.services
.rooms
.outlier
.timeline
.add_pdu_outlier(&event_id, &value);
if let Some(state_key) = &pdu.state_key {
@@ -665,7 +668,7 @@ pub(super) async fn force_set_room_state_from_server(
self.services
.rooms
.outlier
.timeline
.add_pdu_outlier(&event_id, &value);
}
@@ -975,3 +978,73 @@ pub(super) async fn trim_memory(&self) -> Result {
writeln!(self, "done").await
}
#[admin_command]
pub(super) async fn create_jwt(
&self,
user: String,
exp_from_now: Option<u64>,
nbf_from_now: Option<u64>,
issuer: Option<String>,
audience: Option<String>,
) -> Result {
use jwt::{Algorithm, EncodingKey, Header, encode};
#[derive(Serialize)]
struct Claim {
sub: String,
iss: String,
aud: String,
exp: usize,
nbf: usize,
}
let config = &self.services.config.jwt;
if config.format.as_str() != "HMAC" {
return Err!("This command only supports HMAC key format, not {}.", config.format);
}
let key = EncodingKey::from_secret(config.key.as_ref());
let alg = Algorithm::from_str(config.algorithm.as_str()).map_err(|e| {
err!(Config("jwt.algorithm", "JWT algorithm is not recognized or configured {e}"))
})?;
let header = Header { alg, ..Default::default() };
let claim = Claim {
sub: user,
iss: issuer.unwrap_or_default(),
aud: audience.unwrap_or_default(),
exp: exp_from_now
.and_then(|val| now_secs().checked_add(val))
.map(TryInto::try_into)
.and_then(Result::ok)
.unwrap_or(usize::MAX),
nbf: nbf_from_now
.and_then(|val| now_secs().checked_add(val))
.map(TryInto::try_into)
.and_then(Result::ok)
.unwrap_or(0),
};
encode(&header, &claim, &key)
.map_err(|e| err!("Failed to encode JWT: {e}"))
.map(async |token| self.write_str(&token).await)?
.await
}
#[admin_command]
pub(super) async fn resync_database(&self) -> Result {
if !self.services.db.is_secondary() {
return Err!("Not a secondary instance.");
}
self.services
.db
.db
.update()
.map_err(|e| err!("Failed to update from primary: {e:?}"))
}
+25
View File
@@ -234,6 +234,31 @@ pub(super) enum DebugCommand {
level: Option<i32>,
},
/// - Create a JWT token for login
CreateJwt {
/// Localpart of the user's MXID
user: String,
/// Set expiration time in seconds from now.
#[arg(long)]
exp_from_now: Option<u64>,
/// Set not-before time in seconds from now.
#[arg(long)]
nbf_from_now: Option<u64>,
/// Claim an issuer.
#[arg(long)]
issuer: Option<String>,
/// Claim an audience.
#[arg(long)]
audience: Option<String>,
},
/// - Synchronize database with primary (secondary only)
ResyncDatabase,
/// - Developer test stubs
#[command(subcommand)]
#[allow(non_snake_case)]
+1 -21
View File
@@ -1,5 +1,3 @@
use std::fmt::Write;
use futures::StreamExt;
use ruma::{OwnedRoomId, OwnedServerName, OwnedUserId};
use tuwunel_core::{Err, Result};
@@ -26,25 +24,7 @@ pub(super) async fn enable_room(&self, room_id: OwnedRoomId) -> Result {
#[admin_command]
pub(super) async fn incoming_federation(&self) -> Result {
let msg = {
let map = self
.services
.rooms
.event_handler
.federation_handletime
.read()
.expect("locked");
let mut msg = format!("Handling {} incoming pdus:\n", map.len());
for (r, (e, i)) in map.iter() {
let elapsed = i.elapsed();
writeln!(msg, "{} {}: {}m{}s", r, e, elapsed.as_secs() / 60, elapsed.as_secs() % 60)?;
}
msg
};
self.write_str(&msg).await
Err!("This command is temporarily disabled")
}
#[admin_command]
+1 -1
View File
@@ -32,7 +32,7 @@ pub(super) async fn process(subcommand: GlobalsCommand, context: &Context<'_>) -
},
| GlobalsCommand::CurrentCount => {
let timer = tokio::time::Instant::now();
let results = services.globals.db.current_count();
let results = services.globals.current_count();
let query_time = timer.elapsed();
write!(context, "Query completed in {query_time:?}:\n\n```rs\n{results:#?}\n```")
+5 -2
View File
@@ -19,6 +19,9 @@ pub(crate) enum PresenceCommand {
PresenceSince {
/// UNIX timestamp since (u64)
since: u64,
/// Upper-bound of since
to: Option<u64>,
},
}
@@ -34,11 +37,11 @@ pub(super) async fn process(subcommand: PresenceCommand, context: &Context<'_>)
write!(context, "Query completed in {query_time:?}:\n\n```rs\n{results:#?}\n```")
},
| PresenceCommand::PresenceSince { since } => {
| PresenceCommand::PresenceSince { since, to } => {
let timer = tokio::time::Instant::now();
let results: Vec<(_, _, _)> = services
.presence
.presence_since(since)
.presence_since(since, to)
.map(|(user_id, count, bytes)| (user_id.to_owned(), count, bytes.to_vec()))
.collect()
.await;
+13 -2
View File
@@ -1,5 +1,6 @@
use std::{borrow::Cow, collections::BTreeMap, ops::Deref, sync::Arc};
use base64::prelude::*;
use clap::Subcommand;
use futures::{FutureExt, Stream, StreamExt, TryStreamExt};
use tokio::time::Instant;
@@ -30,6 +31,10 @@ pub(crate) enum RawCommand {
/// Key
key: String,
/// Encode as base64
#[arg(long, short)]
base64: bool,
},
/// - Raw database delete (for string keys)
@@ -421,13 +426,19 @@ pub(super) async fn raw_del(&self, map: String, key: String) -> Result {
}
#[admin_command]
pub(super) async fn raw_get(&self, map: String, key: String) -> Result {
pub(super) async fn raw_get(&self, map: String, key: String, base64: bool) -> Result {
let map = self.services.db.get(&map)?;
let timer = Instant::now();
let handle = map.get(&key).await?;
let query_time = timer.elapsed();
let result = String::from_utf8_lossy(&handle);
let result = if base64 {
BASE64_STANDARD.encode(&handle)
} else {
String::from_utf8_lossy(&handle).to_string()
};
self.write_str(&format!("Query completed in {query_time:?}:\n\n```rs\n{result:?}\n```"))
.await
}
+2 -2
View File
@@ -19,7 +19,7 @@ pub(super) async fn list_rooms(
.rooms
.metadata
.iter_ids()
.filter_map(|room_id| async move {
.filter_map(async |room_id| {
(!exclude_disabled
|| !self
.services
@@ -29,7 +29,7 @@ pub(super) async fn list_rooms(
.await)
.then_some(room_id)
})
.filter_map(|room_id| async move {
.filter_map(async |room_id| {
(!exclude_banned
|| !self
.services
+6 -2
View File
@@ -1,7 +1,7 @@
use clap::Subcommand;
use futures::StreamExt;
use ruma::OwnedRoomId;
use tuwunel_core::{Err, Result};
use tuwunel_core::Result;
use crate::{Context, PAGE_SIZE, get_room_info};
@@ -57,7 +57,11 @@ pub(super) async fn process(command: RoomDirectoryCommand, context: &Context<'_>
.collect();
if rooms.is_empty() {
return Err!("No more rooms.");
context
.write_str("No rooms are published.")
.await?;
return Ok(());
}
let body = rooms
+1 -1
View File
@@ -47,7 +47,7 @@ async fn list_joined_members(&self, room_id: OwnedRoomId, local_only: bool) -> R
.unwrap_or(true)
})
.map(ToOwned::to_owned)
.filter_map(|user_id| async move {
.filter_map(async |user_id| {
Some((
self.services
.users
+2 -2
View File
@@ -179,7 +179,7 @@ async fn ban_room(&self, room: OwnedRoomOrAliasId) -> Result {
.alias
.local_aliases_for_room(&room_id)
.map(ToOwned::to_owned)
.for_each(|local_alias| async move {
.for_each(async |local_alias| {
self.services
.rooms
.alias
@@ -363,7 +363,7 @@ async fn ban_list_of_rooms(&self) -> Result {
.alias
.local_aliases_for_room(&room_id)
.map(ToOwned::to_owned)
.for_each(|local_alias| async move {
.for_each(async |local_alias| {
self.services
.rooms
.alias
+8 -2
View File
@@ -236,7 +236,10 @@ pub(super) async fn deactivate(&self, no_leave_rooms: bool, user_id: String) ->
.collect()
.await;
full_user_deactivate(self.services, &user_id, &all_joined_rooms).await?;
full_user_deactivate(self.services, &user_id, &all_joined_rooms)
.boxed()
.await?;
update_displayname(self.services, &user_id, None, &all_joined_rooms).await;
update_avatar_url(self.services, &user_id, None, None, &all_joined_rooms).await;
leave_all_rooms(self.services, &user_id).await;
@@ -358,7 +361,10 @@ pub(super) async fn deactivate_all(&self, no_leave_rooms: bool, force: bool) ->
.collect()
.await;
full_user_deactivate(self.services, &user_id, &all_joined_rooms).await?;
full_user_deactivate(self.services, &user_id, &all_joined_rooms)
.boxed()
.await?;
update_displayname(self.services, &user_id, None, &all_joined_rooms).await;
update_avatar_url(self.services, &user_id, None, None, &all_joined_rooms)
.await;
+9 -2
View File
@@ -22,6 +22,9 @@ brotli_compression = [
"tuwunel-service/brotli_compression",
"reqwest/brotli",
]
bzip2_compression = [
"tuwunel-service/bzip2_compression",
]
element_hacks = [
"tuwunel-service/element_hacks",
]
@@ -52,6 +55,9 @@ jemalloc_stats = [
ldap = [
"tuwunel-service/ldap",
]
lz4_compression = [
"tuwunel-service/lz4_compression",
]
release_max_log_level = [
"tuwunel-core/release_max_log_level",
"tuwunel-service/release_max_log_level",
@@ -73,9 +79,8 @@ axum-extra.workspace = true
axum.workspace = true
base64.workspace = true
bytes.workspace = true
tuwunel-core.workspace = true
tuwunel-service.workspace = true
const-str.workspace = true
ctor.workspace = true
futures.workspace = true
hmac.workspace = true
http.workspace = true
@@ -93,6 +98,8 @@ serde.workspace = true
sha1.workspace = true
tokio.workspace = true
tracing.workspace = true
tuwunel-core.workspace = true
tuwunel-service.workspace = true
[lints]
workspace = true
+5 -589
View File
@@ -1,29 +1,23 @@
use std::fmt::Write;
use axum::extract::State;
use axum_client_ip::InsecureClientIp;
use futures::{FutureExt, StreamExt};
use register::RegistrationKind;
use ruma::{
OwnedRoomId, UserId,
api::client::{
account::{
ThirdPartyIdRemovalStatus, change_password, check_registration_token_validity,
deactivate, get_3pids, get_username_availability,
register::{self, LoginType},
ThirdPartyIdRemovalStatus, change_password, deactivate, get_3pids,
request_3pid_management_token_via_email, request_3pid_management_token_via_msisdn,
whoami,
},
uiaa::{AuthFlow, AuthType, UiaaInfo},
},
events::{
GlobalAccountDataEventType, StateEventType,
StateEventType,
room::power_levels::{RoomPowerLevels, RoomPowerLevelsEventContent},
},
push,
};
use tuwunel_core::{
Err, Error, Result, debug_info, err, error, info, is_equal_to,
Err, Error, Result, err, info,
matrix::{Event, pdu::PduBuilder},
utils,
utils::{ReadyExt, stream::BroadbandExt},
@@ -31,570 +25,9 @@ use tuwunel_core::{
};
use tuwunel_service::Services;
use super::{DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH, join_room_by_id_helper};
use super::SESSION_ID_LENGTH;
use crate::Ruma;
const RANDOM_USER_ID_LENGTH: usize = 10;
/// # `GET /_matrix/client/v3/register/available`
///
/// Checks if a username is valid and available on this server.
///
/// Conditions for returning true:
/// - The user id is not historical
/// - The server name of the user id matches this server
/// - No user or appservice on this server already claimed this username
///
/// Note: This will not reserve the username, so the username might become
/// invalid when trying to register
#[tracing::instrument(skip_all, fields(%client), name = "register_available")]
pub(crate) async fn get_register_available_route(
State(services): State<crate::State>,
InsecureClientIp(client): InsecureClientIp,
body: Ruma<get_username_availability::v3::Request>,
) -> Result<get_username_availability::v3::Response> {
// workaround for https://github.com/matrix-org/matrix-appservice-irc/issues/1780 due to inactivity of fixing the issue
let is_matrix_appservice_irc = body
.appservice_info
.as_ref()
.is_some_and(|appservice| {
appservice.registration.id == "irc"
|| appservice
.registration
.id
.contains("matrix-appservice-irc")
|| appservice
.registration
.id
.contains("matrix_appservice_irc")
});
if services
.globals
.forbidden_usernames()
.is_match(&body.username)
{
return Err!(Request(Forbidden("Username is forbidden")));
}
// don't force the username lowercase if it's from matrix-appservice-irc
let body_username = if is_matrix_appservice_irc {
body.username.clone()
} else {
body.username.to_lowercase()
};
// Validate user id
let user_id =
match UserId::parse_with_server_name(&body_username, services.globals.server_name()) {
| Ok(user_id) => {
if let Err(e) = user_id.validate_strict() {
// unless the username is from the broken matrix appservice IRC bridge, we
// should follow synapse's behaviour on not allowing things like spaces
// and UTF-8 characters in usernames
if !is_matrix_appservice_irc {
return Err!(Request(InvalidUsername(debug_warn!(
"Username {body_username} contains disallowed characters or spaces: \
{e}"
))));
}
}
user_id
},
| Err(e) => {
return Err!(Request(InvalidUsername(debug_warn!(
"Username {body_username} is not valid: {e}"
))));
},
};
// Check if username is creative enough
if services.users.exists(&user_id).await {
return Err!(Request(UserInUse("User ID is not available.")));
}
if let Some(ref info) = body.appservice_info {
if !info.is_user_match(&user_id) {
return Err!(Request(Exclusive("Username is not in an appservice namespace.")));
}
}
if services
.appservice
.is_exclusive_user_id(&user_id)
.await
{
return Err!(Request(Exclusive("Username is reserved by an appservice.")));
}
Ok(get_username_availability::v3::Response { available: true })
}
/// # `POST /_matrix/client/v3/register`
///
/// Register an account on this homeserver.
///
/// You can use [`GET
/// /_matrix/client/v3/register/available`](fn.get_register_available_route.
/// html) to check if the user id is valid and available.
///
/// - Only works if registration is enabled
/// - If type is guest: ignores all parameters except
/// initial_device_display_name
/// - If sender is not appservice: Requires UIAA (but we only use a dummy stage)
/// - If type is not guest and no username is given: Always fails after UIAA
/// check
/// - Creates a new account and populates it with default account data
/// - If `inhibit_login` is false: Creates a device and returns device id and
/// access_token
#[allow(clippy::doc_markdown)]
#[tracing::instrument(skip_all, fields(%client), name = "register")]
pub(crate) async fn register_route(
State(services): State<crate::State>,
InsecureClientIp(client): InsecureClientIp,
body: Ruma<register::v3::Request>,
) -> Result<register::v3::Response> {
let is_guest = body.kind == RegistrationKind::Guest;
let emergency_mode_enabled = services.config.emergency_password.is_some();
if !services.config.allow_registration && body.appservice_info.is_none() {
match (body.username.as_ref(), body.initial_device_display_name.as_ref()) {
| (Some(username), Some(device_display_name)) => {
info!(
%is_guest,
user = %username,
device_name = %device_display_name,
"Rejecting registration attempt as registration is disabled"
);
},
| (Some(username), _) => {
info!(
%is_guest,
user = %username,
"Rejecting registration attempt as registration is disabled"
);
},
| (_, Some(device_display_name)) => {
info!(
%is_guest,
device_name = %device_display_name,
"Rejecting registration attempt as registration is disabled"
);
},
| (None, _) => {
info!(
%is_guest,
"Rejecting registration attempt as registration is disabled"
);
},
}
return Err!(Request(Forbidden("Registration has been disabled.")));
}
if is_guest
&& (!services.config.allow_guest_registration
|| (services.config.allow_registration
&& services.globals.registration_token.is_some()))
{
info!(
"Guest registration disabled / registration enabled with token configured, \
rejecting guest registration attempt, initial device name: \"{}\"",
body.initial_device_display_name
.as_deref()
.unwrap_or("")
);
return Err!(Request(GuestAccessForbidden("Guest registration is disabled.")));
}
// forbid guests from registering if there is not a real admin user yet. give
// generic user error.
if is_guest && services.users.count().await < 2 {
warn!(
"Guest account attempted to register before a real admin user has been registered, \
rejecting registration. Guest's initial device name: \"{}\"",
body.initial_device_display_name
.as_deref()
.unwrap_or("")
);
return Err!(Request(Forbidden("Registration is temporarily disabled.")));
}
let user_id = match (body.username.as_ref(), is_guest) {
| (Some(username), false) => {
// workaround for https://github.com/matrix-org/matrix-appservice-irc/issues/1780 due to inactivity of fixing the issue
let is_matrix_appservice_irc =
body.appservice_info
.as_ref()
.is_some_and(|appservice| {
appservice.registration.id == "irc"
|| appservice
.registration
.id
.contains("matrix-appservice-irc")
|| appservice
.registration
.id
.contains("matrix_appservice_irc")
});
if services
.globals
.forbidden_usernames()
.is_match(username)
&& !emergency_mode_enabled
{
return Err!(Request(Forbidden("Username is forbidden")));
}
// don't force the username lowercase if it's from matrix-appservice-irc
let body_username = if is_matrix_appservice_irc {
username.clone()
} else {
username.to_lowercase()
};
let proposed_user_id = match UserId::parse_with_server_name(
&body_username,
services.globals.server_name(),
) {
| Ok(user_id) => {
if let Err(e) = user_id.validate_strict() {
// unless the username is from the broken matrix appservice IRC bridge, or
// we are in emergency mode, we should follow synapse's behaviour on
// not allowing things like spaces and UTF-8 characters in usernames
if !is_matrix_appservice_irc && !emergency_mode_enabled {
return Err!(Request(InvalidUsername(debug_warn!(
"Username {body_username} contains disallowed characters or \
spaces: {e}"
))));
}
}
user_id
},
| Err(e) => {
return Err!(Request(InvalidUsername(debug_warn!(
"Username {body_username} is not valid: {e}"
))));
},
};
if services.users.exists(&proposed_user_id).await {
return Err!(Request(UserInUse("User ID is not available.")));
}
proposed_user_id
},
| _ => loop {
let proposed_user_id = UserId::parse_with_server_name(
utils::random_string(RANDOM_USER_ID_LENGTH).to_lowercase(),
services.globals.server_name(),
)
.unwrap();
if !services.users.exists(&proposed_user_id).await {
break proposed_user_id;
}
},
};
if body.body.login_type == Some(LoginType::ApplicationService) {
match body.appservice_info {
| Some(ref info) =>
if !info.is_user_match(&user_id) && !emergency_mode_enabled {
return Err!(Request(Exclusive(
"Username is not in an appservice namespace."
)));
},
| _ => {
return Err!(Request(MissingToken("Missing appservice token.")));
},
}
} else if services
.appservice
.is_exclusive_user_id(&user_id)
.await && !emergency_mode_enabled
{
return Err!(Request(Exclusive("Username is reserved by an appservice.")));
}
// UIAA
let mut uiaainfo;
let skip_auth = if services.globals.registration_token.is_some() {
// Registration token required
uiaainfo = UiaaInfo {
flows: vec![AuthFlow {
stages: vec![AuthType::RegistrationToken],
}],
completed: Vec::new(),
params: Box::default(),
session: None,
auth_error: None,
};
body.appservice_info.is_some()
} else {
// No registration token necessary, but clients must still go through the flow
uiaainfo = UiaaInfo {
flows: vec![AuthFlow { stages: vec![AuthType::Dummy] }],
completed: Vec::new(),
params: Box::default(),
session: None,
auth_error: None,
};
body.appservice_info.is_some() || is_guest
};
if !skip_auth {
match &body.auth {
| Some(auth) => {
let (worked, uiaainfo) = services
.uiaa
.try_auth(
&UserId::parse_with_server_name("", services.globals.server_name())
.unwrap(),
"".into(),
auth,
&uiaainfo,
)
.await?;
if !worked {
return Err(Error::Uiaa(uiaainfo));
}
// Success!
},
| _ => match body.json_body {
| Some(ref json) => {
uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH));
services.uiaa.create(
&UserId::parse_with_server_name("", services.globals.server_name())
.unwrap(),
"".into(),
&uiaainfo,
json,
);
return Err(Error::Uiaa(uiaainfo));
},
| _ => {
return Err!(Request(NotJson("JSON body is not valid")));
},
},
}
}
let password = if is_guest { None } else { body.password.as_deref() };
// Create user
services
.users
.create(&user_id, password, None)
.await?;
// Default to pretty displayname
let mut displayname = user_id.localpart().to_owned();
// If `new_user_displayname_suffix` is set, registration will push whatever
// content is set to the user's display name with a space before it
if !services
.globals
.new_user_displayname_suffix()
.is_empty()
&& body.appservice_info.is_none()
{
write!(displayname, " {}", services.server.config.new_user_displayname_suffix)?;
}
services
.users
.set_displayname(&user_id, Some(displayname.clone()));
// Initial account data
services
.account_data
.update(
None,
&user_id,
GlobalAccountDataEventType::PushRules
.to_string()
.into(),
&serde_json::to_value(ruma::events::push_rules::PushRulesEvent {
content: ruma::events::push_rules::PushRulesEventContent {
global: push::Ruleset::server_default(&user_id),
},
})?,
)
.await?;
if (!is_guest && body.inhibit_login)
|| body
.appservice_info
.as_ref()
.is_some_and(|appservice| appservice.registration.device_management)
{
return Ok(register::v3::Response {
access_token: None,
user_id,
device_id: None,
refresh_token: None,
expires_in: None,
});
}
// Generate new device id if the user didn't specify one
let device_id = if is_guest { None } else { body.device_id.clone() }
.unwrap_or_else(|| utils::random_string(DEVICE_ID_LENGTH).into());
// Generate new token for the device
let token = utils::random_string(TOKEN_LENGTH);
// Create device for this account
services
.users
.create_device(
&user_id,
&device_id,
&token,
body.initial_device_display_name.clone(),
Some(client.to_string()),
)
.await?;
debug_info!(%user_id, %device_id, "User account was created");
let device_display_name = body
.initial_device_display_name
.as_deref()
.unwrap_or("");
// log in conduit admin channel if a non-guest user registered
if body.appservice_info.is_none() && !is_guest {
if !device_display_name.is_empty() {
let notice = format!(
"New user \"{user_id}\" registered on this server from IP {client} and device \
display name \"{device_display_name}\""
);
info!("{notice}");
if services.server.config.admin_room_notices {
services.admin.notice(&notice).await;
}
} else {
let notice = format!("New user \"{user_id}\" registered on this server.");
info!("{notice}");
if services.server.config.admin_room_notices {
services.admin.notice(&notice).await;
}
}
}
// log in conduit admin channel if a guest registered
if body.appservice_info.is_none() && is_guest && services.config.log_guest_registrations {
debug_info!("New guest user \"{user_id}\" registered on this server.");
if !device_display_name.is_empty() {
if services.server.config.admin_room_notices {
services
.admin
.notice(&format!(
"Guest user \"{user_id}\" with device display name \
\"{device_display_name}\" registered on this server from IP {client}"
))
.await;
}
} else {
#[allow(clippy::collapsible_else_if)]
if services.server.config.admin_room_notices {
services
.admin
.notice(&format!(
"Guest user \"{user_id}\" with no device display name registered on \
this server from IP {client}",
))
.await;
}
}
}
// If this is the first real user, grant them admin privileges except for guest
// users
// Note: the server user is generated first
if !is_guest {
if let Ok(admin_room) = services.admin.get_admin_room().await {
if services
.rooms
.state_cache
.room_joined_count(&admin_room)
.await
.is_ok_and(is_equal_to!(1))
{
services.admin.make_user_admin(&user_id).await?;
warn!("Granting {user_id} admin privileges as the first user");
}
}
}
if body.appservice_info.is_none()
&& !services.server.config.auto_join_rooms.is_empty()
&& (services.config.allow_guests_auto_join_rooms || !is_guest)
{
for room in &services.server.config.auto_join_rooms {
let Ok(room_id) = services.rooms.alias.resolve(room).await else {
error!(
"Failed to resolve room alias to room ID when attempting to auto join \
{room}, skipping"
);
continue;
};
if !services
.rooms
.state_cache
.server_in_room(services.globals.server_name(), &room_id)
.await
{
warn!(
"Skipping room {room} to automatically join as we have never joined before."
);
continue;
}
if let Some(room_server_name) = room.server_name() {
match join_room_by_id_helper(
&services,
&user_id,
&room_id,
Some("Automatically joining this room upon registration".to_owned()),
&[services.globals.server_name().to_owned(), room_server_name.to_owned()],
None,
&body.appservice_info,
)
.boxed()
.await
{
| Err(e) => {
// don't return this error so we don't fail registrations
error!(
"Failed to automatically join room {room} for user {user_id}: {e}"
);
},
| _ => {
info!("Automatically joined room {room} for user {user_id}");
},
}
}
}
}
Ok(register::v3::Response {
access_token: Some(token),
user_id,
device_id: Some(device_id),
refresh_token: None,
expires_in: None,
})
}
/// # `POST /_matrix/client/r0/account/password`
///
/// Changes the password of this account.
@@ -861,23 +294,6 @@ pub(crate) async fn request_3pid_management_token_via_msisdn_route(
Err!(Request(ThreepidDenied("Third party identifiers are not implemented")))
}
/// # `GET /_matrix/client/v1/register/m.login.registration_token/validity`
///
/// Checks if the provided registration token is valid at the time of checking
///
/// Currently does not have any ratelimiting, and this isn't very practical as
/// there is only one registration token allowed.
pub(crate) async fn check_registration_token_validity(
State(services): State<crate::State>,
body: Ruma<check_registration_token_validity::v1::Request>,
) -> Result<check_registration_token_validity::v1::Response> {
let Some(reg_token) = services.globals.registration_token.clone() else {
return Err!(Request(Forbidden("Server does not allow token registration")));
};
Ok(check_registration_token_validity::v1::Response { valid: reg_token == body.token })
}
/// Runs through all the deactivation steps:
///
/// - Mark as deactivated
@@ -889,7 +305,7 @@ pub async fn full_user_deactivate(
services: &Services,
user_id: &UserId,
all_joined_rooms: &[OwnedRoomId],
) -> Result<()> {
) -> Result {
services
.users
.deactivate_account(user_id)
+1 -1
View File
@@ -132,7 +132,7 @@ pub(crate) async fn get_context_route(
let state_at = events_after
.last()
.map(ref_at!(1))
.map_or(body.event_id.as_ref(), |pdu| pdu.event_id.as_ref());
.map_or_else(|| body.event_id.as_ref(), |pdu| pdu.event_id.as_ref());
let state_ids = services
.rooms
+2 -1
View File
@@ -100,7 +100,8 @@ pub(crate) async fn update_device_route(
.create_device(
sender_user,
&device_id,
&appservice.registration.as_token,
(&appservice.registration.as_token, None),
None,
None,
Some(client.to_string()),
)
+60 -32
View File
@@ -33,7 +33,7 @@ use tuwunel_core::{
TryFutureExtExt,
math::Expected,
result::FlatOk,
stream::{ReadyExt, WidebandExt},
stream::{IterStream, ReadyExt, WidebandExt},
},
};
use tuwunel_service::Services;
@@ -51,19 +51,7 @@ pub(crate) async fn get_public_rooms_filtered_route(
InsecureClientIp(client): InsecureClientIp,
body: Ruma<get_public_rooms_filtered::v3::Request>,
) -> Result<get_public_rooms_filtered::v3::Response> {
if let Some(server) = &body.server {
if services
.config
.forbidden_remote_room_directory_server_names
.is_match(server.host())
|| services
.config
.forbidden_remote_server_names
.is_match(server.host())
{
return Err!(Request(Forbidden("Server is banned on this homeserver.")));
}
}
check_banned(&services, body.server.as_deref())?;
let response = get_public_rooms_filtered_helper(
&services,
@@ -92,19 +80,7 @@ pub(crate) async fn get_public_rooms_route(
InsecureClientIp(client): InsecureClientIp,
body: Ruma<get_public_rooms::v3::Request>,
) -> Result<get_public_rooms::v3::Response> {
if let Some(server) = &body.server {
if services
.config
.forbidden_remote_room_directory_server_names
.is_match(server.host())
|| services
.config
.forbidden_remote_server_names
.is_match(server.host())
{
return Err!(Request(Forbidden("Server is banned on this homeserver.")));
}
}
check_banned(&services, body.server.as_deref())?;
let response = get_public_rooms_filtered_helper(
&services,
@@ -308,32 +284,62 @@ pub(crate) async fn get_public_rooms_filtered_helper(
}
}
let search_term = filter
.generic_search_term
.as_deref()
.map(str::to_lowercase);
let search_room_id = filter
.generic_search_term
.as_deref()
.filter(|_| services.config.allow_public_room_search_by_id)
.filter(|s| s.starts_with('!'))
.filter(|s| s.len() > 5); // require some characters to limit scope.
let meta_public_rooms = search_room_id
.filter(|_| services.config.allow_unlisted_room_search_by_id)
.map(|prefix| services.rooms.metadata.public_ids_prefix(prefix))
.into_iter()
.stream()
.flatten();
let mut all_rooms: Vec<PublicRoomsChunk> = services
.rooms
.directory
.public_rooms()
.map(ToOwned::to_owned)
.chain(meta_public_rooms)
.wide_then(|room_id| public_rooms_chunk(services, room_id))
.ready_filter_map(|chunk| {
if !filter.room_types.is_empty() && !filter.room_types.contains(&RoomTypeFilter::from(chunk.room_type.clone())) {
if !filter.room_types.is_empty()
&& !filter
.room_types
.contains(&RoomTypeFilter::from(chunk.room_type.clone()))
{
return None;
}
if let Some(query) = filter.generic_search_term.as_ref().map(|q| q.to_lowercase()) {
if let Some(query) = search_room_id {
if chunk.room_id.as_str().contains(query) {
return Some(chunk);
}
}
if let Some(query) = search_term.as_deref() {
if let Some(name) = &chunk.name {
if name.as_str().to_lowercase().contains(&query) {
if name.as_str().to_lowercase().contains(query) {
return Some(chunk);
}
}
if let Some(topic) = &chunk.topic {
if topic.to_lowercase().contains(&query) {
if topic.to_lowercase().contains(query) {
return Some(chunk);
}
}
if let Some(canonical_alias) = &chunk.canonical_alias {
if canonical_alias.as_str().to_lowercase().contains(&query) {
if canonical_alias.as_str().to_lowercase().contains(query) {
return Some(chunk);
}
}
@@ -490,3 +496,25 @@ async fn public_rooms_chunk(services: &Services, room_id: OwnedRoomId) -> Public
world_readable,
}
}
fn check_banned(services: &Services, server: Option<&ServerName>) -> Result {
let Some(server) = server else {
return Ok(());
};
let forbidden_remote_directory = services
.config
.forbidden_remote_room_directory_server_names
.is_match(server.host());
let forbidden_remote_server = services
.config
.forbidden_remote_server_names
.is_match(server.host());
if forbidden_remote_directory || forbidden_remote_server {
Err!(Request(Forbidden("Server is banned on this homeserver.")))
} else {
Ok(())
}
}
+3 -3
View File
@@ -526,7 +526,7 @@ where
let mut futures: FuturesUnordered<_> = get_over_federation
.into_iter()
.map(|(server, vec)| async move {
.map(async |(server, vec)| {
let mut device_keys_input_fed = BTreeMap::new();
for (user_id, keys) in vec {
device_keys_input_fed.insert(user_id.to_owned(), keys.clone());
@@ -597,7 +597,7 @@ fn add_unsigned_device_display_name(
keys: &mut Raw<ruma::encryption::DeviceKeys>,
metadata: ruma::api::client::device::Device,
include_display_names: bool,
) -> serde_json::Result<()> {
) -> Result {
if let Some(display_name) = metadata.display_name {
let mut object = keys.deserialize_as::<serde_json::Map<String, serde_json::Value>>()?;
@@ -656,7 +656,7 @@ pub(crate) async fn claim_keys_helper(
let mut futures: FuturesUnordered<_> = get_over_federation
.into_iter()
.map(|(server, vec)| async move {
.map(async |(server, vec)| {
let mut one_time_keys_input_fed = BTreeMap::new();
for (user_id, keys) in vec {
one_time_keys_input_fed.insert(user_id.clone(), keys.clone());
+10 -9
View File
@@ -2,7 +2,7 @@ use std::{borrow::Borrow, collections::HashMap, iter::once, sync::Arc};
use axum::extract::State;
use axum_client_ip::InsecureClientIp;
use futures::{FutureExt, StreamExt};
use futures::{FutureExt, StreamExt, pin_mut};
use ruma::{
CanonicalJsonObject, CanonicalJsonValue, OwnedRoomId, OwnedServerName, OwnedUserId, RoomId,
RoomVersionId, UserId,
@@ -550,7 +550,7 @@ async fn join_room_by_id_helper_remote(
.validate_and_add_event_id_no_fetch(pdu, &room_version_id)
})
.ready_filter_map(Result::ok)
.fold(HashMap::new(), |mut state, (event_id, value)| async move {
.fold(HashMap::new(), async |mut state, (event_id, value)| {
let pdu = match PduEvent::from_id_val(&event_id, value.clone()) {
| Ok(pdu) => pdu,
| Err(e) => {
@@ -561,8 +561,9 @@ async fn join_room_by_id_helper_remote(
services
.rooms
.outlier
.timeline
.add_pdu_outlier(&event_id, &value);
if let Some(state_key) = &pdu.state_key {
let shortstatekey = services
.rooms
@@ -595,7 +596,7 @@ async fn join_room_by_id_helper_remote(
.ready_for_each(|(event_id, value)| {
services
.rooms
.outlier
.timeline
.add_pdu_outlier(&event_id, &value);
})
.await;
@@ -747,7 +748,7 @@ async fn join_room_by_id_helper_local(
})
.await
{
services
let users = services
.rooms
.state_cache
.local_users_in_room(room_id)
@@ -759,10 +760,10 @@ async fn join_room_by_id_helper_local(
&state_lock,
)
})
.boxed()
.next()
.await
.map(ToOwned::to_owned)
.map(ToOwned::to_owned);
pin_mut!(users);
users.next().await
} else {
None
}
+2 -1
View File
@@ -541,8 +541,9 @@ async fn knock_room_helper_remote(
services
.rooms
.outlier
.timeline
.add_pdu_outlier(&event_id, &event);
state_map.insert(shortstatekey, event_id.clone());
}
+1 -5
View File
@@ -230,11 +230,7 @@ pub async fn leave_room(
Ok(())
}
async fn remote_leave_room(
services: &Services,
user_id: &UserId,
room_id: &RoomId,
) -> Result<()> {
async fn remote_leave_room(services: &Services, user_id: &UserId, room_id: &RoomId) -> Result {
let mut make_leave_response_and_server =
Err!(BadServerResponse("No remote server available to assist in leaving {room_id}."));
+1 -1
View File
@@ -85,7 +85,7 @@ pub(crate) async fn joined_members_route(
.state_cache
.room_members(&body.room_id)
.map(ToOwned::to_owned)
.broad_then(|user_id| async move {
.broad_then(async |user_id| {
let (display_name, avatar_url) = join(
services.users.displayname(&user_id).ok(),
services.users.avatar_url(&user_id).ok(),
+7 -9
View File
@@ -100,7 +100,6 @@ pub(crate) async fn get_message_events_route(
.rooms
.timeline
.backfill_if_required(room_id, from)
.boxed()
.await
.log_err()
.ok();
@@ -151,9 +150,7 @@ pub(crate) async fn get_message_events_route(
.map(IterStream::stream)
.into_stream()
.flatten()
.broad_filter_map(|user_id| async move {
get_member_event(&services, room_id, &user_id).await
})
.broad_filter_map(async |user_id| get_member_event(&services, room_id, &user_id).await)
.collect()
.await;
@@ -195,10 +192,11 @@ where
.max()
.unwrap_or_else(PduCount::max);
let receipts = services
.rooms
.read_receipt
.readreceipts_since(lazy_loading_context.room_id, oldest.into_unsigned());
let receipts = services.rooms.read_receipt.readreceipts_since(
lazy_loading_context.room_id,
oldest.into_unsigned(),
Some(newest.into_unsigned()),
);
pin_mut!(receipts);
let witness: Witness = events
@@ -256,7 +254,7 @@ pub(crate) async fn is_ignored_pdu<Pdu>(
user_id: &UserId,
) -> bool
where
Pdu: Event + Send + Sync,
Pdu: Event,
{
// exclude Synapse's dummy events from bloating up response bodies. clients
// don't need to see this.
+3 -1
View File
@@ -19,6 +19,7 @@ pub(super) mod profile;
pub(super) mod push;
pub(super) mod read_marker;
pub(super) mod redact;
pub(super) mod register;
pub(super) mod relations;
pub(super) mod report;
pub(super) mod room;
@@ -63,6 +64,7 @@ pub use profile::{update_all_rooms, update_avatar_url, update_displayname};
pub(super) use push::*;
pub(super) use read_marker::*;
pub(super) use redact::*;
pub(super) use register::*;
pub(super) use relations::*;
pub(super) use report::*;
pub(super) use room::*;
@@ -87,7 +89,7 @@ pub(super) use well_known::*;
const DEVICE_ID_LENGTH: usize = 10;
/// generated user access token length
const TOKEN_LENGTH: usize = 32;
const TOKEN_LENGTH: usize = tuwunel_service::users::device::TOKEN_LENGTH;
/// generated user session ID length
const SESSION_ID_LENGTH: usize = tuwunel_service::uiaa::SESSION_ID_LENGTH;
+2 -2
View File
@@ -350,7 +350,7 @@ pub async fn update_displayname(
let all_joined_rooms: Vec<_> = all_joined_rooms
.iter()
.try_stream()
.and_then(|room_id: &OwnedRoomId| async move {
.and_then(async |room_id: &OwnedRoomId| {
let pdu = PduBuilder::state(user_id.to_string(), &RoomMemberEventContent {
displayname: displayname.clone(),
membership: MembershipState::Join,
@@ -403,7 +403,7 @@ pub async fn update_avatar_url(
let all_joined_rooms: Vec<_> = all_joined_rooms
.iter()
.try_stream()
.and_then(|room_id: &OwnedRoomId| async move {
.and_then(async |room_id: &OwnedRoomId| {
let pdu = PduBuilder::state(user_id.to_string(), &RoomMemberEventContent {
avatar_url: avatar_url.clone(),
blurhash: blurhash.clone(),
+606
View File
@@ -0,0 +1,606 @@
use std::fmt::Write;
use axum::extract::State;
use axum_client_ip::InsecureClientIp;
use futures::FutureExt;
use register::RegistrationKind;
use ruma::{
UserId,
api::client::{
account::{
check_registration_token_validity, get_username_availability,
register::{self, LoginType},
},
uiaa::{AuthFlow, AuthType, UiaaInfo},
},
events::GlobalAccountDataEventType,
push,
};
use tuwunel_core::{Err, Error, Result, debug_info, error, info, is_equal_to, utils, warn};
use tuwunel_service::users::device::generate_refresh_token;
use super::{DEVICE_ID_LENGTH, SESSION_ID_LENGTH, join_room_by_id_helper};
use crate::Ruma;
const RANDOM_USER_ID_LENGTH: usize = 10;
/// # `GET /_matrix/client/v3/register/available`
///
/// Checks if a username is valid and available on this server.
///
/// Conditions for returning true:
/// - The user id is not historical
/// - The server name of the user id matches this server
/// - No user or appservice on this server already claimed this username
///
/// Note: This will not reserve the username, so the username might become
/// invalid when trying to register
#[tracing::instrument(skip_all, fields(%client), name = "register_available")]
pub(crate) async fn get_register_available_route(
State(services): State<crate::State>,
InsecureClientIp(client): InsecureClientIp,
body: Ruma<get_username_availability::v3::Request>,
) -> Result<get_username_availability::v3::Response> {
// workaround for https://github.com/matrix-org/matrix-appservice-irc/issues/1780 due to inactivity of fixing the issue
let is_matrix_appservice_irc = body
.appservice_info
.as_ref()
.is_some_and(|appservice| {
appservice.registration.id == "irc"
|| appservice
.registration
.id
.contains("matrix-appservice-irc")
|| appservice
.registration
.id
.contains("matrix_appservice_irc")
});
if services
.globals
.forbidden_usernames()
.is_match(&body.username)
{
return Err!(Request(Forbidden("Username is forbidden")));
}
// don't force the username lowercase if it's from matrix-appservice-irc
let body_username = if is_matrix_appservice_irc {
body.username.clone()
} else {
body.username.to_lowercase()
};
// Validate user id
let user_id =
match UserId::parse_with_server_name(&body_username, services.globals.server_name()) {
| Ok(user_id) => {
if let Err(e) = user_id.validate_strict() {
// unless the username is from the broken matrix appservice IRC bridge, we
// should follow synapse's behaviour on not allowing things like spaces
// and UTF-8 characters in usernames
if !is_matrix_appservice_irc {
return Err!(Request(InvalidUsername(debug_warn!(
"Username {body_username} contains disallowed characters or spaces: \
{e}"
))));
}
}
user_id
},
| Err(e) => {
return Err!(Request(InvalidUsername(debug_warn!(
"Username {body_username} is not valid: {e}"
))));
},
};
// Check if username is creative enough
if services.users.exists(&user_id).await {
return Err!(Request(UserInUse("User ID is not available.")));
}
if let Some(ref info) = body.appservice_info {
if !info.is_user_match(&user_id) {
return Err!(Request(Exclusive("Username is not in an appservice namespace.")));
}
}
if services
.appservice
.is_exclusive_user_id(&user_id)
.await
{
return Err!(Request(Exclusive("Username is reserved by an appservice.")));
}
Ok(get_username_availability::v3::Response { available: true })
}
/// # `POST /_matrix/client/v3/register`
///
/// Register an account on this homeserver.
///
/// You can use [`GET
/// /_matrix/client/v3/register/available`](fn.get_register_available_route.
/// html) to check if the user id is valid and available.
///
/// - Only works if registration is enabled
/// - If type is guest: ignores all parameters except
/// initial_device_display_name
/// - If sender is not appservice: Requires UIAA (but we only use a dummy stage)
/// - If type is not guest and no username is given: Always fails after UIAA
/// check
/// - Creates a new account and populates it with default account data
/// - If `inhibit_login` is false: Creates a device and returns device id and
/// access_token
#[allow(clippy::doc_markdown)]
#[tracing::instrument(skip_all, fields(%client), name = "register")]
pub(crate) async fn register_route(
State(services): State<crate::State>,
InsecureClientIp(client): InsecureClientIp,
body: Ruma<register::v3::Request>,
) -> Result<register::v3::Response> {
let is_guest = body.kind == RegistrationKind::Guest;
let emergency_mode_enabled = services.config.emergency_password.is_some();
if !services.config.allow_registration && body.appservice_info.is_none() {
match (body.username.as_ref(), body.initial_device_display_name.as_ref()) {
| (Some(username), Some(device_display_name)) => {
info!(
%is_guest,
user = %username,
device_name = %device_display_name,
"Rejecting registration attempt as registration is disabled"
);
},
| (Some(username), _) => {
info!(
%is_guest,
user = %username,
"Rejecting registration attempt as registration is disabled"
);
},
| (_, Some(device_display_name)) => {
info!(
%is_guest,
device_name = %device_display_name,
"Rejecting registration attempt as registration is disabled"
);
},
| (None, _) => {
info!(
%is_guest,
"Rejecting registration attempt as registration is disabled"
);
},
}
return Err!(Request(Forbidden("Registration has been disabled.")));
}
if is_guest
&& (!services.config.allow_guest_registration
|| (services.config.allow_registration
&& services.globals.registration_token.is_some()))
{
info!(
"Guest registration disabled / registration enabled with token configured, \
rejecting guest registration attempt, initial device name: \"{}\"",
body.initial_device_display_name
.as_deref()
.unwrap_or("")
);
return Err!(Request(GuestAccessForbidden("Guest registration is disabled.")));
}
// forbid guests from registering if there is not a real admin user yet. give
// generic user error.
if is_guest && services.users.count().await < 2 {
warn!(
"Guest account attempted to register before a real admin user has been registered, \
rejecting registration. Guest's initial device name: \"{}\"",
body.initial_device_display_name
.as_deref()
.unwrap_or("")
);
return Err!(Request(Forbidden("Registration is temporarily disabled.")));
}
let user_id = match (body.username.as_ref(), is_guest) {
| (Some(username), false) => {
// workaround for https://github.com/matrix-org/matrix-appservice-irc/issues/1780 due to inactivity of fixing the issue
let is_matrix_appservice_irc =
body.appservice_info
.as_ref()
.is_some_and(|appservice| {
appservice.registration.id == "irc"
|| appservice
.registration
.id
.contains("matrix-appservice-irc")
|| appservice
.registration
.id
.contains("matrix_appservice_irc")
});
if services
.globals
.forbidden_usernames()
.is_match(username)
&& !emergency_mode_enabled
{
return Err!(Request(Forbidden("Username is forbidden")));
}
// don't force the username lowercase if it's from matrix-appservice-irc
let body_username = if is_matrix_appservice_irc {
username.clone()
} else {
username.to_lowercase()
};
let proposed_user_id = match UserId::parse_with_server_name(
&body_username,
services.globals.server_name(),
) {
| Ok(user_id) => {
if let Err(e) = user_id.validate_strict() {
// unless the username is from the broken matrix appservice IRC bridge, or
// we are in emergency mode, we should follow synapse's behaviour on
// not allowing things like spaces and UTF-8 characters in usernames
if !is_matrix_appservice_irc && !emergency_mode_enabled {
return Err!(Request(InvalidUsername(debug_warn!(
"Username {body_username} contains disallowed characters or \
spaces: {e}"
))));
}
}
user_id
},
| Err(e) => {
return Err!(Request(InvalidUsername(debug_warn!(
"Username {body_username} is not valid: {e}"
))));
},
};
if services.users.exists(&proposed_user_id).await {
return Err!(Request(UserInUse("User ID is not available.")));
}
proposed_user_id
},
| _ => loop {
let proposed_user_id = UserId::parse_with_server_name(
utils::random_string(RANDOM_USER_ID_LENGTH).to_lowercase(),
services.globals.server_name(),
)
.unwrap();
if !services.users.exists(&proposed_user_id).await {
break proposed_user_id;
}
},
};
if body.body.login_type == Some(LoginType::ApplicationService) {
match body.appservice_info {
| Some(ref info) =>
if !info.is_user_match(&user_id) && !emergency_mode_enabled {
return Err!(Request(Exclusive(
"Username is not in an appservice namespace."
)));
},
| _ => {
return Err!(Request(MissingToken("Missing appservice token.")));
},
}
} else if services
.appservice
.is_exclusive_user_id(&user_id)
.await && !emergency_mode_enabled
{
return Err!(Request(Exclusive("Username is reserved by an appservice.")));
}
// UIAA
let mut uiaainfo;
let skip_auth = if services.globals.registration_token.is_some() {
// Registration token required
uiaainfo = UiaaInfo {
flows: vec![AuthFlow {
stages: vec![AuthType::RegistrationToken],
}],
completed: Vec::new(),
params: Box::default(),
session: None,
auth_error: None,
};
body.appservice_info.is_some()
} else {
// No registration token necessary, but clients must still go through the flow
uiaainfo = UiaaInfo {
flows: vec![AuthFlow { stages: vec![AuthType::Dummy] }],
completed: Vec::new(),
params: Box::default(),
session: None,
auth_error: None,
};
body.appservice_info.is_some() || is_guest
};
if !skip_auth {
match &body.auth {
| Some(auth) => {
let (worked, uiaainfo) = services
.uiaa
.try_auth(
&UserId::parse_with_server_name("", services.globals.server_name())
.unwrap(),
"".into(),
auth,
&uiaainfo,
)
.await?;
if !worked {
return Err(Error::Uiaa(uiaainfo));
}
// Success!
},
| _ => match body.json_body {
| Some(ref json) => {
uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH));
services.uiaa.create(
&UserId::parse_with_server_name("", services.globals.server_name())
.unwrap(),
"".into(),
&uiaainfo,
json,
);
return Err(Error::Uiaa(uiaainfo));
},
| _ => {
return Err!(Request(NotJson("JSON body is not valid")));
},
},
}
}
let password = if is_guest { None } else { body.password.as_deref() };
// Create user
services
.users
.create(&user_id, password, None)
.await?;
// Default to pretty displayname
let mut displayname = user_id.localpart().to_owned();
// If `new_user_displayname_suffix` is set, registration will push whatever
// content is set to the user's display name with a space before it
if !services
.globals
.new_user_displayname_suffix()
.is_empty()
&& body.appservice_info.is_none()
{
write!(displayname, " {}", services.server.config.new_user_displayname_suffix)?;
}
services
.users
.set_displayname(&user_id, Some(displayname.clone()));
// Initial account data
services
.account_data
.update(
None,
&user_id,
GlobalAccountDataEventType::PushRules
.to_string()
.into(),
&serde_json::to_value(ruma::events::push_rules::PushRulesEvent {
content: ruma::events::push_rules::PushRulesEventContent {
global: push::Ruleset::server_default(&user_id),
},
})?,
)
.await?;
if (!is_guest && body.inhibit_login)
|| body
.appservice_info
.as_ref()
.is_some_and(|appservice| appservice.registration.device_management)
{
return Ok(register::v3::Response {
access_token: None,
user_id,
device_id: None,
refresh_token: None,
expires_in: None,
});
}
// Generate new device id if the user didn't specify one
let device_id = if is_guest { None } else { body.device_id.clone() }
.unwrap_or_else(|| utils::random_string(DEVICE_ID_LENGTH).into());
// Generate new token for the device
let (access_token, expires_in) = services
.users
.generate_access_token(body.body.refresh_token);
// Generate a new refresh_token if requested by client
let refresh_token = expires_in.is_some().then(generate_refresh_token);
// Create device for this account
services
.users
.create_device(
&user_id,
&device_id,
(&access_token, expires_in),
refresh_token.as_deref(),
body.initial_device_display_name.clone(),
Some(client.to_string()),
)
.await?;
debug_info!(%user_id, %device_id, "User account was created");
let device_display_name = body
.initial_device_display_name
.as_deref()
.unwrap_or("");
// log in conduit admin channel if a non-guest user registered
if body.appservice_info.is_none() && !is_guest {
if !device_display_name.is_empty() {
let notice = format!(
"New user \"{user_id}\" registered on this server from IP {client} and device \
display name \"{device_display_name}\""
);
info!("{notice}");
if services.server.config.admin_room_notices {
services.admin.notice(&notice).await;
}
} else {
let notice = format!("New user \"{user_id}\" registered on this server.");
info!("{notice}");
if services.server.config.admin_room_notices {
services.admin.notice(&notice).await;
}
}
}
// log in conduit admin channel if a guest registered
if body.appservice_info.is_none() && is_guest && services.config.log_guest_registrations {
debug_info!("New guest user \"{user_id}\" registered on this server.");
if !device_display_name.is_empty() {
if services.server.config.admin_room_notices {
services
.admin
.notice(&format!(
"Guest user \"{user_id}\" with device display name \
\"{device_display_name}\" registered on this server from IP {client}"
))
.await;
}
} else {
#[allow(clippy::collapsible_else_if)]
if services.server.config.admin_room_notices {
services
.admin
.notice(&format!(
"Guest user \"{user_id}\" with no device display name registered on \
this server from IP {client}",
))
.await;
}
}
}
// If this is the first real user, grant them admin privileges except for guest
// users
// Note: the server user is generated first
if !is_guest
&& services.config.grant_admin_to_first_user
&& let Ok(admin_room) = services.admin.get_admin_room().await
&& services
.rooms
.state_cache
.room_joined_count(&admin_room)
.await
.is_ok_and(is_equal_to!(1))
{
services.admin.make_user_admin(&user_id).await?;
warn!("Granting {user_id} admin privileges as the first user");
}
if body.appservice_info.is_none()
&& !services.server.config.auto_join_rooms.is_empty()
&& (services.config.allow_guests_auto_join_rooms || !is_guest)
{
for room in &services.server.config.auto_join_rooms {
let Ok(room_id) = services.rooms.alias.resolve(room).await else {
error!(
"Failed to resolve room alias to room ID when attempting to auto join \
{room}, skipping"
);
continue;
};
if !services
.rooms
.state_cache
.server_in_room(services.globals.server_name(), &room_id)
.await
{
warn!(
"Skipping room {room} to automatically join as we have never joined before."
);
continue;
}
if let Some(room_server_name) = room.server_name() {
match join_room_by_id_helper(
&services,
&user_id,
&room_id,
Some("Automatically joining this room upon registration".to_owned()),
&[services.globals.server_name().to_owned(), room_server_name.to_owned()],
None,
&body.appservice_info,
)
.boxed()
.await
{
| Err(e) => {
// don't return this error so we don't fail registrations
error!(
"Failed to automatically join room {room} for user {user_id}: {e}"
);
},
| _ => {
info!("Automatically joined room {room} for user {user_id}");
},
}
}
}
}
Ok(register::v3::Response {
user_id,
device_id: Some(device_id),
access_token: Some(access_token),
refresh_token,
expires_in,
})
}
/// # `GET /_matrix/client/v1/register/m.login.registration_token/validity`
///
/// Checks if the provided registration token is valid at the time of checking
///
/// Currently does not have any ratelimiting, and this isn't very practical as
/// there is only one registration token allowed.
pub(crate) async fn check_registration_token_validity(
State(services): State<crate::State>,
body: Ruma<check_registration_token_validity::v1::Request>,
) -> Result<check_registration_token_validity::v1::Response> {
let Some(reg_token) = services.globals.registration_token.clone() else {
return Err!(Request(Forbidden("Server does not allow token registration")));
};
Ok(check_registration_token_validity::v1::Response { valid: reg_token == body.token })
}
+1 -1
View File
@@ -175,7 +175,7 @@ async fn paginate_relations_with_filter(
})
}
async fn visibility_filter<Pdu: Event + Send + Sync>(
async fn visibility_filter<Pdu: Event>(
services: &Services,
sender_user: &UserId,
item: (PduCount, Pdu),
+1 -1
View File
@@ -149,7 +149,7 @@ async fn is_event_report_valid(
reason: Option<&String>,
score: Option<ruma::Int>,
pdu: &PduEvent,
) -> Result<()> {
) -> Result {
debug_info!(
"Checking if report from user {sender_user} for event {event_id} in room {room_id} is \
valid"
+23 -27
View File
@@ -111,6 +111,7 @@ pub(crate) async fn create_room_route(
.short
.get_or_create_shortroomid(&room_id)
.await;
let state_lock = services.rooms.state.mutex.lock(&room_id).await;
let alias: Option<OwnedRoomAliasId> = match body.room_alias_name.as_ref() {
@@ -187,6 +188,10 @@ pub(crate) async fn create_room_route(
},
};
// Increment and hold the counter; the room will sync atomically to clients
// which is preferable.
let next_count = services.globals.next_count();
// 1. The room create event
services
.rooms
@@ -425,8 +430,10 @@ pub(crate) async fn create_room_route(
.await?;
}
// 8. Events implied by invite (and TODO: invite_3pid)
drop(next_count);
drop(state_lock);
// 8. Events implied by invite (and TODO: invite_3pid)
for user_id in &body.invite {
if services
.users
@@ -487,43 +494,32 @@ fn default_power_levels_content(
visibility: &room::Visibility,
users: BTreeMap<OwnedUserId, Int>,
) -> Result<serde_json::Value> {
use serde_json::to_value;
let mut power_levels_content =
serde_json::to_value(RoomPowerLevelsEventContent { users, ..Default::default() })
.expect("event is valid, we just created it");
to_value(RoomPowerLevelsEventContent { users, ..Default::default() })?;
// secure proper defaults of sensitive/dangerous permissions that moderators
// (power level 50) should not have easy access to
power_levels_content["events"]["m.room.power_levels"] =
serde_json::to_value(100).expect("100 is valid Value");
power_levels_content["events"]["m.room.server_acl"] =
serde_json::to_value(100).expect("100 is valid Value");
power_levels_content["events"]["m.room.tombstone"] =
serde_json::to_value(100).expect("100 is valid Value");
power_levels_content["events"]["m.room.encryption"] =
serde_json::to_value(100).expect("100 is valid Value");
power_levels_content["events"]["m.room.history_visibility"] =
serde_json::to_value(100).expect("100 is valid Value");
power_levels_content["events"]["m.room.power_levels"] = to_value(100)?;
power_levels_content["events"]["m.room.server_acl"] = to_value(100)?;
power_levels_content["events"]["m.room.tombstone"] = to_value(100)?;
power_levels_content["events"]["m.room.encryption"] = to_value(100)?;
power_levels_content["events"]["m.room.history_visibility"] = to_value(100)?;
// always allow users to respond (not post new) to polls. this is primarily
// useful in read-only announcement rooms that post a public poll.
power_levels_content["events"]["org.matrix.msc3381.poll.response"] =
serde_json::to_value(0).expect("0 is valid Value");
power_levels_content["events"]["m.poll.response"] =
serde_json::to_value(0).expect("0 is valid Value");
power_levels_content["events"]["org.matrix.msc3381.poll.response"] = to_value(0)?;
power_levels_content["events"]["m.poll.response"] = to_value(0)?;
// synapse does this too. clients do not expose these permissions. it prevents
// default users from calling public rooms, for obvious reasons.
if *visibility == room::Visibility::Public {
power_levels_content["events"]["m.call.invite"] =
serde_json::to_value(50).expect("50 is valid Value");
power_levels_content["events"]["m.call"] =
serde_json::to_value(50).expect("50 is valid Value");
power_levels_content["events"]["m.call.member"] =
serde_json::to_value(50).expect("50 is valid Value");
power_levels_content["events"]["org.matrix.msc3401.call"] =
serde_json::to_value(50).expect("50 is valid Value");
power_levels_content["events"]["org.matrix.msc3401.call.member"] =
serde_json::to_value(50).expect("50 is valid Value");
power_levels_content["events"]["m.call.invite"] = to_value(50)?;
power_levels_content["events"]["m.call"] = to_value(50)?;
power_levels_content["events"]["m.call.member"] = to_value(50)?;
power_levels_content["events"]["org.matrix.msc3401.call"] = to_value(50)?;
power_levels_content["events"]["org.matrix.msc3401.call.member"] = to_value(50)?;
}
if let Some(power_level_content_override) = power_level_content_override {
+11 -20
View File
@@ -17,7 +17,7 @@ use ruma::{
};
use serde_json::{json, value::to_raw_value};
use tuwunel_core::{
Error, Result, err, info,
Err, Error, Result, err,
matrix::{Event, StateKey, pdu::PduBuilder},
};
@@ -54,10 +54,8 @@ pub(crate) async fn upgrade_room_route(
TRANSFERABLE_STATE_EVENTS.is_sorted(),
"TRANSFERABLE_STATE_EVENTS is not sorted"
);
let sender_user = body
.sender_user
.as_ref()
.expect("user is authenticated");
let sender_user = body.sender_user();
if !services
.server
@@ -134,8 +132,7 @@ pub(crate) async fn upgrade_room_route(
create_event_content.insert(
"creator".into(),
json!(&sender_user).try_into().map_err(|e| {
info!("Error forming creation event: {e}");
Error::BadRequest(ErrorKind::BadJson, "Error forming creation event")
err!(Request(BadJson(error!("Error forming creation event: {e}"))))
})?,
);
},
@@ -150,24 +147,20 @@ pub(crate) async fn upgrade_room_route(
"room_version".into(),
json!(&body.new_version)
.try_into()
.map_err(|_| Error::BadRequest(ErrorKind::BadJson, "Error forming creation event"))?,
.map_err(|_| err!(Request(BadJson("Error forming creation event"))))?,
);
create_event_content.insert(
"predecessor".into(),
json!(predecessor)
.try_into()
.map_err(|_| Error::BadRequest(ErrorKind::BadJson, "Error forming creation event"))?,
.map_err(|_| err!(Request(BadJson("Error forming creation event"))))?,
);
// Validate creation event content
if serde_json::from_str::<CanonicalJsonObject>(
to_raw_value(&create_event_content)
.expect("Error forming creation event")
.get(),
)
.is_err()
if serde_json::from_str::<CanonicalJsonObject>(to_raw_value(&create_event_content)?.get())
.is_err()
{
return Err(Error::BadRequest(ErrorKind::BadJson, "Error forming creation event"));
return Err!(Request(BadJson("Error forming creation event")));
}
services
@@ -176,8 +169,7 @@ pub(crate) async fn upgrade_room_route(
.build_and_append_pdu(
PduBuilder {
event_type: TimelineEventType::RoomCreate,
content: to_raw_value(&create_event_content)
.expect("event is valid, we just created it"),
content: to_raw_value(&create_event_content)?,
unsigned: None,
state_key: Some(StateKey::new()),
redacts: None,
@@ -205,8 +197,7 @@ pub(crate) async fn upgrade_room_route(
blurhash: services.users.blurhash(sender_user).await.ok(),
reason: None,
join_authorized_via_users_server: None,
})
.expect("event is valid, we just created it"),
})?,
unsigned: None,
state_key: Some(sender_user.as_str().into()),
redacts: None,
+3 -3
View File
@@ -95,13 +95,13 @@ async fn category_room_events(
});
let results: Vec<_> = rooms
.filter_map(|room_id| async move {
.filter_map(async |room_id| {
check_room_visible(services, sender_user, &room_id, criteria)
.await
.is_ok()
.then_some(room_id)
})
.filter_map(|room_id| async move {
.filter_map(async |room_id| {
let query = RoomQuery {
room_id: &room_id,
user_id: Some(sender_user),
@@ -135,7 +135,7 @@ async fn category_room_events(
.iter()
.stream()
.ready_filter(|_| criteria.include_state.is_some_and(is_true!()))
.filter_map(|(room_id, ..)| async move {
.filter_map(async |(room_id, ..)| {
procure_room_state(services, room_id)
.map_ok(|state| (room_id.clone(), state))
.await
-455
View File
@@ -1,455 +0,0 @@
use std::time::Duration;
use axum::extract::State;
use axum_client_ip::InsecureClientIp;
use futures::{FutureExt, StreamExt, TryFutureExt};
use ruma::{
OwnedUserId, UserId,
api::client::{
session::{
get_login_token,
get_login_types::{
self,
v3::{ApplicationServiceLoginType, PasswordLoginType, TokenLoginType},
},
login::{
self,
v3::{DiscoveryInfo, HomeserverInfo},
},
logout, logout_all,
},
uiaa,
},
};
use tuwunel_core::{
Err, Error, Result, debug, debug_error, err, info, utils,
utils::{hash, stream::ReadyExt},
};
use tuwunel_service::{Services, uiaa::SESSION_ID_LENGTH};
use super::{DEVICE_ID_LENGTH, TOKEN_LENGTH};
use crate::Ruma;
/// # `GET /_matrix/client/v3/login`
///
/// Get the supported login types of this server. One of these should be used as
/// the `type` field when logging in.
#[tracing::instrument(skip_all, fields(%client), name = "login")]
pub(crate) async fn get_login_types_route(
State(services): State<crate::State>,
InsecureClientIp(client): InsecureClientIp,
_body: Ruma<get_login_types::v3::Request>,
) -> Result<get_login_types::v3::Response> {
Ok(get_login_types::v3::Response::new(vec![
get_login_types::v3::LoginType::Password(PasswordLoginType::default()),
get_login_types::v3::LoginType::ApplicationService(ApplicationServiceLoginType::default()),
get_login_types::v3::LoginType::Token(TokenLoginType {
get_login_token: services.server.config.login_via_existing_session,
}),
]))
}
/// Authenticates the given user by its ID and its password.
///
/// Returns the user ID if successful, and an error otherwise.
#[tracing::instrument(skip_all, fields(%user_id), name = "password")]
async fn password_login(
services: &Services,
user_id: &UserId,
lowercased_user_id: &UserId,
password: &str,
) -> Result<OwnedUserId> {
let (hash, user_id) = services
.users
.password_hash(user_id)
.map_ok(|hash| (hash, user_id))
.or_else(|_| {
services
.users
.password_hash(lowercased_user_id)
.map_ok(|hash| (hash, lowercased_user_id))
})
.await?;
if hash.is_empty() {
return Err!(Request(UserDeactivated("The user has been deactivated")));
}
hash::verify_password(password, &hash)
.inspect_err(|e| debug_error!("{e}"))
.map_err(|_| err!(Request(Forbidden("Wrong username or password."))))?;
Ok(user_id.to_owned())
}
/// Authenticates the given user through the configured LDAP server.
///
/// Creates the user if the user is found in the LDAP and do not already have an
/// account.
#[tracing::instrument(skip_all, fields(%user_id), name = "ldap")]
async fn ldap_login(
services: &Services,
user_id: &UserId,
lowercased_user_id: &UserId,
password: &str,
) -> Result<OwnedUserId> {
let (user_dn, is_ldap_admin) = match services.config.ldap.bind_dn.as_ref() {
| Some(bind_dn) if bind_dn.contains("{username}") =>
(bind_dn.replace("{username}", lowercased_user_id.localpart()), false),
| _ => {
debug!("Searching user in LDAP");
let dns = services.users.search_ldap(user_id).await?;
if dns.len() >= 2 {
return Err!(Ldap("LDAP search returned two or more results"));
}
let Some((user_dn, is_admin)) = dns.first() else {
return password_login(services, user_id, lowercased_user_id, password).await;
};
(user_dn.clone(), *is_admin)
},
};
let user_id = services
.users
.auth_ldap(&user_dn, password)
.await
.map(|()| lowercased_user_id.to_owned())?;
// LDAP users are automatically created on first login attempt. This is a very
// common feature that can be seen on many services using a LDAP provider for
// their users (synapse, Nextcloud, Jellyfin, ...).
//
// LDAP users are crated with a dummy password but non empty because an empty
// password is reserved for deactivated accounts. The tuwunel password field
// will never be read to login a LDAP user so it's not an issue.
if !services.users.exists(lowercased_user_id).await {
services
.users
.create(lowercased_user_id, Some("*"), Some("ldap"))
.await?;
}
let is_tuwunel_admin = services
.admin
.user_is_admin(lowercased_user_id)
.await;
if is_ldap_admin && !is_tuwunel_admin {
services
.admin
.make_user_admin(lowercased_user_id)
.await?;
} else if !is_ldap_admin && is_tuwunel_admin {
services
.admin
.revoke_admin(lowercased_user_id)
.await?;
}
Ok(user_id)
}
/// # `POST /_matrix/client/v3/login`
///
/// Authenticates the user and returns an access token it can use in subsequent
/// requests.
///
/// - The user needs to authenticate using their password (or if enabled using a
/// json web token)
/// - If `device_id` is known: invalidates old access token of that device
/// - If `device_id` is unknown: creates a new device
/// - Returns access token that is associated with the user and device
///
/// Note: You can use [`GET
/// /_matrix/client/r0/login`](fn.get_supported_versions_route.html) to see
/// supported login types.
#[tracing::instrument(skip_all, fields(%client), name = "login")]
pub(crate) async fn login_route(
State(services): State<crate::State>,
InsecureClientIp(client): InsecureClientIp,
body: Ruma<login::v3::Request>,
) -> Result<login::v3::Response> {
let emergency_mode_enabled = services.config.emergency_password.is_some();
// Validate login method
// TODO: Other login methods
let user_id = match &body.login_info {
#[allow(deprecated)]
| login::v3::LoginInfo::Password(login::v3::Password {
identifier,
password,
user,
..
}) => {
debug!("Got password login type");
let user_id =
if let Some(uiaa::UserIdentifier::UserIdOrLocalpart(user_id)) = identifier {
UserId::parse_with_server_name(user_id, &services.config.server_name)
} else if let Some(user) = user {
UserId::parse_with_server_name(user, &services.config.server_name)
} else {
return Err!(Request(Unknown(
debug_warn!(?body.login_info, "Valid identifier or username was not provided (invalid or unsupported login type?)")
)));
}
.map_err(|e| err!(Request(InvalidUsername(warn!("Username is invalid: {e}")))))?;
let lowercased_user_id = UserId::parse_with_server_name(
user_id.localpart().to_lowercase(),
&services.config.server_name,
)?;
if !services.globals.user_is_local(&user_id)
|| !services
.globals
.user_is_local(&lowercased_user_id)
{
return Err!(Request(Unknown("User ID does not belong to this homeserver")));
}
if cfg!(feature = "ldap") && services.config.ldap.enable {
ldap_login(&services, &user_id, &lowercased_user_id, password)
.boxed()
.await?
} else {
password_login(&services, &user_id, &lowercased_user_id, password)
.boxed()
.await?
}
},
| login::v3::LoginInfo::Token(login::v3::Token { token }) => {
debug!("Got token login type");
if !services.server.config.login_via_existing_session {
return Err!(Request(Unknown("Token login is not enabled.")));
}
services
.users
.find_from_login_token(token)
.await?
},
#[allow(deprecated)]
| login::v3::LoginInfo::ApplicationService(login::v3::ApplicationService {
identifier,
user,
}) => {
debug!("Got appservice login type");
let Some(ref info) = body.appservice_info else {
return Err!(Request(MissingToken("Missing appservice token.")));
};
let user_id =
if let Some(uiaa::UserIdentifier::UserIdOrLocalpart(user_id)) = identifier {
UserId::parse_with_server_name(user_id, &services.config.server_name)
} else if let Some(user) = user {
UserId::parse_with_server_name(user, &services.config.server_name)
} else {
return Err!(Request(Unknown(
debug_warn!(?body.login_info, "Valid identifier or username was not provided (invalid or unsupported login type?)")
)));
}
.map_err(|e| err!(Request(InvalidUsername(warn!("Username is invalid: {e}")))))?;
if !services.globals.user_is_local(&user_id) {
return Err!(Request(Unknown("User ID does not belong to this homeserver")));
}
if !info.is_user_match(&user_id) && !emergency_mode_enabled {
return Err!(Request(Exclusive("Username is not in an appservice namespace.")));
}
user_id
},
| _ => {
debug!("/login json_body: {:?}", &body.json_body);
return Err!(Request(Unknown(
debug_warn!(?body.login_info, "Invalid or unsupported login type")
)));
},
};
// Generate new device id if the user didn't specify one
let device_id = body
.device_id
.clone()
.unwrap_or_else(|| utils::random_string(DEVICE_ID_LENGTH).into());
// Generate a new token for the device
let token = utils::random_string(TOKEN_LENGTH);
// Determine if device_id was provided and exists in the db for this user
let device_exists = if body.device_id.is_some() {
services
.users
.all_device_ids(&user_id)
.ready_any(|v| v == device_id)
.await
} else {
false
};
if device_exists {
services
.users
.set_token(&user_id, &device_id, &token)
.await?;
} else {
services
.users
.create_device(
&user_id,
&device_id,
&token,
body.initial_device_display_name.clone(),
Some(client.to_string()),
)
.await?;
}
// send client well-known if specified so the client knows to reconfigure itself
let client_discovery_info: Option<DiscoveryInfo> = services
.server
.config
.well_known
.client
.as_ref()
.map(|server| DiscoveryInfo::new(HomeserverInfo::new(server.to_string())));
info!("{user_id} logged in");
#[allow(deprecated)]
Ok(login::v3::Response {
user_id,
access_token: token,
device_id,
well_known: client_discovery_info,
expires_in: None,
home_server: Some(services.config.server_name.clone()),
refresh_token: None,
})
}
/// # `POST /_matrix/client/v1/login/get_token`
///
/// Allows a logged-in user to get a short-lived token which can be used
/// to log in with the m.login.token flow.
///
/// <https://spec.matrix.org/v1.13/client-server-api/#post_matrixclientv1loginget_token>
#[tracing::instrument(skip_all, fields(%client), name = "login_token")]
pub(crate) async fn login_token_route(
State(services): State<crate::State>,
InsecureClientIp(client): InsecureClientIp,
body: Ruma<get_login_token::v1::Request>,
) -> Result<get_login_token::v1::Response> {
if !services.server.config.login_via_existing_session {
return Err!(Request(Forbidden("Login via an existing session is not enabled")));
}
// This route SHOULD have UIA
// TODO: How do we make only UIA sessions that have not been used before valid?
let (sender_user, sender_device) = body.sender();
let mut uiaainfo = uiaa::UiaaInfo {
flows: vec![uiaa::AuthFlow { stages: vec![uiaa::AuthType::Password] }],
completed: Vec::new(),
params: Box::default(),
session: None,
auth_error: None,
};
match &body.auth {
| Some(auth) => {
let (worked, uiaainfo) = services
.uiaa
.try_auth(sender_user, sender_device, auth, &uiaainfo)
.await?;
if !worked {
return Err(Error::Uiaa(uiaainfo));
}
// Success!
},
| _ => match body.json_body.as_ref() {
| Some(json) => {
uiaainfo.session = Some(utils::random_string(SESSION_ID_LENGTH));
services
.uiaa
.create(sender_user, sender_device, &uiaainfo, json);
return Err(Error::Uiaa(uiaainfo));
},
| _ => {
return Err!(Request(NotJson("No JSON body was sent when required.")));
},
},
}
let login_token = utils::random_string(TOKEN_LENGTH);
let expires_in = services
.users
.create_login_token(sender_user, &login_token);
Ok(get_login_token::v1::Response {
expires_in: Duration::from_millis(expires_in),
login_token,
})
}
/// # `POST /_matrix/client/v3/logout`
///
/// Log out the current device.
///
/// - Invalidates access token
/// - Deletes device metadata (device id, device display name, last seen ip,
/// last seen ts)
/// - Forgets to-device events
/// - Triggers device list updates
#[tracing::instrument(skip_all, fields(%client), name = "logout")]
pub(crate) async fn logout_route(
State(services): State<crate::State>,
InsecureClientIp(client): InsecureClientIp,
body: Ruma<logout::v3::Request>,
) -> Result<logout::v3::Response> {
services
.users
.remove_device(body.sender_user(), body.sender_device())
.await;
Ok(logout::v3::Response::new())
}
/// # `POST /_matrix/client/r0/logout/all`
///
/// Log out all devices of this user.
///
/// - Invalidates all access tokens
/// - Deletes all device metadata (device id, device display name, last seen ip,
/// last seen ts)
/// - Forgets all to-device events
/// - Triggers device list updates
///
/// Note: This is equivalent to calling [`GET
/// /_matrix/client/r0/logout`](fn.logout_route.html) from each device of this
/// user.
#[tracing::instrument(skip_all, fields(%client), name = "logout")]
pub(crate) async fn logout_all_route(
State(services): State<crate::State>,
InsecureClientIp(client): InsecureClientIp,
body: Ruma<logout_all::v3::Request>,
) -> Result<logout_all::v3::Response> {
services
.users
.all_device_ids(body.sender_user())
.for_each(|device_id| {
services
.users
.remove_device(body.sender_user(), device_id)
})
.await;
Ok(logout_all::v3::Response::new())
}
+48
View File
@@ -0,0 +1,48 @@
use ruma::{
OwnedUserId, UserId,
api::client::{
session::login::v3::{ApplicationService, Request},
uiaa,
},
};
use tuwunel_core::{Err, Result, err};
use tuwunel_service::Services;
use crate::Ruma;
pub(super) async fn handle_login(
services: &Services,
body: &Ruma<Request>,
info: &ApplicationService,
) -> Result<OwnedUserId> {
#[allow(deprecated)]
let ApplicationService { identifier, user } = info;
let Some(ref info) = body.appservice_info else {
return Err!(Request(MissingToken("Missing appservice token.")));
};
let user_id = if let Some(uiaa::UserIdentifier::UserIdOrLocalpart(user_id)) = identifier {
UserId::parse_with_server_name(user_id, &services.config.server_name)
} else if let Some(user) = user {
UserId::parse_with_server_name(user, &services.config.server_name)
} else {
return Err!(Request(Unknown(debug_warn!(
?body.login_info,
"Valid identifier or username was not provided (invalid or unsupported login type?)"
))));
}
.map_err(|e| err!(Request(InvalidUsername(warn!("Username is invalid: {e}")))))?;
if !services.globals.user_is_local(&user_id) {
return Err!(Request(Unknown("User ID does not belong to this homeserver")));
}
let emergency_mode_enabled = services.config.emergency_password.is_some();
if !info.is_user_match(&user_id) && !emergency_mode_enabled {
return Err!(Request(Exclusive("Username is not in an appservice namespace.")));
}
Ok(user_id)
}
+117
View File
@@ -0,0 +1,117 @@
use std::str::FromStr;
use jwt::{Algorithm, DecodingKey, Validation, decode};
use ruma::{
OwnedUserId, UserId,
api::client::session::login::v3::{Request, Token},
};
use serde::Deserialize;
use tuwunel_core::{Err, Result, at, config::JwtConfig, debug, err, jwt, warn};
use tuwunel_service::Services;
use crate::Ruma;
#[derive(Debug, Deserialize)]
struct Claim {
/// Subject is the localpart of the User MXID
sub: String,
}
pub(super) async fn handle_login(
services: &Services,
_body: &Ruma<Request>,
info: &Token,
) -> Result<OwnedUserId> {
let config = &services.config.jwt;
if !config.enable {
return Err!(Request(Unknown("JWT login is not enabled.")));
}
let claim = validate(config, &info.token)?;
let local = claim.sub.to_lowercase();
let server = &services.server.name;
let user_id = UserId::parse_with_server_name(local, server).map_err(|e| {
err!(Request(InvalidUsername("JWT subject is not a valid user MXID: {e}")))
})?;
if !services.users.exists(&user_id).await {
if !config.register_user {
return Err!(Request(NotFound("User {user_id} is not registered on this server.")));
}
services
.users
.create(&user_id, Some("*"), Some("jwt"))
.await?;
}
Ok(user_id)
}
fn validate(config: &JwtConfig, token: &str) -> Result<Claim> {
let verifier = init_verifier(config)?;
let validator = init_validator(config)?;
decode::<Claim>(token, &verifier, &validator)
.map(|decoded| (decoded.header, decoded.claims))
.inspect(|(head, claim)| debug!(?head, ?claim, "JWT token decoded"))
.map_err(|e| err!(Request(Forbidden("Invalid JWT token: {e}"))))
.map(at!(1))
}
fn init_verifier(config: &JwtConfig) -> Result<DecodingKey> {
let key = &config.key;
let format = config.format.as_str();
Ok(match format {
| "HMAC" => DecodingKey::from_secret(key.as_bytes()),
| "HMACB64" => DecodingKey::from_base64_secret(key.as_str())
.map_err(|e| err!(Config("jwt.key", "JWT key is not valid base64: {e}")))?,
| "ECDSA" => DecodingKey::from_ec_pem(key.as_bytes())
.map_err(|e| err!(Config("jwt.key", "JWT key is not valid PEM: {e}")))?,
| _ => return Err!(Config("jwt.format", "Key format {format:?} is not supported.")),
})
}
fn init_validator(config: &JwtConfig) -> Result<Validation> {
let alg = config.algorithm.as_str();
let alg = Algorithm::from_str(alg).map_err(|e| {
err!(Config("jwt.algorithm", "JWT algorithm is not recognized or configured {e}"))
})?;
let mut validator = Validation::new(alg);
let mut required_spec_claims: Vec<_> = ["sub"].into();
validator.validate_exp = config.validate_exp;
if config.require_exp {
required_spec_claims.push("exp");
}
validator.validate_nbf = config.validate_nbf;
if config.require_nbf {
required_spec_claims.push("nbf");
}
if !config.audience.is_empty() {
required_spec_claims.push("aud");
validator.set_audience(&config.audience);
}
if !config.issuer.is_empty() {
required_spec_claims.push("iss");
validator.set_issuer(&config.issuer);
}
if cfg!(debug_assertions) && !config.validate_signature {
warn!("JWT signature validation is disabled!");
validator.insecure_disable_signature_validation();
}
validator.set_required_spec_claims(&required_spec_claims);
debug!(?validator, "JWT configured");
Ok(validator)
}
+75
View File
@@ -0,0 +1,75 @@
use ruma::{OwnedUserId, UserId};
use tuwunel_core::{Err, Result, debug};
use tuwunel_service::Services;
use super::password_login;
/// Authenticates the given user through the configured LDAP server.
///
/// Creates the user if the user is found in the LDAP and do not already have an
/// account.
#[tracing::instrument(skip_all, fields(%user_id), name = "ldap")]
pub(super) async fn ldap_login(
services: &Services,
user_id: &UserId,
lowercased_user_id: &UserId,
password: &str,
) -> Result<OwnedUserId> {
let (user_dn, is_ldap_admin) = match services.config.ldap.bind_dn.as_ref() {
| Some(bind_dn) if bind_dn.contains("{username}") =>
(bind_dn.replace("{username}", lowercased_user_id.localpart()), false),
| _ => {
debug!("Searching user in LDAP");
let dns = services.users.search_ldap(user_id).await?;
if dns.len() >= 2 {
return Err!(Ldap("LDAP search returned two or more results"));
}
let Some((user_dn, is_admin)) = dns.first() else {
return password_login(services, user_id, lowercased_user_id, password).await;
};
(user_dn.clone(), *is_admin)
},
};
let user_id = services
.users
.auth_ldap(&user_dn, password)
.await
.map(|()| lowercased_user_id.to_owned())?;
// LDAP users are automatically created on first login attempt. This is a very
// common feature that can be seen on many services using a LDAP provider for
// their users (synapse, Nextcloud, Jellyfin, ...).
//
// LDAP users are crated with a dummy password but non empty because an empty
// password is reserved for deactivated accounts. The tuwunel password field
// will never be read to login a LDAP user so it's not an issue.
if !services.users.exists(lowercased_user_id).await {
services
.users
.create(lowercased_user_id, Some("*"), Some("ldap"))
.await?;
}
let is_tuwunel_admin = services
.admin
.user_is_admin(lowercased_user_id)
.await;
if is_ldap_admin && !is_tuwunel_admin {
services
.admin
.make_user_admin(lowercased_user_id)
.await?;
} else if !is_ldap_admin && is_tuwunel_admin {
services
.admin
.revoke_admin(lowercased_user_id)
.await?;
}
Ok(user_id)
}
+62
View File
@@ -0,0 +1,62 @@
use axum::extract::State;
use axum_client_ip::InsecureClientIp;
use futures::StreamExt;
use ruma::api::client::session::{logout, logout_all};
use tuwunel_core::Result;
use crate::Ruma;
/// # `POST /_matrix/client/v3/logout`
///
/// Log out the current device.
///
/// - Invalidates access token
/// - Deletes device metadata (device id, device display name, last seen ip,
/// last seen ts)
/// - Forgets to-device events
/// - Triggers device list updates
#[tracing::instrument(skip_all, fields(%client), name = "logout")]
pub(crate) async fn logout_route(
State(services): State<crate::State>,
InsecureClientIp(client): InsecureClientIp,
body: Ruma<logout::v3::Request>,
) -> Result<logout::v3::Response> {
services
.users
.remove_device(body.sender_user(), body.sender_device())
.await;
Ok(logout::v3::Response::new())
}
/// # `POST /_matrix/client/r0/logout/all`
///
/// Log out all devices of this user.
///
/// - Invalidates all access tokens
/// - Deletes all device metadata (device id, device display name, last seen ip,
/// last seen ts)
/// - Forgets all to-device events
/// - Triggers device list updates
///
/// Note: This is equivalent to calling [`GET
/// /_matrix/client/r0/logout`](fn.logout_route.html) from each device of this
/// user.
#[tracing::instrument(skip_all, fields(%client), name = "logout")]
pub(crate) async fn logout_all_route(
State(services): State<crate::State>,
InsecureClientIp(client): InsecureClientIp,
body: Ruma<logout_all::v3::Request>,
) -> Result<logout_all::v3::Response> {
services
.users
.all_device_ids(body.sender_user())
.for_each(|device_id| {
services
.users
.remove_device(body.sender_user(), device_id)
})
.await;
Ok(logout_all::v3::Response::new())
}
+162
View File
@@ -0,0 +1,162 @@
mod appservice;
mod jwt;
mod ldap;
mod logout;
mod password;
mod refresh;
mod token;
use axum::extract::State;
use axum_client_ip::InsecureClientIp;
use ruma::api::client::session::{
get_login_types::{
self,
v3::{
ApplicationServiceLoginType, JwtLoginType, LoginType, PasswordLoginType,
TokenLoginType,
},
},
login::{
self,
v3::{DiscoveryInfo, HomeserverInfo, LoginInfo},
},
};
use tuwunel_core::{Err, Result, info, utils, utils::stream::ReadyExt};
use tuwunel_service::users::device::generate_refresh_token;
use self::{ldap::ldap_login, password::password_login};
pub(crate) use self::{
logout::{logout_all_route, logout_route},
refresh::refresh_token_route,
token::login_token_route,
};
use super::{DEVICE_ID_LENGTH, TOKEN_LENGTH};
use crate::Ruma;
/// # `GET /_matrix/client/v3/login`
///
/// Get the supported login types of this server. One of these should be used as
/// the `type` field when logging in.
#[tracing::instrument(skip_all, fields(%client), name = "login")]
pub(crate) async fn get_login_types_route(
State(services): State<crate::State>,
InsecureClientIp(client): InsecureClientIp,
_body: Ruma<get_login_types::v3::Request>,
) -> Result<get_login_types::v3::Response> {
Ok(get_login_types::v3::Response::new(vec![
LoginType::Password(PasswordLoginType::default()),
LoginType::ApplicationService(ApplicationServiceLoginType::default()),
LoginType::Jwt(JwtLoginType::default()),
LoginType::Token(TokenLoginType {
get_login_token: services.config.login_via_existing_session,
}),
]))
}
/// # `POST /_matrix/client/v3/login`
///
/// Authenticates the user and returns an access token it can use in subsequent
/// requests.
///
/// - The user needs to authenticate using their password (or if enabled using a
/// json web token)
/// - If `device_id` is known: invalidates old access token of that device
/// - If `device_id` is unknown: creates a new device
/// - Returns access token that is associated with the user and device
///
/// Note: You can use [`GET
/// /_matrix/client/r0/login`](fn.get_supported_versions_route.html) to see
/// supported login types.
#[tracing::instrument(name = "login", skip_all, fields(%client, ?body.login_info))]
pub(crate) async fn login_route(
State(services): State<crate::State>,
InsecureClientIp(client): InsecureClientIp,
body: Ruma<login::v3::Request>,
) -> Result<login::v3::Response> {
// Validate login method
let user_id = match &body.login_info {
| LoginInfo::Password(info) => password::handle_login(&services, &body, info).await?,
| LoginInfo::Token(info) => token::handle_login(&services, &body, info).await?,
| LoginInfo::Jwt(info) => jwt::handle_login(&services, &body, info).await?,
| LoginInfo::ApplicationService(info) =>
appservice::handle_login(&services, &body, info).await?,
| _ => {
return Err!(Request(Unknown(debug_warn!(
?body.login_info,
?body.json_body,
"Invalid or unsupported login type",
))));
},
};
// Generate a new token for the device
let (access_token, expires_in) = services
.users
.generate_access_token(body.body.refresh_token);
// Generate a new refresh_token if requested by client
let refresh_token = expires_in.is_some().then(generate_refresh_token);
// Generate new device id if the user didn't specify one
let device_id = body
.device_id
.clone()
.unwrap_or_else(|| utils::random_string(DEVICE_ID_LENGTH).into());
// Determine if device_id was provided and exists in the db for this user
let device_exists = services
.users
.all_device_ids(&user_id)
.ready_any(|v| v == device_id)
.await;
if !device_exists {
services
.users
.create_device(
&user_id,
&device_id,
(&access_token, expires_in),
refresh_token.as_deref(),
body.initial_device_display_name.clone(),
Some(client.to_string()),
)
.await?;
} else {
services
.users
.set_access_token(
&user_id,
&device_id,
&access_token,
expires_in,
refresh_token.as_deref(),
)
.await?;
}
info!("{user_id} logged in");
let home_server = services.server.name.clone().into();
// send client well-known if specified so the client knows to reconfigure itself
let well_known: Option<DiscoveryInfo> = services
.config
.well_known
.client
.as_ref()
.map(ToString::to_string)
.map(HomeserverInfo::new)
.map(DiscoveryInfo::new);
#[allow(deprecated)]
Ok(login::v3::Response {
user_id,
access_token,
device_id,
home_server,
well_known,
expires_in,
refresh_token,
})
}
+101
View File
@@ -0,0 +1,101 @@
use futures::{FutureExt, TryFutureExt};
use ruma::{
OwnedUserId, UserId,
api::client::{
session::login::v3::{Password, Request},
uiaa,
},
};
use tuwunel_core::{Err, Result, debug_error, err, utils::hash};
use tuwunel_service::Services;
use super::ldap_login;
use crate::Ruma;
pub(super) async fn handle_login(
services: &Services,
body: &Ruma<Request>,
info: &Password,
) -> Result<OwnedUserId> {
#[allow(deprecated)]
let Password { identifier, password, user, .. } = info;
let user_id = if let Some(uiaa::UserIdentifier::UserIdOrLocalpart(user_id)) = identifier {
UserId::parse_with_server_name(user_id, &services.config.server_name)
} else if let Some(user) = user {
UserId::parse_with_server_name(user, &services.config.server_name)
} else {
return Err!(Request(Unknown(debug_warn!(
?body.login_info,
"Valid identifier or username was not provided (invalid or unsupported login type?)"
))));
}
.map_err(|e| err!(Request(InvalidUsername(warn!("Username is invalid: {e}")))))?;
let lowercased_user_id = UserId::parse_with_server_name(
user_id.localpart().to_lowercase(),
&services.config.server_name,
)?;
let user_is_remote = !services.globals.user_is_local(&user_id)
|| !services
.globals
.user_is_local(&lowercased_user_id);
if user_is_remote {
return Err!(Request(Unknown("User ID does not belong to this homeserver")));
}
if cfg!(feature = "ldap") && services.config.ldap.enable {
ldap_login(services, &user_id, &lowercased_user_id, password)
.boxed()
.await
} else {
password_login(services, &user_id, &lowercased_user_id, password).await
}
}
/// Authenticates the given user by its ID and its password.
///
/// Returns the user ID if successful, and an error otherwise.
#[tracing::instrument(skip_all, fields(%user_id), name = "password")]
pub(super) async fn password_login(
services: &Services,
user_id: &UserId,
lowercased_user_id: &UserId,
password: &str,
) -> Result<OwnedUserId> {
// Restrict login to accounts only of type 'password', including untyped
// legacy accounts which are equivalent to 'password'.
if services
.users
.origin(user_id)
.await
.is_ok_and(|origin| origin != "password")
{
return Err!(Request(Forbidden("Account does not permit password login.")));
}
let (hash, user_id) = services
.users
.password_hash(user_id)
.map_ok(|hash| (hash, user_id))
.or_else(|_| {
services
.users
.password_hash(lowercased_user_id)
.map_ok(|hash| (hash, lowercased_user_id))
})
.map_err(|_| err!(Request(Forbidden("Wrong username or password."))))
.await?;
if hash.is_empty() {
return Err!(Request(UserDeactivated("The user has been deactivated")));
}
hash::verify_password(password, &hash)
.inspect_err(|e| debug_error!("{e}"))
.map_err(|_| err!(Request(Forbidden("Wrong username or password."))))?;
Ok(user_id.to_owned())
}
+54
View File
@@ -0,0 +1,54 @@
use axum::extract::State;
use axum_client_ip::InsecureClientIp;
use ruma::api::client::session::refresh_token::v3::{Request, Response};
use tuwunel_core::{Err, Result, debug_info, err};
use tuwunel_service::users::device::generate_refresh_token;
use crate::Ruma;
/// # `POST /_matrix/client/v3/refresh`
///
/// Refresh an access token.
///
/// <https://spec.matrix.org/v1.15/client-server-api/#post_matrixclientv3refresh>
#[tracing::instrument(skip_all, fields(%client), name = "refresh_token")]
pub(crate) async fn refresh_token_route(
State(services): State<crate::State>,
InsecureClientIp(client): InsecureClientIp,
body: Ruma<Request>,
) -> Result<Response> {
let refresh_token_claim = body.body.refresh_token;
if !refresh_token_claim.starts_with("refresh_") {
return Err!(Request(Forbidden("Refresh token is malformed.")));
}
let (user_id, device_id, ..) = services
.users
.find_from_token(&refresh_token_claim)
.await
.map_err(|e| err!(Request(Forbidden("Refresh token is unrecognized: {e}"))))?;
// New tokens
let refresh_token = Some(generate_refresh_token());
let (access_token, expires_in_ms) = services.users.generate_access_token(true);
services
.users
.set_access_token(
&user_id,
&device_id,
&access_token,
expires_in_ms,
refresh_token.as_deref(),
)
.await?;
debug_info!(?user_id, ?device_id, ?expires_in_ms, "refreshed their access_token",);
Ok(Response {
access_token,
refresh_token,
expires_in_ms,
})
}
+100
View File
@@ -0,0 +1,100 @@
use std::time::Duration;
use axum::extract::State;
use axum_client_ip::InsecureClientIp;
use ruma::{
OwnedUserId,
api::client::{
session::{
get_login_token,
login::v3::{Request, Token},
},
uiaa,
},
};
use tuwunel_core::{Err, Result, utils::random_string};
use tuwunel_service::{Services, uiaa::SESSION_ID_LENGTH};
use super::TOKEN_LENGTH;
use crate::Ruma;
pub(super) async fn handle_login(
services: &Services,
_body: &Ruma<Request>,
info: &Token,
) -> Result<OwnedUserId> {
let Token { token } = info;
if !services.config.login_via_existing_session {
return Err!(Request(Unknown("Token login is not enabled.")));
}
services.users.find_from_login_token(token).await
}
/// # `POST /_matrix/client/v1/login/get_token`
///
/// Allows a logged-in user to get a short-lived token which can be used
/// to log in with the m.login.token flow.
///
/// <https://spec.matrix.org/v1.13/client-server-api/#post_matrixclientv1loginget_token>
#[tracing::instrument(skip_all, fields(%client), name = "login_token")]
pub(crate) async fn login_token_route(
State(services): State<crate::State>,
InsecureClientIp(client): InsecureClientIp,
body: Ruma<get_login_token::v1::Request>,
) -> Result<get_login_token::v1::Response> {
if !services.config.login_via_existing_session {
return Err!(Request(Forbidden("Login via an existing session is not enabled")));
}
// This route SHOULD have UIA
// TODO: How do we make only UIA sessions that have not been used before valid?
let (sender_user, sender_device) = body.sender();
let password_flow = uiaa::AuthFlow { stages: vec![uiaa::AuthType::Password] };
let mut uiaainfo = uiaa::UiaaInfo {
flows: vec![password_flow],
completed: Vec::new(),
params: Box::default(),
session: None,
auth_error: None,
};
match &body.auth {
| Some(auth) => {
let (worked, uiaainfo) = services
.uiaa
.try_auth(sender_user, sender_device, auth, &uiaainfo)
.await?;
if !worked {
return Err!(Uiaa(uiaainfo));
}
// Success!
},
| _ => match body.json_body.as_ref() {
| Some(json) => {
uiaainfo.session = Some(random_string(SESSION_ID_LENGTH));
services
.uiaa
.create(sender_user, sender_device, &uiaainfo, json);
return Err!(Uiaa(uiaainfo));
},
| _ => return Err!(Request(NotJson("No JSON body was sent when required."))),
},
}
let login_token = random_string(TOKEN_LENGTH);
let expires_in = services
.users
.create_login_token(sender_user, &login_token);
Ok(get_login_token::v1::Response {
expires_in: Duration::from_millis(expires_in),
login_token,
})
}
+1 -1
View File
@@ -166,7 +166,7 @@ where
let next_batch: OptionFuture<_> = queue
.pop_front()
.map(|(room, _)| async move {
.map(async |(room, _)| {
parents.insert(room);
let next_short_room_ids: Vec<_> = parents
+14 -23
View File
@@ -1,5 +1,5 @@
use axum::extract::State;
use futures::{FutureExt, TryStreamExt};
use futures::{FutureExt, TryFutureExt, TryStreamExt};
use ruma::{
OwnedEventId, RoomId, UserId,
api::client::state::{get_state_events, get_state_events_for_key, send_state_event},
@@ -17,7 +17,7 @@ use ruma::{
};
use serde_json::json;
use tuwunel_core::{
Err, Result, err,
Err, Result, err, is_false,
matrix::{Event, pdu::PduBuilder},
utils::BoolExt,
};
@@ -337,7 +337,7 @@ async fn allowed_to_send_state_event(
.resolve_alias(&alias, None)
.await
.map_err(|e| {
err!(Request(Unknown("Failed resolving alias \"{alias}\": {e}")))
err!(Request(BadAlias("Failed resolving alias \"{alias}\": {e}")))
})?;
if alias_room_id != room_id {
@@ -356,7 +356,7 @@ async fn allowed_to_send_state_event(
},
| StateEventType::RoomMember => match json.deserialize_as::<RoomMemberEventContent>() {
| Ok(membership_content) => {
let Ok(state_key) = UserId::parse(state_key) else {
let Ok(_state_key) = UserId::parse(state_key) else {
return Err!(Request(BadJson(
"Membership event has invalid or non-existent state key"
)));
@@ -371,17 +371,6 @@ async fn allowed_to_send_state_event(
)));
}
if services
.rooms
.state_cache
.is_joined(state_key, room_id)
.await
{
return Err!(Request(InvalidParam(
"{state_key} is already joined, an authorising user is not required."
)));
}
if !services.globals.user_is_local(&authorising_user) {
return Err!(Request(InvalidParam(
"Authorising user {authorising_user} does not belong to this \
@@ -389,17 +378,19 @@ async fn allowed_to_send_state_event(
)));
}
if !services
services
.rooms
.state_cache
.is_joined(&authorising_user, room_id)
.await
{
return Err!(Request(InvalidParam(
"Authorising user {authorising_user} is not in the room, they \
cannot authorise the join."
)));
}
.map(is_false!())
.map(BoolExt::into_result)
.map_err(|()| {
err!(Request(InvalidParam(
"Authorising user {authorising_user} is not in the room. They \
cannot authorise the join."
)))
})
.await?;
}
},
| Err(e) => {
+1 -1
View File
@@ -75,7 +75,7 @@ async fn share_encrypted_room(
.get_shared_rooms(sender_user, user_id)
.ready_filter(|&room_id| Some(room_id) != ignore_room)
.map(ToOwned::to_owned)
.broad_any(|other_room_id| async move {
.broad_any(async |other_room_id| {
services
.rooms
.state_accessor
+392 -346
View File
File diff suppressed because it is too large. Load diff
+184 -121
View File
@@ -1,5 +1,5 @@
use std::{
cmp::{self, Ordering},
cmp::Ordering,
collections::{BTreeMap, BTreeSet, HashMap, HashSet},
ops::Deref,
time::Duration,
@@ -8,7 +8,7 @@ use std::{
use axum::extract::State;
use futures::{
FutureExt, Stream, StreamExt, TryFutureExt,
future::{OptionFuture, join3, try_join4},
future::{OptionFuture, join3, try_join5},
pin_mut,
};
use ruma::{
@@ -18,6 +18,7 @@ use ruma::{
events::{
AnyRawAccountDataEvent, AnySyncEphemeralRoomEvent, StateEventType, TimelineEventType,
room::member::{MembershipState, RoomMemberEventContent},
typing::TypingEventContent,
},
serde::Raw,
uint,
@@ -27,7 +28,7 @@ use tuwunel_core::{
matrix::{Event, TypeStateKey, pdu::PduCount},
trace,
utils::{
BoolExt, FutureBoolExt, IterStream, ReadyExt, TryFutureExtExt,
BoolExt, FutureBoolExt, IterStream, ReadyExt, TryFutureExtExt, TryReadyExt,
future::ReadyEqExt,
math::{ruma_from_usize, usize_from_ruma},
},
@@ -60,31 +61,16 @@ pub(crate) async fn sync_events_v5_route(
body: Ruma<sync_events::v5::Request>,
) -> Result<sync_events::v5::Response> {
debug_assert!(DEFAULT_BUMP_TYPES.is_sorted(), "DEFAULT_BUMP_TYPES is not sorted");
let sender_user = body
.sender_user
.as_ref()
.expect("user is authenticated");
let sender_device = body
.sender_device
.as_ref()
.expect("user is authenticated");
let mut body = body.body;
// Setup watchers, so if there's no response, we can wait for them
let watcher = services.sync.watch(sender_user, sender_device);
let next_batch = services.globals.next_count()?;
let conn_id = body.conn_id.clone();
let sender_user = body.sender_user();
let sender_device = body.sender_device();
let snake_key = into_snake_key(sender_user, sender_device, body.conn_id.clone());
let globalsince = body
.pos
.as_ref()
.and_then(|string| string.parse().ok())
.unwrap_or(0);
let snake_key = into_snake_key(sender_user, sender_device, conn_id);
if globalsince != 0 && !services.sync.snake_connection_cached(&snake_key) {
return Err!(Request(UnknownPos(
"Connection data unknown to server; restarting sync stream."
@@ -98,10 +84,16 @@ pub(crate) async fn sync_events_v5_route(
.forget_snake_sync_connection(&snake_key);
}
// Setup watchers, so if there's no response, we can wait for them
let watcher = services.sync.watch(sender_user, sender_device);
let next_batch = services.globals.wait_pending().await?;
// Get sticky parameters from cache
let mut cached = body.body.clone();
let known_rooms = services
.sync
.update_snake_sync_request_with_cache(&snake_key, &mut body);
.update_snake_sync_request_with_cache(&snake_key, &mut cached);
let all_joined_rooms = services
.rooms
@@ -135,33 +127,35 @@ pub(crate) async fn sync_events_v5_route(
.chain(all_invited_rooms.clone())
.chain(all_knocked_rooms.clone());
let pos = next_batch.clone().to_string();
let pos = next_batch.to_string();
let mut todo_rooms: TodoRooms = BTreeMap::new();
let sync_info: SyncInfo<'_> = (sender_user, sender_device, globalsince, &body);
let sync_info: SyncInfo<'_> = (sender_user, sender_device, globalsince, &cached);
let account_data = collect_account_data(services, sync_info).map(Ok);
let account_data = collect_account_data(services, sync_info, next_batch).map(Ok);
let e2ee = collect_e2ee(services, sync_info, all_joined_rooms.clone());
let e2ee = collect_e2ee(services, sync_info, next_batch, all_joined_rooms.clone());
let to_device = collect_to_device(services, sync_info, next_batch).map(Ok);
let receipts = collect_receipts(services).map(Ok);
let receipts = collect_receipts(services, sync_info, next_batch).map(Ok);
let (account_data, e2ee, to_device, receipts) =
try_join4(account_data, e2ee, to_device, receipts).await?;
let typing = collect_typing_events(services, sync_info, next_batch, all_joined_rooms.clone());
let (account_data, e2ee, to_device, receipts, typing) =
try_join5(account_data, e2ee, to_device, receipts, typing).await?;
let extensions = sync_events::v5::response::Extensions {
account_data,
e2ee,
to_device,
receipts,
typing: sync_events::v5::response::Typing::default(),
typing,
};
let mut response = sync_events::v5::Response {
txn_id: body.txn_id.clone(),
txn_id: cached.txn_id.clone(),
pos,
lists: BTreeMap::new(),
rooms: BTreeMap::new(),
@@ -173,7 +167,7 @@ pub(crate) async fn sync_events_v5_route(
sync_info,
all_invited_rooms.clone(),
all_joined_rooms.clone(),
all_rooms,
all_rooms.clone(),
&mut todo_rooms,
&known_rooms,
&mut response,
@@ -189,7 +183,7 @@ pub(crate) async fn sync_events_v5_route(
all_invited_rooms.clone(),
&todo_rooms,
&mut response,
&body,
&cached,
)
.await?;
@@ -206,11 +200,18 @@ pub(crate) async fn sync_events_v5_route(
.to_device
.clone()
.is_none_or(|to| to.events.is_empty())
&& response.extensions.typing.is_empty()
{
// Hang a few seconds so requests are not spammed
// Stop hanging if new info arrives
let default = Duration::from_secs(30);
let duration = cmp::min(body.timeout.unwrap_or(default), default);
let timeout_default = services.config.client_sync_timeout_default;
let timeout_min = services.config.client_sync_timeout_min;
let timeout_max = services.config.client_sync_timeout_max;
let duration = body
.timeout
.unwrap_or_else(|| Duration::from_millis(timeout_default))
.clamp(Duration::from_millis(timeout_min), Duration::from_millis(timeout_max));
_ = tokio::time::timeout(duration, watcher).await;
}
@@ -338,7 +339,6 @@ where
.collect();
new_known_rooms.extend(new_rooms);
//new_known_rooms.extend(room_ids..cloned());
for room_id in room_ids {
let todo_room = todo_rooms.entry(room_id.to_owned()).or_insert((
BTreeSet::new(),
@@ -469,8 +469,8 @@ where
let mut receipts: Vec<Raw<AnySyncEphemeralRoomEvent>> = services
.rooms
.read_receipt
.readreceipts_since(room_id, *roomsince)
.filter_map(|(read_user, _ts, v)| async move {
.readreceipts_since(room_id, *roomsince, Some(next_batch))
.filter_map(async |(read_user, _ts, v)| {
services
.users
.user_is_ignored(read_user, sender_user)
@@ -494,15 +494,15 @@ where
.insert(room_id.clone(), pack_receipts(Box::new(receipts.into_iter())));
}
if roomsince != &0
if *roomsince != 0
&& timeline_pdus.is_empty()
&& receipt_size == 0
&& response
.extensions
.account_data
.rooms
.get(room_id)
.is_none_or(Vec::is_empty)
&& receipt_size == 0
{
continue;
}
@@ -519,7 +519,7 @@ where
}))
})?
.or_else(|| {
if roomsince != &0 {
if *roomsince != 0 {
Some(roomsince.to_string())
} else {
None
@@ -548,7 +548,7 @@ where
let required_state = required_state_request
.iter()
.stream()
.filter_map(|state| async move {
.filter_map(async |state| {
services
.rooms
.state_accessor
@@ -560,29 +560,40 @@ where
.collect()
.await;
// Heroes
let heroes: Vec<_> = services
let room_name = services
.rooms
.state_cache
.room_members(room_id)
.ready_filter(|member| *member != sender_user)
.filter_map(|user_id| {
services
.rooms
.state_accessor
.get_member(room_id, user_id)
.map_ok(|memberevent| sync_events::v5::response::Hero {
user_id: user_id.into(),
name: memberevent.displayname,
avatar: memberevent.avatar_url,
})
.ok()
})
.take(5)
.collect()
.await;
.state_accessor
.get_name(room_id)
.await
.ok();
let name = match heroes.len().cmp(&(1_usize)) {
// Heroes
let heroes: Vec<_> = if room_name.is_none() {
services
.rooms
.state_cache
.room_members(room_id)
.ready_filter(|member| *member != sender_user)
.filter_map(|user_id| {
services
.rooms
.state_accessor
.get_member(room_id, user_id)
.map_ok(|memberevent| sync_events::v5::response::Hero {
user_id: user_id.into(),
name: memberevent.displayname,
avatar: memberevent.avatar_url,
})
.ok()
})
.take(5)
.collect()
.await
} else {
vec![]
};
let hero_name = match heroes.len().cmp(&(1_usize)) {
| Ordering::Greater => {
let firsts = heroes[1..]
.iter()
@@ -616,27 +627,24 @@ where
None
};
let room_avatar = match services
.rooms
.state_accessor
.get_avatar(room_id)
.await
{
| ruma::JsOption::Some(avatar) => ruma::JsOption::from_option(avatar.url),
| ruma::JsOption::Null => ruma::JsOption::Null,
| ruma::JsOption::Undefined => ruma::JsOption::Undefined,
};
rooms.insert(room_id.clone(), sync_events::v5::response::Room {
name: services
.rooms
.state_accessor
.get_name(room_id)
.await
.ok()
.or(name),
avatar: match heroes_avatar {
| Some(heroes_avatar) => ruma::JsOption::Some(heroes_avatar),
| _ => match services
.rooms
.state_accessor
.get_avatar(room_id)
.await
{
| ruma::JsOption::Some(avatar) => ruma::JsOption::from_option(avatar.url),
| ruma::JsOption::Null => ruma::JsOption::Null,
| ruma::JsOption::Undefined => ruma::JsOption::Undefined,
},
avatar: if room_name.is_some() {
room_avatar
} else {
ruma::JsOption::from_option(heroes_avatar)
},
name: room_name.or(hero_name),
initial: Some(roomsince == &0),
is_dm: None,
invite_state,
@@ -691,9 +699,11 @@ where
}
Ok(rooms)
}
async fn collect_account_data(
services: &Services,
(sender_user, _, globalsince, body): (&UserId, &DeviceId, u64, &sync_events::v5::Request),
next_batch: u64,
) -> sync_events::v5::response::AccountData {
let mut account_data = sync_events::v5::response::AccountData {
global: Vec::new(),
@@ -711,7 +721,7 @@ async fn collect_account_data(
account_data.global = services
.account_data
.changes_since(None, sender_user, globalsince, None)
.changes_since(None, sender_user, globalsince, Some(next_batch))
.ready_filter_map(|e| extract_variant!(e, AnyRawAccountDataEvent::Global))
.collect()
.await;
@@ -722,7 +732,7 @@ async fn collect_account_data(
room.clone(),
services
.account_data
.changes_since(Some(room), sender_user, globalsince, None)
.changes_since(Some(room), sender_user, globalsince, Some(next_batch))
.ready_filter_map(|e| extract_variant!(e, AnyRawAccountDataEvent::Room))
.collect()
.await,
@@ -741,6 +751,7 @@ async fn collect_e2ee<'a, Rooms>(
u64,
&sync_events::v5::Request,
),
next_batch: u64,
all_joined_rooms: Rooms,
) -> Result<sync_events::v5::response::E2EE>
where
@@ -756,7 +767,7 @@ where
device_list_changes.extend(
services
.users
.keys_changed(sender_user, globalsince, None)
.keys_changed(sender_user, globalsince, Some(next_batch))
.map(ToOwned::to_owned)
.collect::<Vec<_>>()
.await,
@@ -832,44 +843,51 @@ where
.await;
for (key, id) in current_state_ids {
if since_state_ids.get(&key) != Some(&id) {
let Ok(pdu) = services.rooms.timeline.get_pdu(&id).await else {
error!("Pdu in state not found: {id}");
continue;
};
if pdu.kind == TimelineEventType::RoomMember {
if let Some(Ok(user_id)) = pdu.state_key.as_deref().map(UserId::parse)
{
if user_id == sender_user {
continue;
}
if since_state_ids.get(&key) == Some(&id) {
continue;
}
let content: RoomMemberEventContent = pdu.get_content()?;
match content.membership {
| MembershipState::Join => {
// A new user joined an encrypted room
if !share_encrypted_room(
services,
sender_user,
user_id,
Some(room_id),
)
.await
{
device_list_changes.insert(user_id.to_owned());
}
},
| MembershipState::Leave => {
// Write down users that have left encrypted rooms we
// are in
left_encrypted_users.insert(user_id.to_owned());
},
| _ => {},
}
let Ok(pdu) = services.rooms.timeline.get_pdu(&id).await else {
error!("Pdu in state not found: {id}");
continue;
};
if pdu.kind != TimelineEventType::RoomMember {
continue;
}
let Some(Ok(user_id)) = pdu.state_key.as_deref().map(UserId::parse) else {
continue;
};
if user_id == sender_user {
continue;
}
let content: RoomMemberEventContent = pdu.get_content()?;
match content.membership {
| MembershipState::Join => {
// A new user joined an encrypted room
if !share_encrypted_room(
services,
sender_user,
user_id,
Some(room_id),
)
.await
{
device_list_changes.insert(user_id.to_owned());
}
}
},
| MembershipState::Leave => {
// Write down users that have left encrypted rooms we
// are in
left_encrypted_users.insert(user_id.to_owned());
},
| _ => {},
}
}
if joined_since_last_sync || new_encrypted_room {
// If the user is in a new encrypted room, give them all joined users
device_list_changes.extend(
@@ -895,7 +913,7 @@ where
device_list_changes.extend(
services
.users
.room_keys_changed(room_id, globalsince, None)
.room_keys_changed(room_id, globalsince, Some(next_batch))
.map(|(user_id, _)| user_id)
.map(ToOwned::to_owned)
.collect::<Vec<_>>()
@@ -953,7 +971,52 @@ async fn collect_to_device(
})
}
async fn collect_receipts(_services: &Services) -> sync_events::v5::response::Receipts {
async fn collect_typing_events<'a, Rooms>(
services: &Services,
(sender_user, _, _, body): SyncInfo<'_>,
_next_batch: u64,
rooms: Rooms,
) -> Result<sync_events::v5::response::Typing>
where
Rooms: Iterator<Item = &'a RoomId> + Send + 'a,
{
use sync_events::v5::response::Typing;
if !body.extensions.typing.enabled.unwrap_or(false) {
return Ok(Typing::default());
}
rooms
.stream()
.filter_map(async |room_id| {
services
.rooms
.typing
.typing_users_for_user(room_id, sender_user)
.inspect_err(|e| warn!(%room_id, "Failed to get typing events for room: {e}"))
.await
.ok()
.filter(|users| !users.is_empty())
.map(|users| Ok((room_id, users)))
})
.ready_try_fold_default(|mut response: Typing, (room_id, users)| {
response.rooms.insert(
room_id.to_owned(),
Raw::new(&ruma::events::typing::SyncTypingEvent {
content: TypingEventContent::new(users),
})?,
);
Ok(response)
})
.await
}
async fn collect_receipts(
_services: &Services,
(_sender_user, _, _globalsince, _body): SyncInfo<'_>,
_next_batch: u64,
) -> sync_events::v5::response::Receipts {
sync_events::v5::response::Receipts { rooms: BTreeMap::new() }
// TODO: get explicitly requested read receipts
}
+6 -7
View File
@@ -1,5 +1,5 @@
use axum::extract::State;
use futures::StreamExt;
use futures::{StreamExt, TryStreamExt};
use ruma::{api::client::threads::get_threads, uint};
use tuwunel_core::{
Result, at,
@@ -35,18 +35,17 @@ pub(crate) async fn get_threads_route(
.rooms
.threads
.threads_until(body.sender_user(), &body.room_id, from, &body.include)
.await?
.take(limit)
.filter_map(|(count, pdu)| async move {
services
.try_filter_map(async |(count, pdu)| {
Ok(services
.rooms
.state_accessor
.user_can_see_event(body.sender_user(), &body.room_id, &pdu.event_id)
.await
.then_some((count, pdu))
.then_some((count, pdu)))
})
.collect()
.await;
.try_collect()
.await?;
Ok(get_threads::v1::Response {
next_batch: threads
+1 -2
View File
@@ -41,7 +41,6 @@ pub(crate) async fn send_event_to_device_route(
map.insert(target_device_id_maybe.clone(), event.clone());
let mut messages = BTreeMap::new();
messages.insert(target_user_id.clone(), map);
let count = services.globals.next_count()?;
let mut buf = EduBuf::new();
serde_json::to_writer(
@@ -49,7 +48,7 @@ pub(crate) async fn send_event_to_device_route(
&federation::transactions::edu::Edu::DirectToDevice(DirectDeviceContent {
sender: sender_user.to_owned(),
ev_type: body.event_type.clone(),
message_id: count.to_string().into(),
message_id: services.globals.next_count().to_string().into(),
messages,
}),
)
+3 -3
View File
@@ -60,7 +60,7 @@ pub(crate) async fn get_mutual_rooms_route(
})
}
/// # `DELETE /_matrix/client/unstable/uk.tcpip.msc4133/profile/:user_id/us.cloke.msc4175.tz`
/// # `DELETE /_matrix/client/unstable/uk.tcpip.msc4133/profile/{user_id}/us.cloke.msc4175.tz`
///
/// Deletes the `tz` (timezone) of a user, as per MSC4133 and MSC4175.
///
@@ -88,7 +88,7 @@ pub(crate) async fn delete_timezone_key_route(
Ok(delete_timezone_key::unstable::Response {})
}
/// # `PUT /_matrix/client/unstable/uk.tcpip.msc4133/profile/:user_id/us.cloke.msc4175.tz`
/// # `PUT /_matrix/client/unstable/uk.tcpip.msc4133/profile/{user_id}/us.cloke.msc4175.tz`
///
/// Updates the `tz` (timezone) of a user, as per MSC4133 and MSC4175.
///
@@ -270,7 +270,7 @@ pub(crate) async fn delete_profile_key_route(
Ok(delete_profile_key::unstable::Response {})
}
/// # `GET /_matrix/client/unstable/uk.tcpip.msc4133/profile/:user_id/us.cloke.msc4175.tz`
/// # `GET /_matrix/client/unstable/uk.tcpip.msc4133/profile/{user_id}/us.cloke.msc4175.tz`
///
/// Returns the `timezone` of the user as per MSC4133 and MSC4175.
///
+5 -1
View File
@@ -6,7 +6,10 @@ use ruma::{
};
use tuwunel_core::{
Result,
utils::{future::BoolExt, stream::BroadbandExt},
utils::{
future::BoolExt,
stream::{BroadbandExt, ReadyExt},
},
};
use crate::Ruma;
@@ -34,6 +37,7 @@ pub(crate) async fn search_users_route(
let mut users = services
.users
.stream()
.ready_filter(|&user_id| user_id != sender_user)
.map(ToOwned::to_owned)
.broad_filter_map(async |user_id| {
let display_name = services.users.displayname(&user_id).await.ok();
+1 -1
View File
@@ -1,4 +1,4 @@
#![type_length_limit = "16384"] //TODO: reduce me
#![type_length_limit = "65536"] //TODO: reduce me
#![allow(clippy::toplevel_ref_arg)]
pub mod client;
+17 -16
View File
@@ -35,6 +35,7 @@ pub fn build(router: Router<State>, server: &Server) -> Router<State> {
.ruma_route(&client::get_login_types_route)
.ruma_route(&client::login_route)
.ruma_route(&client::login_token_route)
.ruma_route(&client::refresh_token_route)
.ruma_route(&client::whoami_route)
.ruma_route(&client::logout_route)
.ruma_route(&client::logout_all_route)
@@ -124,23 +125,23 @@ pub fn build(router: Router<State>, server: &Server) -> Router<State> {
// Ruma doesn't have support for multiple paths for a single endpoint yet, and these routes
// share one Ruma request / response type pair with {get,send}_state_event_for_key_route
.route(
"/_matrix/client/r0/rooms/:room_id/state/:event_type",
"/_matrix/client/r0/rooms/{room_id}/state/{event_type}",
get(client::get_state_events_for_empty_key_route)
.put(client::send_state_event_for_empty_key_route),
)
.route(
"/_matrix/client/v3/rooms/:room_id/state/:event_type",
"/_matrix/client/v3/rooms/{room_id}/state/{event_type}",
get(client::get_state_events_for_empty_key_route)
.put(client::send_state_event_for_empty_key_route),
)
// These two endpoints allow trailing slashes
.route(
"/_matrix/client/r0/rooms/:room_id/state/:event_type/",
"/_matrix/client/r0/rooms/{room_id}/state/{event_type}/",
get(client::get_state_events_for_empty_key_route)
.put(client::send_state_event_for_empty_key_route),
)
.route(
"/_matrix/client/v3/rooms/:room_id/state/:event_type/",
"/_matrix/client/v3/rooms/{room_id}/state/{event_type}/",
get(client::get_state_events_for_empty_key_route)
.put(client::send_state_event_for_empty_key_route),
)
@@ -179,7 +180,7 @@ pub fn build(router: Router<State>, server: &Server) -> Router<State> {
.ruma_route(&client::get_mutual_rooms_route)
.ruma_route(&client::get_room_summary)
.route(
"/_matrix/client/unstable/im.nheko.summary/rooms/:room_id_or_alias/summary",
"/_matrix/client/unstable/im.nheko.summary/rooms/{room_id_or_alias}/summary",
get(client::get_room_summary_legacy)
)
.ruma_route(&client::well_known_support)
@@ -193,7 +194,7 @@ pub fn build(router: Router<State>, server: &Server) -> Router<State> {
.ruma_route(&server::get_server_version_route)
.route("/_matrix/key/v2/server", get(server::get_server_keys_route))
.route(
"/_matrix/key/v2/server/:key_id",
"/_matrix/key/v2/server/{key_id}",
get(server::get_server_keys_deprecated_route),
)
.ruma_route(&server::get_public_rooms_route)
@@ -227,9 +228,9 @@ pub fn build(router: Router<State>, server: &Server) -> Router<State> {
.route("/_tuwunel/local_user_count", get(client::tuwunel_local_user_count));
} else {
router = router
.route("/_matrix/federation/*path", any(federation_disabled))
.route("/_matrix/federation/{*path}", any(federation_disabled))
.route("/.well-known/matrix/server", any(federation_disabled))
.route("/_matrix/key/*path", any(federation_disabled))
.route("/_matrix/key/{*path}", any(federation_disabled))
.route("/_tuwunel/local_user_count", any(federation_disabled));
}
@@ -247,27 +248,27 @@ pub fn build(router: Router<State>, server: &Server) -> Router<State> {
get(client::get_media_preview_legacy_legacy_route),
)
.route(
"/_matrix/media/v1/download/:server_name/:media_id",
"/_matrix/media/v1/download/{server_name}/{media_id}",
get(client::get_content_legacy_legacy_route),
)
.route(
"/_matrix/media/v1/download/:server_name/:media_id/:file_name",
"/_matrix/media/v1/download/{server_name}/{media_id}/{file_name}",
get(client::get_content_as_filename_legacy_legacy_route),
)
.route(
"/_matrix/media/v1/thumbnail/:server_name/:media_id",
"/_matrix/media/v1/thumbnail/{server_name}/{media_id}",
get(client::get_content_thumbnail_legacy_legacy_route),
);
} else {
router = router
.route("/_matrix/media/v1/*path", any(legacy_media_disabled))
.route("/_matrix/media/v1/{*path}", any(legacy_media_disabled))
.route("/_matrix/media/v3/config", any(legacy_media_disabled))
.route("/_matrix/media/v3/download/*path", any(legacy_media_disabled))
.route("/_matrix/media/v3/thumbnail/*path", any(legacy_media_disabled))
.route("/_matrix/media/v3/download/{*path}", any(legacy_media_disabled))
.route("/_matrix/media/v3/thumbnail/{*path}", any(legacy_media_disabled))
.route("/_matrix/media/v3/preview_url", any(redirect_legacy_preview))
.route("/_matrix/media/r0/config", any(legacy_media_disabled))
.route("/_matrix/media/r0/download/*path", any(legacy_media_disabled))
.route("/_matrix/media/r0/thumbnail/*path", any(legacy_media_disabled))
.route("/_matrix/media/r0/download/{*path}", any(legacy_media_disabled))
.route("/_matrix/media/r0/thumbnail/{*path}", any(legacy_media_disabled))
.route("/_matrix/media/r0/preview_url", any(redirect_legacy_preview));
}
+6 -9
View File
@@ -1,6 +1,5 @@
use std::{mem, ops::Deref};
use std::{fmt::Debug, mem, ops::Deref};
use async_trait::async_trait;
use axum::{body::Body, extract::FromRequest};
use bytes::{BufMut, Bytes, BytesMut};
use ruma::{
@@ -14,6 +13,7 @@ use super::{auth, auth::Auth, request, request::Request};
use crate::State;
/// Extractor for Ruma request structs
#[derive(Debug)]
pub(crate) struct Args<T> {
/// Request struct body
pub(crate) body: T,
@@ -39,10 +39,7 @@ pub(crate) struct Args<T> {
pub(crate) json_body: Option<CanonicalJsonValue>,
}
impl<T> Args<T>
where
T: IncomingRequest + Send + Sync + 'static,
{
impl<T> Args<T> {
#[inline]
pub(crate) fn sender(&self) -> (&UserId, &DeviceId) {
(self.sender_user(), self.sender_device())
@@ -72,20 +69,20 @@ where
impl<T> Deref for Args<T>
where
T: IncomingRequest + Send + Sync + 'static,
T: Sync,
{
type Target = T;
fn deref(&self) -> &Self::Target { &self.body }
}
#[async_trait]
impl<T> FromRequest<State, Body> for Args<T>
where
T: IncomingRequest + Send + Sync + 'static,
T: IncomingRequest + Debug + Send + Sync + 'static,
{
type Rejection = Error;
#[tracing::instrument(name = "ar", level = "debug", skip(services), ret, err)]
async fn from_request(
request: hyper::Request<Body>,
services: &State,
Loaded 100 of 252 files, more files were not shown because too many files have changed in this diff. Show more