Commit Graph

102 Commits

Author SHA1 Message Date
Markus Unterwaditzer
df8a1f5606 Fix RecordingStore::create
Bug introduced in #225
2025-04-03 15:22:08 -07:00
Markus Unterwaditzer
58f0071864 Fix malformed QMDL store writes
Fix https://github.com/EFForg/rayhunter/issues/199
Fix https://github.com/EFForg/rayhunter/issues/151

rayhunter updates manifest files using write **without truncation**.
This means that if the new manifest is shorter than the old one,
trailing bytes of the old data will persist in the new file.

Switch over to atomic file writes so that this bug is fixed + rayhunter
behaves correctly if it is killed mid-write.

https://github.com/EFForg/rayhunter/pull/182 could be reverted as it
seems to mostly be a workaround.
2025-04-03 12:09:19 -07:00
Sashanoraa
fbc47187c5 Create ServerState outside of run_server
This reduces the number of arguments of run_server to make clippy happy
and also makes the code easier to understand.
2025-03-27 11:57:01 -07:00
Sashanoraa
5f601a209e Collapse nested if statements 2025-03-27 11:57:01 -07:00
Sashanoraa
034e0632e4 Box some of the larger information element enum variants
An enum is always the size needed to store its largest variant. Some of
the variants of the InformationElement and LteInformationElement are
substantially larger than the rest. Boxing the larger variants reduces
the size of the enum, in some cases by several kilobytes.

Since Rust does not currently support destructing a Box via pattern
matching, some code that destructures these enums had to be modified.
2025-03-27 11:57:01 -07:00
Sashanoraa
4edf001ca4 Fix small clippy warnings 2025-03-27 11:57:01 -07:00
Sashanoraa
b41f61bfa6 Replace unnecessary File::options with File::create 2025-03-27 11:57:01 -07:00
Will Greenberg
c9dcbbe5d6 daemon: if we fail to parse the QMDL manifest, make a new one
If rayhunter doesn't exit cleanly (e.g. during a battery outage), the
QMDL manifest may end up in a corrupted state. If that's the case,
rayhunter should try to recover by creating a new manifest. This'll let
it continue, and will preserve previous recordings, but they won't be
visible through the UI.
2025-03-25 15:36:12 -07:00
Sashanoraa
d0d01089dd Fix various clippy warnings
This commit fixes various clippy warnings that do not affect the
function of the code and aren't stylistic in nature.
2025-03-24 13:47:20 -07:00
Sashanoraa
9c26e89b24 Modify config load to use serde default
This commit refactors the config loading code to no longer require a
separate ConfigFile struct by taking advantage of serde's `default`
attribute. This causes serde to use the Config struct's default value
for that attribute for any missing attributes, which is what the
existing code was doing anyway.

This also fixes several clippy warnings.

Serde docs: https://serde.rs/container-attrs.html#default
2025-03-24 13:47:20 -07:00
oopsbagel
0b3c0de481 fix(lib/util): use better names for runtime metadata
- document RuntimeMetadata fields
- rename RayhunterMetadata to RuntimeMetadata
- rename RuntimeMetadata.os to RuntimeMetadata.system_os
- remove unpopulated hardware field
- remove unnecessary duplication of datastructure in analyzer harness
2025-03-19 11:48:54 -07:00
oopsbagel
188e9f436b fix(qmdl-manifest): store os/arch/hardware in qmdl manifest.toml
Do not superfluously prefix these names with rayhunter_, as they describe the
hardware and not the binary.
2025-03-19 11:48:54 -07:00
oopsbagel
f2b5aa2743 feat: show rayhunter version/os/arch in pcap, ndjson, qmdl manifest
Create a util mod to provide information about the rayhunter binary and
system.
2025-03-19 11:48:54 -07:00
oopsbagel
b785a7f21c feat(qmdl): add rayhunter version and os to manifest.toml 2025-03-19 11:48:54 -07:00
Cooper Quintin
8629aacf6b switch default to not see trace messages, switch arg from quiet to verbose 2025-02-10 11:26:27 -08:00
Cooper Quintin
a3fd1479f9 rename qmdl path so that downloaded files have a qmdl extension 2025-02-10 11:26:27 -08:00
Cooper Quintin
049c563f02 fix shortcodes on rayhunter_check 2025-02-10 11:26:27 -08:00
Will Greenberg
3619df32ab check: give qmdl-path a shorthand arg 2025-01-28 11:02:19 -08:00
Will Greenberg
3e26e61b05 check: don't count informational events as warnings, better logging 2025-01-28 11:02:19 -08:00
Will Greenberg
327eaddcd7 rayhunter-check: pcapify qmdl 2025-01-06 16:24:11 -08:00
Cooper Quintin
95e8f846d3 propegate colorblind mode beyond start/stop 2024-11-26 11:05:13 -08:00
Cooper Quintin
15f128add1 remove unneeded import 2024-11-26 11:05:13 -08:00
Cooper Quintin
87f9cc403b add colorblind mode. Fixes #77 2024-11-26 11:05:13 -08:00
Will Greenberg
16f705f29c Add the test analyzer entirely via daemon flags
Also consolidate the duplicate AnalysisWriter implementation
2024-10-08 14:58:46 -07:00
Will Greenberg
df84faa1f9 On-demand analysis of past recordings
* rayhunter-daemon: API for triggering and reading analysis
* rayhunter-daemon: rename readonly mode to debug mode
* rayhunter-daemon: debug mode allows live-loading frontend files
* rayhunter-check: rework to handle directories
* rayhunter-check: better output
* CI: build rayhunter-check
2024-10-08 14:58:46 -07:00
Cooper Quintin
c59fb7c013 Fix UI and add more logging (#61)
* add some more logging

* WIP attempt to fix async on update_ui

* fix async for update_ui
2024-10-03 13:32:59 -07:00
Cooper Quintin
ca4f49b15f Framebuffer update (#60)
* first pass at changing the UI color based on state

* adding flag to qmdl metadata for when hueristic is triggered

* update style for web page to match UI and have color alert on heuristic trigger

* add test analyzer

* rename example_analyzer to test_analyzer

* refactor ui update to not depend on server

* refactor to pass around color instead of display state for framebuffer channel

* add debug feature flag for test analyzer

* remove warning status from qmdl manifest

* dont keep has warning around
2024-10-03 10:41:59 -07:00
Will Greenberg
861aaedd47 rayhunter-check improvements 2024-08-19 16:49:01 -07:00
Will Greenberg
bc93c01890 bin: rm deprecated tempdir crate 2024-08-05 09:57:09 -07:00
Cooper Quintin
60cbdefb29 minor fixes 2024-06-17 16:18:55 -07:00
Cooper Quintin
ebdd32ad5f Update bin/src/daemon.rs
Co-authored-by: Will Greenberg <willg@eff.org>
2024-06-17 15:32:42 -07:00
Cooper Quintin
a9842fcadb Apply suggestions from code review
Co-authored-by: Will Greenberg <willg@eff.org>
2024-06-17 11:46:01 -07:00
Cooper Quintin
aa730f3c18 add EFF logo as an option 2024-06-14 14:15:41 -07:00
Cooper Quintin
54dd952ebd refactor display code 2024-06-14 14:00:46 -07:00
Cooper Quintin
e31bccb229 draw_line method added to framebuffer 2024-06-13 17:20:25 -07:00
Cooper Quintin
8365cb5706 send bytes to framebuffer instead of image 2024-06-12 17:04:47 -07:00
Cooper Quintin
31233560cc Update bin/src/framebuffer.rs
Co-authored-by: Will Greenberg <willg@eff.org>
2024-06-12 14:51:41 -07:00
Cooper Quintin
b2d8b7d5f3 Update bin/src/framebuffer.rs
Co-authored-by: Will Greenberg <willg@eff.org>
2024-06-12 14:51:32 -07:00
Cooper Quintin
de8cf51649 add config and read files from binary 2024-06-11 16:46:47 -07:00
Cooper Quintin
81f545e90e respect ctrl c in image display loop 2024-06-10 13:28:36 -07:00
Cooper Quintin
46cd8a9af0 poc of image drawing 2024-06-07 16:30:22 -07:00
Cooper Quintin
2ab48875ba make framebuffer crate and call it 2024-06-07 13:30:33 -07:00
Will Greenberg
bfc688ad21 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.
2024-05-09 14:46:41 -07:00
Will Greenberg
3c932f0ce9 daemon: run analysis in realtime
Currently we just show the results of analysis as a <pre> tagged
JSON blob, but eventually we can make some actual UI
2024-05-08 14:58:14 -07:00
Will Greenberg
c883cdf7c6 daemon: bind to 0.0.0.0
127.0.0.1 is loopback, so rayhunter wasn't accessible via wifi
before.
2024-04-30 17:45:16 -07:00
Will Greenberg
531c10cf29 Add rayhunter-check, a utility for running QMDL heuristics 2024-03-11 18:21:52 -07:00
Will Greenberg
f19506b415 daemon: rename entrypoint from main.rs to daemon.rs 2024-03-11 18:21:10 -07:00
Will Greenberg
0b6c06c7e6 appease clippy 2024-02-22 19:29:52 -08:00
Will Greenberg
775cbcda1e Transition to async I/O for most things
Mixing async and sync I/O leads to a multitude of complications, and
generally speaking it's much more convenient to stick to one paradigm
or the other. Since axum (and many other HTTP servers) use async,
and since async is a convenient model for performing operations like
"handle an MPSC message or file read, whichever happens first", let's
commit to an async interface.
2024-02-22 19:28:58 -08:00
Will Greenberg
df651fe334 qmdl_store: replace end_time with last_message_time
This way, even if the program exits unexpectedly, there's a reasonable
value for the "end time" of a log.
2024-02-22 19:10:31 -08:00