diff --git a/README.md b/README.md index 8e4b1b7..bff15e6 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,43 @@ # Conduit ### A Matrix homeserver written in Rust -[![Liberapay](https://img.shields.io/liberapay/receives/timokoesters?logo=liberapay)](https://liberapay.com/timokoesters) -[![Matrix](https://img.shields.io/matrix/conduit:conduit.rs?server_fqdn=conduit.koesters.xyz)](https://matrix.to/#/#conduit:matrix.org) - #### What is the goal? A fast Matrix homeserver that's easy to set up and just works. You can install it on a mini-computer like the Raspberry Pi to host Matrix for your family, friends or company. + #### Can I try it out? Yes! Just open a Matrix client ( or Element Android for example) and register on the `https://conduit.koesters.xyz` homeserver. + +#### What is it build on? + +- [Ruma](https://www.ruma.io): Useful structures for endpoint requests and + responses that can be (de)serialized +- [Sled](https://github.com/spacejam/sled): A simple (key, value) database with + good performance +- [Rocket](https://rocket.rs): A flexible web framework + + +#### What are the biggest things still missing? + +- Most federation features (invites, e2ee) +- Push notifications on mobile +- Notification settings +- Lots of testing + +Check out the [Conduit 1.0 Release Milestone](https://gitlab.com/famedly/conduit/-/milestones/3). + + #### How can I deploy my own? ##### Deploy -Download or compile a conduit binary and call it from somewhere like a systemd script. [Read +Download or compile a Conduit binary, set up the config and call it from somewhere like a systemd script. [Read more](DEPLOY.md) ##### Deploy using Docker @@ -33,32 +51,15 @@ docker run -d -p 8448:8000 -v db:/srv/conduit/.local/share/conduit matrixconduit Or build and run it with docker or docker-compose. [Read more](docker/README.md) -#### What is it build on? - -- [Ruma](https://www.ruma.io): Useful structures for endpoint requests and - responses that can be (de)serialized -- [Sled](https://github.com/spacejam/sled): A simple (key, value) database with - good performance -- [Rocket](https://rocket.rs): A flexible web framework - -#### What are the biggest things still missing? - -- Appservices (Bridges and Bots) -- Most federation features (invites, e2ee) -- Push notifications on mobile -- Notification settings -- Lots of testing - -Also check out the [milestones](https://git.koesters.xyz/timo/conduit/milestones). #### How can I contribute? 1. Look for an issue you would like to work on and make sure it's not assigned to other users 2. Ask someone to assign the issue to you (comment on the issue or chat in - #conduit:matrix.org) -3. Fork the repo and work on the issue. #conduit:matrix.org is happy to help :) -4. Submit a PR + #conduit:nordgedanken.dev) +3. Fork the repo and work on the issue. #conduit:nordgedanken.dev is happy to help :) +4. Submit a MR #### Donate diff --git a/src/database/sending.rs b/src/database/sending.rs index 9b5d71a..ffb2c31 100644 --- a/src/database/sending.rs +++ b/src/database/sending.rs @@ -275,11 +275,9 @@ impl Sending { }; prefix.push(0xff); - if servercurrentpdus + servercurrentpdus .compare_and_swap(prefix, Option::<&[u8]>::None, Some(&[])) // Try to reserve - == Ok(Ok(())) { true } else { - false - } + == Ok(Ok(())) }) { servercurrentpdus.insert(&key, &[]).unwrap(); diff --git a/src/main.rs b/src/main.rs index 3818433..dc1d9d6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ #![allow(clippy::suspicious_else_formatting)] #![warn(rust_2018_idioms)] +#![allow(clippy::suspicious_else_formatting)] pub mod appservice_server; pub mod client_server; diff --git a/src/ruma_wrapper.rs b/src/ruma_wrapper.rs index 686e99b..8513221 100644 --- a/src/ruma_wrapper.rs +++ b/src/ruma_wrapper.rs @@ -1,13 +1,9 @@ use crate::Error; use ruma::{ - api::{AuthScheme, IncomingRequest, OutgoingRequest}, identifiers::{DeviceId, UserId}, Outgoing, }; -use std::{ - convert::{TryFrom, TryInto}, - ops::Deref, -}; +use std::{convert::TryInto, ops::Deref}; #[cfg(feature = "conduit_bin")] use { @@ -24,6 +20,8 @@ use { tokio::io::AsyncReadExt, Request, State, }, + ruma::api::{AuthScheme, OutgoingRequest}, + std::convert::TryFrom, std::io::Cursor, }; diff --git a/src/server_server.rs b/src/server_server.rs index de8954f..0038c33 100644 --- a/src/server_server.rs +++ b/src/server_server.rs @@ -2,7 +2,7 @@ use crate::{client_server, utils, ConduitResult, Database, Error, PduEvent, Resu use http::header::{HeaderValue, AUTHORIZATION, HOST}; use log::{info, warn}; use regex::Regex; -use rocket::{get, post, put, response::content::Json, State}; +use rocket::{response::content::Json, State}; use ruma::{ api::{ federation::{ @@ -28,6 +28,10 @@ use std::{ net::{IpAddr, SocketAddr}, time::{Duration, SystemTime}, }; +#[cfg(feature = "conduit_bin")] +use { + rocket::{get, post, put} +}; #[tracing::instrument(skip(globals))] pub async fn send_request( @@ -553,6 +557,12 @@ pub async fn send_transaction_message_route<'a>( // TODO: redact event if hashing fails let (event_id, value) = crate::pdu::process_incoming_pdu(pdu); + // Skip the pdu if we already know about it + if db.rooms.get_pdu_id(&event_id)?.is_some() { + resolved_map.insert(event_id, Err("We already know about this event".into())); + continue; + } + let pdu = serde_json::from_value::( serde_json::to_value(&value).expect("CanonicalJsonObj is a valid JsonValue"), ) @@ -583,7 +593,7 @@ pub async fn send_transaction_message_route<'a>( .get("users") .and_then(|users| users.as_sequence()) .map_or_else( - || Vec::new(), + Vec::new, |users| { users .iter() @@ -615,7 +625,7 @@ pub async fn send_transaction_message_route<'a>( .and_then(|string| { UserId::parse_with_server_name(string, db.globals.server_name()).ok() }); - + #[allow(clippy::blocks_in_if_conditions)] if bridge_user_id.map_or(false, |bridge_user_id| { db.rooms .is_joined(&bridge_user_id, room_id) diff --git a/tests/Complement.Dockerfile b/tests/Complement.Dockerfile index 370db7c..7deb6e8 100644 --- a/tests/Complement.Dockerfile +++ b/tests/Complement.Dockerfile @@ -9,7 +9,9 @@ ARG SCCACHE_ENDPOINT ARG SCCACHE_S3_USE_SSL COPY . . -RUN test -e cached_target/release/conduit || cargo build --release +RUN mkdir -p target/release +RUN test -e cached_target/release/conduit && cp cached_target/release/conduit target/release/conduit || cargo build --release + FROM valkum/docker-rust-ci:latest WORKDIR /workdir @@ -37,4 +39,4 @@ CMD ([ -z "${COMPLEMENT_CA}" ] && echo "Error: Need Complement PKI support" && t sed -i "s/your.server.name/${SERVER_NAME}/g" caddy.json && \ /workdir/caddy start --config caddy.json > /dev/null && \ /workdir/conduit - \ No newline at end of file +