mirror of
https://github.com/LowderPlay/cheburcheck.git
synced 2026-10-12 00:58:23 +03:00
@@ -56,6 +56,7 @@ struct NodeStatus {
|
||||
connected_at: Option<DateTime<Utc>>,
|
||||
online: bool,
|
||||
version: Option<String>,
|
||||
bundle_type: Option<String>,
|
||||
dpi_hop_v4: Option<u8>,
|
||||
dpi_hop_v6: Option<u8>,
|
||||
}
|
||||
@@ -107,6 +108,7 @@ fn build_node_statuses(
|
||||
connected_at: probe.last_connected_at,
|
||||
online: status.is_some_and(|status| status.online),
|
||||
version: status.map(|status| status.version.clone()),
|
||||
bundle_type: status.and_then(|status| status.bundle_type.clone()),
|
||||
dpi_hop_v4: status.and_then(|status| status.dpi_hop_v4),
|
||||
dpi_hop_v6: status.and_then(|status| status.dpi_hop_v6),
|
||||
}
|
||||
@@ -152,6 +154,7 @@ mod tests {
|
||||
ProbeStatusSnapshot {
|
||||
online: true,
|
||||
version: "1.2.3".to_string(),
|
||||
bundle_type: Some("debian".to_string()),
|
||||
dpi_hop_v4: Some(5),
|
||||
dpi_hop_v6: None,
|
||||
},
|
||||
@@ -171,6 +174,7 @@ mod tests {
|
||||
connected_at: Some("2026-08-24T12:34:56Z".parse().unwrap()),
|
||||
online: true,
|
||||
version: Some("1.2.3".to_string()),
|
||||
bundle_type: Some("debian".to_string()),
|
||||
dpi_hop_v4: Some(5),
|
||||
dpi_hop_v6: None,
|
||||
},
|
||||
@@ -183,6 +187,7 @@ mod tests {
|
||||
connected_at: Some("2026-08-23T12:34:56Z".parse().unwrap()),
|
||||
online: false,
|
||||
version: None,
|
||||
bundle_type: None,
|
||||
dpi_hop_v4: None,
|
||||
dpi_hop_v6: None,
|
||||
},
|
||||
|
||||
+5
-1
@@ -66,6 +66,7 @@ type ProbeStatuses = Arc<rocket::tokio::sync::RwLock<HashMap<String, ProbeStatus
|
||||
pub struct ProbeStatusSnapshot {
|
||||
pub online: bool,
|
||||
pub version: String,
|
||||
pub bundle_type: Option<String>,
|
||||
pub dpi_hop_v4: Option<u8>,
|
||||
pub dpi_hop_v6: Option<u8>,
|
||||
}
|
||||
@@ -377,6 +378,7 @@ async fn dispatch_probe_status(probe_statuses: &ProbeStatuses, topic: &str, payl
|
||||
ProbeStatusSnapshot {
|
||||
online: status.online,
|
||||
version: status.version.to_string(),
|
||||
bundle_type: status.bundle_type.map(str::to_string),
|
||||
dpi_hop_v4: status.dpi_hop_v4,
|
||||
dpi_hop_v6: status.dpi_hop_v6,
|
||||
},
|
||||
@@ -462,7 +464,7 @@ mod tests {
|
||||
dispatch_probe_status(
|
||||
&statuses,
|
||||
"probe/status/v1/42",
|
||||
br#"{"online":false,"probe_id":"42","version":"1.2.3","dpi_hop_v4":4,"dpi_hop_v6":6}"#,
|
||||
br#"{"online":false,"probe_id":"42","version":"1.2.3","bundle_type":"openwrt","dpi_hop_v4":4,"dpi_hop_v6":6}"#,
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -471,6 +473,7 @@ mod tests {
|
||||
Some(&ProbeStatusSnapshot {
|
||||
online: false,
|
||||
version: "1.2.3".to_string(),
|
||||
bundle_type: Some("openwrt".to_string()),
|
||||
dpi_hop_v4: Some(4),
|
||||
dpi_hop_v6: Some(6),
|
||||
})
|
||||
@@ -484,6 +487,7 @@ mod tests {
|
||||
ProbeStatusSnapshot {
|
||||
online: true,
|
||||
version: "1.2.3".to_string(),
|
||||
bundle_type: None,
|
||||
dpi_hop_v4: None,
|
||||
dpi_hop_v6: None,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user