mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-04-27 16:09:58 -07:00
daemon: switch to writing heuristics output to ND-JSON
ND-JSON (newline-delimited JSON) is just a file with a list of JSON objects separated by newlines. This way, as the analyzer harness processes new packets, it can simply append JSON-serialized results to a file without parsing the entire thing first. Also simplifies the analysis stuff to all operate in the diag thread.
This commit is contained in:
@@ -23,10 +23,9 @@ async fn main() {
|
||||
let mut qmdl_reader = QmdlReader::new(qmdl_file, Some(file_size as usize));
|
||||
let mut qmdl_stream = pin!(qmdl_reader.as_stream()
|
||||
.try_filter(|container| future::ready(container.data_type == DataType::UserSpace)));
|
||||
println!("{}\n", serde_json::to_string(&harness.get_metadata()).expect("failed to serialize report metadata"));
|
||||
while let Some(container) = qmdl_stream.try_next().await.expect("failed getting QMDL container") {
|
||||
harness.analyze_qmdl_messages(container)
|
||||
let row = harness.analyze_qmdl_messages(container);
|
||||
println!("{}\n", serde_json::to_string(&row).expect("failed to serialize row"));
|
||||
}
|
||||
|
||||
let report = harness.build_analysis_report();
|
||||
println!("{}", serde_json::to_string(&report).expect("failed to serialize report"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user