peach-workspace/peach-web
glyph 3991af11c7 only render private if sbot is active, fix type in profile 2022-03-03 09:34:30 +02:00
..
debian Remove configuration of http basic auth 2021-12-17 17:19:04 -05:00
docs First workspace commit 2021-08-06 13:58:40 -04:00
src reduce code repetition 2022-03-03 09:33:45 +02:00
static minor css tweaks 2022-03-02 15:24:40 +02:00
templates only render private if sbot is active, fix type in profile 2022-03-03 09:34:30 +02:00
.gitignore First workspace commit 2021-08-06 13:58:40 -04:00
.travis.yml First workspace commit 2021-08-06 13:58:40 -04:00
Cargo.toml add deps for base64 and temp dir creation 2022-02-25 09:09:07 +02:00
README.md update rocket config file and related docs 2022-01-18 16:59:54 +02:00
Rocket.toml update rocket config file and related docs 2022-01-18 16:59:54 +02:00

README.md

peach-web

Build Status Generic badge

Web Interface for PeachCloud

peach-web provides a web interface for the PeachCloud device.

Initial development is focused on administration of the device itself, beginning with networking functionality, with SSB-related administration to be integrated at a later stage.

The peach-web stack currently consists of Rocket (Rust web framework), Tera (Rust template engine), HTML and CSS.

Note: This is a work-in-progress.

Setup

Clone the peach-workspace repo:

git clone https://git.coopcloud.tech/PeachCloud/peach-workspace

Move into the repo and compile:

cd peach-workspace/peach-web cargo build --release

Run the tests:

ROCKET_DISABLE_AUTH=true ROCKET_STANDALONE_MODE=false cargo test

Move back to the peach-workspace directory:

cd ..

Run the binary:

./target/release/peach-web

Environment

Deployment Profile

The web application deployment profile can be configured with the ROCKET_ENV environment variable:

export ROCKET_ENV=stage

Default configuration parameters are defined in Rocket.toml. This file defines a set of default parameters, some of which are overwritten when running in debug mode (ie. cargo run or cargo build) or release mode (ie. cargo run --release or cargo build --release).

Read the Rocket Environment Configurations docs for further information.

Configuration Mode

The web application can be run with a minimal set of routes and functionality (PeachPub - a simple sbot manager) or with the full-suite of capabilities, including network management and access to device statistics (PeachCloud). The mode is enabled by default (as defined in Rocket.toml) but can be overwritten using the ROCKET_STANDALONE_MODE environment variable: true or false. If the variable is unset or the value is incorrectly set, the application defaults to standalone mode.

Authentication

Authentication is disabled in debug mode and enabled by default when running the application in release mode. It can be disabled by setting the ROCKET_DISABLE_AUTH environment variable to true:

export ROCKET_DISABLE_AUTH=true

Logging

Logging is made available with env_logger:

export RUST_LOG=info

Other logging levels include debug, warn and error.

Debian Packaging

A systemd service file and Debian maintainer scripts are included in the debian directory, allowing peach-web to be easily bundled as a Debian package (.deb). The cargo-deb crate can be used to achieve this.

Install cargo-deb:

cargo install cargo-deb

Move into the repo:

cd peach-web

Build the package:

cargo deb

The output will be written to target/debian/peach-web_0.3.0_arm64.deb (or similar).

Install the package as follows:

sudo dpkg -i target/debian/peach-web_0.3.0_arm64.deb

The service will be automatically enabled and started.

Uninstall the service:

sudo apt-get remove peach-web

Remove configuration files (not removed with apt-get remove):

sudo apt-get purge peach-web

Design

peach-web is built on the Rocket webserver and Tera templating engine. It presents a web interface for interacting with the device. HTML is rendered server-side. Request handlers call peach- libraries and serve HTML and assets. Each Tera template is passed a context object. In the case of Rust, this object is a struct and must implement Serialize. The fields of the context object are available in the context of the template to be rendered.

Configuration

Configuration variables are stored in /var/lib/peachcloud/config.yml. Peach-web also updates this file when changes are made to configurations via the web interface. peach-web has no database, so all configurations are stored in this file.

Dynamic DNS Configuration

Most users will want to use the default PeachCloud dynamic dns server. If the config dyn_use_custom_server=false, then default values will be used. If the config dyn_use_custom_server=true, then a value must also be set for dyn_dns_server_address (e.g. "http://peachdynserver.commoninternet.net"). This value is the URL of the instance of peach-dyndns-server that requests will be sent to for domain registration. Using a custom value can here can be useful for testing.

Licensing

AGPL-3.0