mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-07-19 06:18:10 -07:00
Pass notification_channel in diag_task constructor
This commit is contained in:
+6
-4
@@ -43,6 +43,7 @@ pub struct DiagTask {
|
|||||||
ui_update_sender: Sender<display::DisplayState>,
|
ui_update_sender: Sender<display::DisplayState>,
|
||||||
analysis_sender: Sender<AnalysisCtrlMessage>,
|
analysis_sender: Sender<AnalysisCtrlMessage>,
|
||||||
analyzer_config: AnalyzerConfig,
|
analyzer_config: AnalyzerConfig,
|
||||||
|
notification_channel: tokio::sync::mpsc::Sender<Notification>,
|
||||||
state: DiagState,
|
state: DiagState,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,11 +60,13 @@ impl DiagTask {
|
|||||||
ui_update_sender: Sender<display::DisplayState>,
|
ui_update_sender: Sender<display::DisplayState>,
|
||||||
analysis_sender: Sender<AnalysisCtrlMessage>,
|
analysis_sender: Sender<AnalysisCtrlMessage>,
|
||||||
analyzer_config: AnalyzerConfig,
|
analyzer_config: AnalyzerConfig,
|
||||||
|
notification_channel: tokio::sync::mpsc::Sender<Notification>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
ui_update_sender,
|
ui_update_sender,
|
||||||
analysis_sender,
|
analysis_sender,
|
||||||
analyzer_config,
|
analyzer_config,
|
||||||
|
notification_channel,
|
||||||
state: DiagState::Stopped,
|
state: DiagState::Stopped,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,7 +166,6 @@ impl DiagTask {
|
|||||||
&mut self,
|
&mut self,
|
||||||
qmdl_store: &mut RecordingStore,
|
qmdl_store: &mut RecordingStore,
|
||||||
container: MessagesContainer,
|
container: MessagesContainer,
|
||||||
notification_channel: &tokio::sync::mpsc::Sender<Notification>,
|
|
||||||
) {
|
) {
|
||||||
if container.data_type != DataType::UserSpace {
|
if container.data_type != DataType::UserSpace {
|
||||||
debug!("skipping non-userspace diag messages...");
|
debug!("skipping non-userspace diag messages...");
|
||||||
@@ -202,7 +204,7 @@ impl DiagTask {
|
|||||||
.send(display::DisplayState::WarningDetected)
|
.send(display::DisplayState::WarningDetected)
|
||||||
.await
|
.await
|
||||||
.expect("couldn't send ui update message: {}");
|
.expect("couldn't send ui update message: {}");
|
||||||
notification_channel
|
self.notification_channel
|
||||||
.send(Notification::new(
|
.send(Notification::new(
|
||||||
"heuristic-warning".to_string(),
|
"heuristic-warning".to_string(),
|
||||||
"Rayhunter has emitted a warning!".to_string(),
|
"Rayhunter has emitted a warning!".to_string(),
|
||||||
@@ -231,7 +233,7 @@ pub fn run_diag_read_thread(
|
|||||||
) {
|
) {
|
||||||
task_tracker.spawn(async move {
|
task_tracker.spawn(async move {
|
||||||
let mut diag_stream = pin!(dev.as_stream().into_stream());
|
let mut diag_stream = pin!(dev.as_stream().into_stream());
|
||||||
let mut diag_task = DiagTask::new(ui_update_sender, analysis_sender, analyzer_config);
|
let mut diag_task = DiagTask::new(ui_update_sender, analysis_sender, analyzer_config, notification_channel);
|
||||||
qmdl_file_tx
|
qmdl_file_tx
|
||||||
.send(DiagDeviceCtrlMessage::StartRecording)
|
.send(DiagDeviceCtrlMessage::StartRecording)
|
||||||
.await
|
.await
|
||||||
@@ -275,7 +277,7 @@ pub fn run_diag_read_thread(
|
|||||||
match maybe_container.unwrap() {
|
match maybe_container.unwrap() {
|
||||||
Ok(container) => {
|
Ok(container) => {
|
||||||
let mut qmdl_store = qmdl_store_lock.write().await;
|
let mut qmdl_store = qmdl_store_lock.write().await;
|
||||||
diag_task.process_container(qmdl_store.deref_mut(), container, ¬ification_channel).await
|
diag_task.process_container(qmdl_store.deref_mut(), container).await
|
||||||
},
|
},
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("error reading diag device: {err}");
|
error!("error reading diag device: {err}");
|
||||||
|
|||||||
Reference in New Issue
Block a user