mirror of
https://github.com/LowderPlay/cheburcheck.git
synced 2026-09-22 22:37:59 +03:00
feat: probe autoupdate (#88)
* feat: autoupdate * chore: bump version * feat: publish installer * fix: standalone builds * ci: release docs * fix: windows icmp socket * docs: windows notice * docs: remove line breaks
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "website"
|
||||
version = "1.2.4"
|
||||
version = "1.2.5"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -6,6 +6,7 @@ mod database_refresh;
|
||||
mod db;
|
||||
mod mqtt;
|
||||
mod mqtt_auth;
|
||||
mod probe_installer;
|
||||
mod whitelist;
|
||||
|
||||
use env_logger::Env;
|
||||
@@ -106,6 +107,7 @@ async fn rocket() -> _ {
|
||||
)
|
||||
.mount("/agency", routes![agency::upload_report])
|
||||
.mount("/mqtt", routes![mqtt_auth::auth, mqtt_auth::acl])
|
||||
.mount("/", routes![probe_installer::download])
|
||||
.mount("/whitelist", routes![whitelist::export_csv])
|
||||
.register("/", catchers![api_error])
|
||||
}
|
||||
|
||||
@@ -120,7 +120,11 @@ pub async fn acl(
|
||||
}
|
||||
|
||||
async fn can_probe_subscribe(client_id: &str, topic: &str, pool: &PgPool) -> bool {
|
||||
if topic == "probe/config/v1" || is_own_task_subscription(client_id, topic) {
|
||||
if topic == "probe/config/v1"
|
||||
|| topic == "probe/update/v1"
|
||||
|| topic == format!("probe/update/v1/{client_id}")
|
||||
|| is_own_task_subscription(client_id, topic)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if !is_global_task_subscription(topic) {
|
||||
@@ -182,6 +186,14 @@ mod tests {
|
||||
assert!(!is_own_task_subscription("42", "probe/tasks/v1/#"));
|
||||
}
|
||||
|
||||
#[rocket::async_test]
|
||||
async fn update_subscriptions_are_node_scoped() {
|
||||
let pool = PgPool::connect_lazy("postgres://localhost/unused").unwrap();
|
||||
assert!(can_probe_subscribe("42", "probe/update/v1", &pool).await);
|
||||
assert!(can_probe_subscribe("42", "probe/update/v1/42", &pool).await);
|
||||
assert!(!can_probe_subscribe("42", "probe/update/v1/7", &pool).await);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn results_can_only_be_published_as_the_authenticated_node() {
|
||||
assert!(can_probe_publish("42", "probe/results/v1/job/42"));
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
use rocket::http::ContentType;
|
||||
|
||||
const INSTALLER: &str = include_str!("../../probe/install.sh");
|
||||
|
||||
#[get("/install-probe.sh")]
|
||||
pub fn download() -> (ContentType, &'static str) {
|
||||
(ContentType::new("text", "x-shellscript"), INSTALLER)
|
||||
}
|
||||
Reference in New Issue
Block a user