Skip to content

Commit

Permalink
Merge pull request #22 from Trivernis/develop
Browse files Browse the repository at this point in the history
Version 1.0.1
  • Loading branch information
Trivernis authored Apr 9, 2022
2 parents 035b54a + f554690 commit 16cb977
Show file tree
Hide file tree
Showing 58 changed files with 5,909 additions and 5,433 deletions.
File renamed without changes.
42 changes: 42 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ARG BASE_IMAGE=docker.io/alpine:latest

FROM ${BASE_IMAGE} AS base
RUN apk update
RUN apk add --no-cache \
build-base \
openssl3-dev \
gtk+3.0-dev \
libappindicator-dev \
patchelf \
librsvg-dev \
curl \
wget \
clang \
nodejs \
npm \
libsoup-dev \
webkit2gtk-dev \
file \
python3 \
bash \
protoc
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rm -rf /var/lib/{cache,log}/ /var/cache

FROM base AS sources
WORKDIR /usr/src
COPY mediarepo-api ./mediarepo-api
COPY mediarepo-daemon ./mediarepo-daemon
COPY mediarepo-ui ./mediarepo-ui
COPY scripts ./scripts
RUN python3 scripts/clean.py
RUN python3 scripts/check.py --install

FROM sources AS build_daemon
WORKDIR /usr/src
RUN python3 scripts/build.py daemon --verbose

FROM sources AS build_ui
WORKDIR /usr/src
RUN python3 scripts/build.py ui --verbose --bundles deb
37 changes: 0 additions & 37 deletions Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ After building the `out` directory contains all the built binaries and bundles.

### Test Builds

For test builds the `Dockerfile` in this repository can be used. This way no build dependencies need to be installed on the system. The dockerfile doesn't provide any artifacts and can only be used for validation.
For test builds the `Containerfile` in this repository can be used. This way no build dependencies need to be installed on the system. The Containerfile doesn't provide any artifacts and can only be used for validation.

## Usage and Further Information

Expand Down
20 changes: 10 additions & 10 deletions mediarepo-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
[package]
name = "mediarepo-api"
version = "0.31.0"
version = "0.32.0"
edition = "2018"
license = "gpl-3"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tracing = "0.1.30"
tracing = "0.1.32"
thiserror = "1.0.30"
async-trait = { version = "0.1.52", optional = true }
async-trait = { version = "0.1.53", optional = true }
parking_lot = { version = "0.12.0", optional = true }
serde_json = { version = "1.0.78", optional = true }
serde_json = { version = "1.0.79", optional = true }
directories = { version = "4.0.1", optional = true }
mime_guess = { version = "2.0.3", optional = true }
mime_guess = { version = "2.0.4", optional = true }
serde_piecewise_default = "0.2.0"
futures = { version = "0.3.21", optional = true }
url = { version = "2.2.2", optional = true }
pathsearch = { version = "0.2.0", optional = true }

[dependencies.bromine]
version = "0.18.1"
version = "0.20.1"
optional = true
features = ["serialize_bincode"]
features = ["serialize_bincode", "encryption_layer"]

[dependencies.serde]
version = "1.0.136"
Expand All @@ -33,13 +33,13 @@ version = "0.4.19"
features = ["serde"]

[dependencies.tauri]
version = "1.0.0-beta.8"
optional=true
version = "1.0.0-rc.4"
optional = true
default-features = false
features = []

[dependencies.tokio]
version = "1.16.1"
version = "1.17.0"
optional = true
features = ["sync", "fs", "net", "io-util", "io-std", "time", "rt", "process"]

Expand Down
29 changes: 18 additions & 11 deletions mediarepo-api/src/client_api/protocol.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use async_trait::async_trait;
use bromine::error::Result;
use bromine::prelude::encrypted::{EncryptedStream, EncryptionOptions};
use bromine::prelude::IPCResult;
use bromine::protocol::encrypted::EncryptedListener;
use bromine::protocol::*;
use std::io::Error;
use std::net::ToSocketAddrs;
Expand All @@ -9,12 +11,11 @@ use std::task::{Context, Poll};
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
use tokio::net::{TcpListener, TcpStream};

#[derive(Debug)]
pub enum ApiProtocolListener {
#[cfg(unix)]
UnixSocket(tokio::net::UnixListener),

Tcp(TcpListener),
Tcp(EncryptedListener<TcpListener>),
}

unsafe impl Send for ApiProtocolListener {}
Expand All @@ -25,12 +26,14 @@ impl AsyncStreamProtocolListener for ApiProtocolListener {
type AddressType = String;
type RemoteAddressType = String;
type Stream = ApiProtocolStream;
type ListenerOptions = ();

#[tracing::instrument]
async fn protocol_bind(address: Self::AddressType) -> Result<Self> {
async fn protocol_bind(address: Self::AddressType, _: Self::ListenerOptions) -> Result<Self> {
if let Some(addr) = address.to_socket_addrs().ok().and_then(|mut a| a.next()) {
let listener = TcpListener::bind(addr).await?;
tracing::info!("Connecting via TCP");
let listener =
EncryptedListener::protocol_bind(addr, EncryptionOptions::default()).await?;
tracing::info!("Connecting via encrypted TCP");

Ok(Self::Tcp(listener))
} else {
Expand Down Expand Up @@ -67,19 +70,18 @@ impl AsyncStreamProtocolListener for ApiProtocolListener {
))
}
ApiProtocolListener::Tcp(listener) => {
let (stream, addr) = listener.accept().await?;
let (stream, addr) = listener.protocol_accept().await?;
Ok((ApiProtocolStream::Tcp(stream), addr.to_string()))
}
}
}
}

#[derive(Debug)]
pub enum ApiProtocolStream {
#[cfg(unix)]
UnixSocket(tokio::net::UnixStream),

Tcp(TcpStream),
Tcp(EncryptedStream<TcpStream>),
}

unsafe impl Send for ApiProtocolStream {}
Expand All @@ -97,7 +99,7 @@ impl AsyncProtocolStreamSplit for ApiProtocolStream {
(Box::new(read), Box::new(write))
}
ApiProtocolStream::Tcp(stream) => {
let (read, write) = stream.into_split();
let (read, write) = stream.protocol_into_split();
(Box::new(read), Box::new(write))
}
}
Expand All @@ -107,10 +109,15 @@ impl AsyncProtocolStreamSplit for ApiProtocolStream {
#[async_trait]
impl AsyncProtocolStream for ApiProtocolStream {
type AddressType = String;
type StreamOptions = ();

async fn protocol_connect(address: Self::AddressType) -> IPCResult<Self> {
async fn protocol_connect(
address: Self::AddressType,
_: Self::StreamOptions,
) -> IPCResult<Self> {
if let Some(addr) = address.to_socket_addrs().ok().and_then(|mut a| a.next()) {
let stream = TcpStream::connect(addr).await?;
let stream =
EncryptedStream::protocol_connect(addr, EncryptionOptions::default()).await?;
Ok(Self::Tcp(stream))
} else {
#[cfg(unix)]
Expand Down
3 changes: 2 additions & 1 deletion mediarepo-api/src/tauri_plugin/commands/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::daemon_management::find_daemon_executable;
use crate::tauri_plugin::commands::AppAccess;
use crate::tauri_plugin::error::PluginResult;
use crate::tauri_plugin::settings::save_settings;
use bromine::prelude::encrypted::EncryptedListener;
use bromine::prelude::{IPCError, IPCResult};
use bromine::IPCBuilder;
use std::io::ErrorKind;
Expand Down Expand Up @@ -53,7 +54,7 @@ pub async fn check_daemon_running(address: String) -> PluginResult<bool> {

async fn try_connect_daemon(address: String) -> IPCResult<()> {
let address = get_socket_address(address)?;
let ctx = IPCBuilder::<TcpListener>::new()
let ctx = IPCBuilder::<EncryptedListener<TcpListener>>::new()
.address(address)
.build_client()
.await?;
Expand Down
Loading

0 comments on commit 16cb977

Please sign in to comment.