feat: p2p monitoring

This commit is contained in:
Matthew Esposito 2025-04-17 18:44:27 -04:00
parent 051b63c6de
commit 3f0b27604b
4 changed files with 54 additions and 10 deletions

View file

@ -4,7 +4,9 @@
use cached::proc_macro::cached;
use clap::{Arg, ArgAction, Command};
use redlib::p2p::ONLINE;
use std::str::FromStr;
use std::sync::atomic::Ordering;
use futures_lite::FutureExt;
use hyper::Uri;
@ -227,6 +229,16 @@ async fn main() {
}
}
// Manual overrides for online value
app.at("/force_offline").get(|_| {
ONLINE.store(false, Ordering::SeqCst);
resource("", "text/plain", false).boxed()
});
app.at("/force_online").get(|_| {
ONLINE.store(true, Ordering::SeqCst);
resource("", "text/plain", false).boxed()
});
// Read static files
app.at("/style.css").get(|_| style().boxed());
app