From e7a0891bbbd8325a3dc9e696eac8b43b736ce275 Mon Sep 17 00:00:00 2001 From: b1ek Date: Sun, 7 Jan 2024 02:21:19 +1000 Subject: [PATCH] add readme with instructions --- README.md | 26 ++++++++++++++++++++++++++ client/Cargo.lock | 2 +- client/Cargo.toml | 2 +- client/src/main.rs | 6 ++++-- server/Cargo.lock | 2 +- server/Cargo.toml | 2 +- 6 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..e982325 --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# blek! Online +A 88x31 widget to tell your website's users if you are online + +## Installation + +There are some prerequisites for the user: +1. You should know how to use docker compose and linux shell commands +2. You MUST have a web server of your own. If you dont have it, there is literally no way for you to run this app. +3. You should have a UNIX machine that you use on a daily basis. If you really want to, write a PR with windows support. + +If you do not meet the prerequisities, you are very unlikely to properly run this without any severe tinkering. + +1. Clone the repo and cd to its directory +2. Generate a 1024 bytes long key: `head -c 1024 /dev/random > secret.key` +3. Put your server URL in `client/src/main.rs` on 4th line. +4. Install the client binary on your PC or laptop and set up a cron job to execute it once a minute. +5. Copy the `secret.key` to your server and `docker-compose up -d` it. Then pass it via the reverse proxy to whereever you want. + +## Embeding the gif + +Lets assume that `$URL` is your server's url. +Embded it like this: + +```html +My online indicator +``` \ No newline at end of file diff --git a/client/Cargo.lock b/client/Cargo.lock index c1ecb76..0516445 100644 --- a/client/Cargo.lock +++ b/client/Cargo.lock @@ -57,7 +57,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] -name = "blek-heartbeat" +name = "blek-online-client" version = "0.1.0" dependencies = [ "obfstr", diff --git a/client/Cargo.toml b/client/Cargo.toml index 0a8e846..a61289e 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "blek-heartbeat" +name = "blek-online-client" version = "0.1.0" edition = "2021" diff --git a/client/src/main.rs b/client/src/main.rs index cd26048..78a62ec 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -1,6 +1,8 @@ use reqwest::{blocking, Method}; use std::{result::Result, error::Error, process::exit, io::{Write, stderr}, fs, path::Path}; +const SERVER_URL: &'static str = "https://online.blek.codes"; // no '/' at the end + fn write_metrics(add: u32) -> Result<(), Box> { let user = users::get_user_by_uid(users::get_current_uid()); if let Some(user) = user.clone() { @@ -27,9 +29,9 @@ fn write_metrics(add: u32) -> Result<(), Box> { } fn main() -> Result<(), Box> { - let key = include_bytes!("key.bin"); + let key = include_bytes!("secret.key"); let cli = blocking::Client::new(); - let res = cli.request(Method::POST, "https://hb.blek.codes/beat") + let res = cli.request(Method::POST, format!("{SERVER_URL}/beat")) .body(key.to_vec()) .send()?; diff --git a/server/Cargo.lock b/server/Cargo.lock index 2319de8..d00668e 100644 --- a/server/Cargo.lock +++ b/server/Cargo.lock @@ -66,7 +66,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "blek-heartbeat-server" +name = "blek-online-server" version = "0.1.0" dependencies = [ "bytes", diff --git a/server/Cargo.toml b/server/Cargo.toml index fa26be3..a05f384 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "blek-heartbeat-server" +name = "blek-online-server" version = "0.1.0" edition = "2021"