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. 4
      tests/Complement.Dockerfile

49
README.md

@ -1,25 +1,43 @@ @@ -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 (<https://app.element.io> 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 @@ -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

6
src/database/sending.rs

@ -275,11 +275,9 @@ impl Sending { @@ -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();

1
src/main.rs

@ -1,5 +1,6 @@ @@ -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;

8
src/ruma_wrapper.rs

@ -1,13 +1,9 @@ @@ -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 { @@ -24,6 +20,8 @@ use {
tokio::io::AsyncReadExt,
Request, State,
},
ruma::api::{AuthScheme, OutgoingRequest},
std::convert::TryFrom,
std::io::Cursor,
};

16
src/server_server.rs

@ -2,7 +2,7 @@ use crate::{client_server, utils, ConduitResult, Database, Error, PduEvent, Resu @@ -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::{ @@ -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<T: OutgoingRequest>(
@ -553,6 +557,12 @@ pub async fn send_transaction_message_route<'a>( @@ -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::<PduEvent>(
serde_json::to_value(&value).expect("CanonicalJsonObj is a valid JsonValue"),
)
@ -583,7 +593,7 @@ pub async fn send_transaction_message_route<'a>( @@ -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>( @@ -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)

4
tests/Complement.Dockerfile

@ -9,7 +9,9 @@ ARG SCCACHE_ENDPOINT @@ -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

Loading…
Cancel
Save