Browse Source

Merge remote-tracking branch 'upstream/master' into pushers

merge-requests/18/head
Devin Ragotzy 5 years ago
parent
commit
aa1c2bf31b
  1. 49
      README.md
  2. 6
      src/database/sending.rs
  3. 1
      src/main.rs
  4. 8
      src/ruma_wrapper.rs
  5. 16
      src/server_server.rs
  6. 6
      tests/Complement.Dockerfile

49
README.md

@ -1,25 +1,43 @@
# Conduit # Conduit
### A Matrix homeserver written in Rust ### 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? #### What is the goal?
A fast Matrix homeserver that's easy to set up and just works. You can install 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, it on a mini-computer like the Raspberry Pi to host Matrix for your family,
friends or company. friends or company.
#### Can I try it out? #### Can I try it out?
Yes! Just open a Matrix client (<https://app.element.io> or Element Android for Yes! Just open a Matrix client (<https://app.element.io> or Element Android for
example) and register on the `https://conduit.koesters.xyz` homeserver. 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? #### How can I deploy my own?
##### Deploy ##### 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) more](DEPLOY.md)
##### Deploy using Docker ##### 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) 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? #### How can I contribute?
1. Look for an issue you would like to work on and make sure it's not assigned 1. Look for an issue you would like to work on and make sure it's not assigned
to other users to other users
2. Ask someone to assign the issue to you (comment on the issue or chat in 2. Ask someone to assign the issue to you (comment on the issue or chat in
#conduit:matrix.org) #conduit:nordgedanken.dev)
3. Fork the repo and work on the issue. #conduit:matrix.org is happy to help :) 3. Fork the repo and work on the issue. #conduit:nordgedanken.dev is happy to help :)
4. Submit a PR 4. Submit a MR
#### Donate #### Donate

6
src/database/sending.rs

@ -275,11 +275,9 @@ impl Sending {
}; };
prefix.push(0xff); prefix.push(0xff);
if servercurrentpdus servercurrentpdus
.compare_and_swap(prefix, Option::<&[u8]>::None, Some(&[])) // Try to reserve .compare_and_swap(prefix, Option::<&[u8]>::None, Some(&[])) // Try to reserve
== Ok(Ok(())) { true } else { == Ok(Ok(()))
false
}
}) })
{ {
servercurrentpdus.insert(&key, &[]).unwrap(); servercurrentpdus.insert(&key, &[]).unwrap();

1
src/main.rs

@ -1,5 +1,6 @@
#![allow(clippy::suspicious_else_formatting)] #![allow(clippy::suspicious_else_formatting)]
#![warn(rust_2018_idioms)] #![warn(rust_2018_idioms)]
#![allow(clippy::suspicious_else_formatting)]
pub mod appservice_server; pub mod appservice_server;
pub mod client_server; pub mod client_server;

8
src/ruma_wrapper.rs

@ -1,13 +1,9 @@
use crate::Error; use crate::Error;
use ruma::{ use ruma::{
api::{AuthScheme, IncomingRequest, OutgoingRequest},
identifiers::{DeviceId, UserId}, identifiers::{DeviceId, UserId},
Outgoing, Outgoing,
}; };
use std::{ use std::{convert::TryInto, ops::Deref};
convert::{TryFrom, TryInto},
ops::Deref,
};
#[cfg(feature = "conduit_bin")] #[cfg(feature = "conduit_bin")]
use { use {
@ -24,6 +20,8 @@ use {
tokio::io::AsyncReadExt, tokio::io::AsyncReadExt,
Request, State, Request, State,
}, },
ruma::api::{AuthScheme, OutgoingRequest},
std::convert::TryFrom,
std::io::Cursor, std::io::Cursor,
}; };

16
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 http::header::{HeaderValue, AUTHORIZATION, HOST};
use log::{info, warn}; use log::{info, warn};
use regex::Regex; use regex::Regex;
use rocket::{get, post, put, response::content::Json, State}; use rocket::{response::content::Json, State};
use ruma::{ use ruma::{
api::{ api::{
federation::{ federation::{
@ -28,6 +28,10 @@ use std::{
net::{IpAddr, SocketAddr}, net::{IpAddr, SocketAddr},
time::{Duration, SystemTime}, time::{Duration, SystemTime},
}; };
#[cfg(feature = "conduit_bin")]
use {
rocket::{get, post, put}
};
#[tracing::instrument(skip(globals))] #[tracing::instrument(skip(globals))]
pub async fn send_request<T: OutgoingRequest>( pub async fn send_request<T: OutgoingRequest>(
@ -553,6 +557,12 @@ pub async fn send_transaction_message_route<'a>(
// TODO: redact event if hashing fails // TODO: redact event if hashing fails
let (event_id, value) = crate::pdu::process_incoming_pdu(pdu); 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::<PduEvent>( let pdu = serde_json::from_value::<PduEvent>(
serde_json::to_value(&value).expect("CanonicalJsonObj is a valid JsonValue"), 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") .get("users")
.and_then(|users| users.as_sequence()) .and_then(|users| users.as_sequence())
.map_or_else( .map_or_else(
|| Vec::new(), Vec::new,
|users| { |users| {
users users
.iter() .iter()
@ -615,7 +625,7 @@ pub async fn send_transaction_message_route<'a>(
.and_then(|string| { .and_then(|string| {
UserId::parse_with_server_name(string, db.globals.server_name()).ok() 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| { if bridge_user_id.map_or(false, |bridge_user_id| {
db.rooms db.rooms
.is_joined(&bridge_user_id, room_id) .is_joined(&bridge_user_id, room_id)

6
tests/Complement.Dockerfile

@ -9,7 +9,9 @@ ARG SCCACHE_ENDPOINT
ARG SCCACHE_S3_USE_SSL ARG SCCACHE_S3_USE_SSL
COPY . . 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 FROM valkum/docker-rust-ci:latest
WORKDIR /workdir 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 && \ sed -i "s/your.server.name/${SERVER_NAME}/g" caddy.json && \
/workdir/caddy start --config caddy.json > /dev/null && \ /workdir/caddy start --config caddy.json > /dev/null && \
/workdir/conduit /workdir/conduit

Loading…
Cancel
Save