diff --git a/ORIGINAL-PEACHCLOUD-README.md b/ORIGINAL-PEACHCLOUD-README.md new file mode 100644 index 0000000..229433a --- /dev/null +++ b/ORIGINAL-PEACHCLOUD-README.md @@ -0,0 +1,74 @@ +# [PeachCloud](http://peachcloud.org) :peach: :cloud: + +_Better [Scuttlebutt](https://scuttlebutt.nz) cloud infrastructure as a hardware product._ + +[**_Support us on OpenCollective!_**](https://opencollective.com/peachcloud) + +[![Build Status](https://build.coopcloud.tech/api/badges/PeachCloud/peach-workspace/status.svg?ref=refs/heads/main)](https://build.coopcloud.tech/PeachCloud/peach-workspace) + +## Background + +- April 2018 project proposal: [`%HqwAsltORROCh4uyOq6iV+SsqU3OuNUevnq+5dwCqVI=.sha256`](https://viewer.scuttlebot.io/%25HqwAsltORROCh4uyOq6iV%2BSsqU3OuNUevnq%2B5dwCqVI%3D.sha256) +- November 2018 project pivot: [`%9NCyTf+oBxG0APlXRCKtrGZj3t+i+Kp3pKPN1gtFX2c=.sha256`](https://viewer.scuttlebot.io/%259NCyTf%2BoBxG0APlXRCKtrGZj3t%2Bi%2BKp3pKPN1gtFX2c%3D.sha256) + +## Active Repositories + +**Documentation** + + - [peach-devdocs](https://github.com/peachcloud/peach-devdocs) - Developer documentation for PeachCloud in the form of a Markdown book + +**Devops** + + - [peach-vps](https://github.com/peachcloud/peach-vps) - Setup scripts and configuration files for deploying a PeachCloud development server + +**Image building & device configuration** + + - [peach-config](https://github.com/peachcloud/peach-config) - Configuration instructions, files and scripts + - [peach-img-builder](https://github.com/peachcloud/peach-img-builder) - Vmdb2 script for building a Debian disc image for Raspberry Pi with PeachCloud pre-installed + +**Microservices** + + - [peach-buttons](https://github.com/peachcloud/peach-buttons) - Emit GPIO events using JSON-RPC pubsub over WS + - [peach-oled](https://github.com/peachcloud/peach-oled) - Write and draw to OLED display using JSON-RPC over HTTP + - [peach-menu](https://github.com/peachcloud/peach-menu) - A menu for monitoring and interacting with the PeachCloud device + - [peach-network](https://github.com/peachcloud/peach-network) - Query and configure network interfaces using JSON-RPC over HTTP + - [peach-stats](https://github.com/peachcloud/peach-stats) - Query system statistics using JSON-RPC over HTTP + - [peach-lib](https://github.com/peachcloud/peach-lib) - JSON-RPC client library for the PeachCloud ecosystem + - [peach-monitor](https://github.com/peachcloud/peach-monitor) - Monitor network data usage and set alert flags based on user-defined thresholds + +**Diagnostics** + + - [peach-probe](https://github.com/peachcloud/peach-probe) - Probe PeachCloud microservices to evaluate their state and ensure correct API responses + +**Web interface** + + - [peach-patterns](https://github.com/peachcloud/peach-patterns) - Pattern library for the PeachCloud UI design system + - [peach-web](https://github.com/peachcloud/peach-web) - A web interface for monitoring and interacting with the PeachCloud device + +## Continuous Integration + +[Drone CI](https://docs.drone.io/) is used to provide continuous integration for this workspace. The configuration file can be found in `.drone.yml` in the root of this repository. It is currently configured to run `cargo fmt`, `cargo clippy`, `cargo test` and `cargo build` on every `pull request` event. The pipeline runs on the AMD64 Debian Buster image from the official Rust Docker image repository. + +The status of the current and previous CI builds can be viewed via the [Drone CI Build UI](https://build.coopcloud.tech/PeachCloud/peach-workspace) (kindly hosted by Co-op Cloud). + +Adding `[CI SKIP]` to the end of a commit message results in the CI checks being skipped for the next event. For example: + +``` +git commit -m "update readme [CI SKIP]" +git push origin main +``` + +## Developer Diaries + +- [@ahdinosaur](https://github.com/ahdinosaur): `@6ilZq3kN0F+dXFHAPjAwMm87JEb/VdB+LC9eIMW3sa0=.ed25519` + - 1: [`%bSkZCJBmNYUmECNKYOiWkgEeRxrlo2UghNBzE6Cph94=.sha256`](https://viewer.scuttlebot.io/%25bSkZCJBmNYUmECNKYOiWkgEeRxrlo2UghNBzE6Cph94%3D.sha256) + - 2: [`%2L7gYAh2ih+7eFCrtObPWIUYHuGnJjwj4KCXrCIsWhM=.sha256`](https://viewer.scuttlebot.io/%252L7gYAh2ih%2B7eFCrtObPWIUYHuGnJjwj4KCXrCIsWhM%3D.sha256) + - [@mycognosist](https://github.com/mycognosist): `@HEqy940T6uB+T+d9Jaa58aNfRzLx9eRWqkZljBmnkmk=.ed25519` + - [`%mKUByRp4Gib6fqP1q2/dHg+ueSoR+Sj2Y0D7T0Np0D4=.sha256`](https://viewer.scuttlebot.io/%25mKUByRp4Gib6fqP1q2%2FdHg%2BueSoR%2BSj2Y0D7T0Np0D4%3D.sha256) + +## Accounts + +- [GitHub](https://github.com/peachcloud) +- [Twitter](https://twitter.com/peachcloudorg) +- [Email](mailto:peachcloudorg@gmail.com) +- [OpenCollective](https://opencollective.com/peachcloud) diff --git a/README.md b/README.md index 229433a..f820474 100644 --- a/README.md +++ b/README.md @@ -2,73 +2,35 @@ _Better [Scuttlebutt](https://scuttlebutt.nz) cloud infrastructure as a hardware product._ -[**_Support us on OpenCollective!_**](https://opencollective.com/peachcloud) +![image of peachcloud device](https://peach.commoninternet.net/assets/peachcloud.jpg) + +## About + +This project is a hack that combines PeachCloud with TildFriends. + +The original PeachCloud project was paused when most development in the Scuttlebutt ecosystem stopped (reference), +but even after most funding and development and left the ecosystem, a version of the Sbot in C called TildeFriends was finished, +and continues to be maintained. + +This fork of the PeachCloud project makes use of the TildeFriends sbot to make a minimal and functional PeachCloud Scuttlebutt pub, +that can be easily deployed and operated by a non-technical user. + +Due to the timing and conditions of the Scuttlebutt ecosystem, and the rise of new protocols, +for this particular hack, the focus was on getting the project working in a minimal form (aka more hacky), +with less of a focus on long-term sustainability of the project as an ecosystem. + +This project serves to provide a working simple-to-use pub for a P2P protocol which is in some ways frozen in amber, +as well as to share the PeachCloud interface and project, as a design-inspiration for other projects. + +## Setup + +TODO: how to install with yunohost +TODO: how to install without yunohost -[![Build Status](https://build.coopcloud.tech/api/badges/PeachCloud/peach-workspace/status.svg?ref=refs/heads/main)](https://build.coopcloud.tech/PeachCloud/peach-workspace) ## Background - April 2018 project proposal: [`%HqwAsltORROCh4uyOq6iV+SsqU3OuNUevnq+5dwCqVI=.sha256`](https://viewer.scuttlebot.io/%25HqwAsltORROCh4uyOq6iV%2BSsqU3OuNUevnq%2B5dwCqVI%3D.sha256) - November 2018 project pivot: [`%9NCyTf+oBxG0APlXRCKtrGZj3t+i+Kp3pKPN1gtFX2c=.sha256`](https://viewer.scuttlebot.io/%259NCyTf%2BoBxG0APlXRCKtrGZj3t%2Bi%2BKp3pKPN1gtFX2c%3D.sha256) - -## Active Repositories - -**Documentation** - - - [peach-devdocs](https://github.com/peachcloud/peach-devdocs) - Developer documentation for PeachCloud in the form of a Markdown book - -**Devops** - - - [peach-vps](https://github.com/peachcloud/peach-vps) - Setup scripts and configuration files for deploying a PeachCloud development server - -**Image building & device configuration** - - - [peach-config](https://github.com/peachcloud/peach-config) - Configuration instructions, files and scripts - - [peach-img-builder](https://github.com/peachcloud/peach-img-builder) - Vmdb2 script for building a Debian disc image for Raspberry Pi with PeachCloud pre-installed - -**Microservices** - - - [peach-buttons](https://github.com/peachcloud/peach-buttons) - Emit GPIO events using JSON-RPC pubsub over WS - - [peach-oled](https://github.com/peachcloud/peach-oled) - Write and draw to OLED display using JSON-RPC over HTTP - - [peach-menu](https://github.com/peachcloud/peach-menu) - A menu for monitoring and interacting with the PeachCloud device - - [peach-network](https://github.com/peachcloud/peach-network) - Query and configure network interfaces using JSON-RPC over HTTP - - [peach-stats](https://github.com/peachcloud/peach-stats) - Query system statistics using JSON-RPC over HTTP - - [peach-lib](https://github.com/peachcloud/peach-lib) - JSON-RPC client library for the PeachCloud ecosystem - - [peach-monitor](https://github.com/peachcloud/peach-monitor) - Monitor network data usage and set alert flags based on user-defined thresholds - -**Diagnostics** - - - [peach-probe](https://github.com/peachcloud/peach-probe) - Probe PeachCloud microservices to evaluate their state and ensure correct API responses - -**Web interface** - - - [peach-patterns](https://github.com/peachcloud/peach-patterns) - Pattern library for the PeachCloud UI design system - - [peach-web](https://github.com/peachcloud/peach-web) - A web interface for monitoring and interacting with the PeachCloud device - -## Continuous Integration - -[Drone CI](https://docs.drone.io/) is used to provide continuous integration for this workspace. The configuration file can be found in `.drone.yml` in the root of this repository. It is currently configured to run `cargo fmt`, `cargo clippy`, `cargo test` and `cargo build` on every `pull request` event. The pipeline runs on the AMD64 Debian Buster image from the official Rust Docker image repository. - -The status of the current and previous CI builds can be viewed via the [Drone CI Build UI](https://build.coopcloud.tech/PeachCloud/peach-workspace) (kindly hosted by Co-op Cloud). - -Adding `[CI SKIP]` to the end of a commit message results in the CI checks being skipped for the next event. For example: - -``` -git commit -m "update readme [CI SKIP]" -git push origin main -``` - -## Developer Diaries - -- [@ahdinosaur](https://github.com/ahdinosaur): `@6ilZq3kN0F+dXFHAPjAwMm87JEb/VdB+LC9eIMW3sa0=.ed25519` - - 1: [`%bSkZCJBmNYUmECNKYOiWkgEeRxrlo2UghNBzE6Cph94=.sha256`](https://viewer.scuttlebot.io/%25bSkZCJBmNYUmECNKYOiWkgEeRxrlo2UghNBzE6Cph94%3D.sha256) - - 2: [`%2L7gYAh2ih+7eFCrtObPWIUYHuGnJjwj4KCXrCIsWhM=.sha256`](https://viewer.scuttlebot.io/%252L7gYAh2ih%2B7eFCrtObPWIUYHuGnJjwj4KCXrCIsWhM%3D.sha256) - - [@mycognosist](https://github.com/mycognosist): `@HEqy940T6uB+T+d9Jaa58aNfRzLx9eRWqkZljBmnkmk=.ed25519` - - [`%mKUByRp4Gib6fqP1q2/dHg+ueSoR+Sj2Y0D7T0Np0D4=.sha256`](https://viewer.scuttlebot.io/%25mKUByRp4Gib6fqP1q2%2FdHg%2BueSoR%2BSj2Y0D7T0Np0D4%3D.sha256) - -## Accounts - -- [GitHub](https://github.com/peachcloud) -- [Twitter](https://twitter.com/peachcloudorg) -- [Email](mailto:peachcloudorg@gmail.com) -- [OpenCollective](https://opencollective.com/peachcloud) +- [Original PeachCloud ReadMe](/ORIGINAL-PEACHCLOUD-README.md) +- [Original PeachCloud Documentation](https://peach.commoninternet.net) diff --git a/peach-lib/src/config_manager.rs b/peach-lib/src/config_manager.rs index eb5baa2..586fbea 100644 --- a/peach-lib/src/config_manager.rs +++ b/peach-lib/src/config_manager.rs @@ -59,9 +59,9 @@ pub fn get_peach_config_defaults() -> HashMap { ("SSB_ADMIN_IDS", ""), ("ADMIN_PASSWORD_HASH", "47"), ("TEMPORARY_PASSWORD_HASH", ""), - ("TILDE_SBOT_DATADIR", "/home/notplants/.local/share/tildefriends/"), + ("TILDE_SBOT_DATADIR", "/home/peach/.local/share/tildefriends/"), ("TILDE_SBOT_SERVICE", "tilde-sbot.service"), - ("TILDE_BINARY_PATH", "/home/notplants/computer/projects/peachpub/tilde/tildefriends/out/release/tildefriends.standalone"), + ("TILDE_BINARY_PATH", "/home/peach/tildefriends.standalone"), ("PEACH_CONFIGDIR", "/var/lib/peachcloud"), ("PEACH_HOMEDIR", "/home/peach"), ("PEACH_WEBDIR", "/usr/share/peach-web"), @@ -286,8 +286,12 @@ pub fn delete_ssb_admin_id(ssb_id: &str) -> Result, PeachError> { // looks up the String value for SSB_ADMIN_IDS and converts it into a Vec pub fn get_ssb_admin_ids() -> Result, PeachError> { let ssb_admin_ids_str = get_config_value("SSB_ADMIN_IDS")?; - let ssb_admin_ids: Vec = serde_json::from_str(&ssb_admin_ids_str)?; - Ok(ssb_admin_ids) + if ssb_admin_ids_str.trim().is_empty() { + Ok(vec![]) + } else { + let ssb_admin_ids: Vec = serde_json::from_str(&ssb_admin_ids_str)?; + Ok(ssb_admin_ids) + } } // takes in a Vec and saves SSB_ADMIN_IDS as a json string representation of this vec diff --git a/peach-lib/src/error.rs b/peach-lib/src/error.rs index abf336b..9e86316 100644 --- a/peach-lib/src/error.rs +++ b/peach-lib/src/error.rs @@ -110,6 +110,9 @@ pub enum PeachError { /// Represents an Anyhow error with Solar SolarClientError(String), + /// Represents an Anyhow error with Solar + TildeClientError(String), + /// Represents an error with encoding or decoding an SsbMessage SsbMessageError(String), @@ -143,6 +146,7 @@ impl std::error::Error for PeachError { PeachError::Write { ref source, .. } => Some(source), PeachError::JsonRpcError(_) => None, PeachError::SolarClientError(_) => None, + PeachError::TildeClientError(_) => None, PeachError::SsbMessageError(_) => None, } } @@ -203,6 +207,7 @@ impl std::fmt::Display for PeachError { } PeachError::JsonRpcError(ref err) => err.fmt(f), PeachError::SolarClientError(ref err) => err.fmt(f), + PeachError::TildeClientError(ref err) => err.fmt(f), PeachError::SsbMessageError(ref err) => err.fmt(f), } } diff --git a/peach-lib/src/password_utils.rs b/peach-lib/src/password_utils.rs index cde3ad9..1c08e18 100644 --- a/peach-lib/src/password_utils.rs +++ b/peach-lib/src/password_utils.rs @@ -108,29 +108,20 @@ using this link: http://peach.local/auth/reset", // use golgi to send a private message on scuttlebutt match task::block_on(publish_private_msg(&msg, &ssb_admin_id)) { Ok(_) => (), - Err(e) => return Err(PeachError::Sbot(e)), + Err(e) => return Err(e), } } Ok(()) } -async fn publish_private_msg(msg: &str, recipient: &str) -> Result<(), String> { - // retrieve latest go-sbot configuration parameters - let sbot_config = SbotConfig::read().ok(); - - let msg = msg.to_string(); - let recipient = vec![recipient.to_string()]; +async fn publish_private_msg(msg: &str, recipient: &str) -> Result<(), PeachError> { // initialise sbot connection with ip:port and shscap from config file - let mut sbot_client = init_sbot(); + let mut sbot_client = init_sbot().await?; debug!("Publishing a Scuttlebutt private message with temporary password"); - // TODO: implement publish private message in solar, and then implement this - Err(format!("Failed to publish private message: \ - private publishing is not yet implemented in solar_client: \ - the message meant to be sent was: {}", msg)) - // match sbot_client.publish_private(msg, recipient).await { - // Ok(_) => Ok(()), - // Err(e) => Err(format!("Failed to publish private message: {}", e)), - // } + match sbot_client.private_message(recipient, msg).await { + Ok(_) => Ok(()), + Err(e) => Err(PeachError::TildeClientError(format!("Failed to publish private message: {}", e))), + } } diff --git a/peach-web/src/routes/settings/admin/menu.rs b/peach-web/src/routes/settings/admin/menu.rs index 7a1d7ae..49470d5 100644 --- a/peach-web/src/routes/settings/admin/menu.rs +++ b/peach-web/src/routes/settings/admin/menu.rs @@ -9,9 +9,9 @@ pub fn build_template() -> PreEscaped { div class="card center" { (PreEscaped("")) div id="settingsButtons" { - // a id="configure" class="button button-primary center" href="/settings/admin/configure" title="Configure Admin" { "Configure Admin" } + a id="configure" class="button button-primary center" href="/settings/admin/configure" title="Configure Admin" { "Configure Admin" } a id="change" class="button button-primary center" href="/auth/change" title="Change Password" { "Change Password" } - // a id="reset" class="button button-primary center" href="/auth/reset" title="Reset Password" { "Reset Password" } + a id="reset" class="button button-primary center" href="/auth/reset" title="Reset Password" { "Reset Password" } } }