add readme with instructions

This commit is contained in:
b1ek 2024-01-07 02:21:19 +10:00
parent b0cd77f68a
commit e7a0891bbb
Signed by: blek
GPG Key ID: 14546221E3595D0C
6 changed files with 34 additions and 6 deletions

26
README.md Normal file
View File

@ -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
<img src='$URL/gif' width='88' height='31' alt='My online indicator' />
```

2
client/Cargo.lock generated
View File

@ -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",

View File

@ -1,5 +1,5 @@
[package]
name = "blek-heartbeat"
name = "blek-online-client"
version = "0.1.0"
edition = "2021"

View File

@ -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<dyn Error>> {
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<dyn Error>> {
}
fn main() -> Result<(), Box<dyn Error>> {
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()?;

2
server/Cargo.lock generated
View File

@ -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",

View File

@ -1,5 +1,5 @@
[package]
name = "blek-heartbeat-server"
name = "blek-online-server"
version = "0.1.0"
edition = "2021"