mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-04-27 07:59:59 -07:00
unified rayhunter-daemon binary for all devices
Replace per-device features with config "display" field with the value set at install time.
This commit is contained in:
committed by
Will Greenberg
parent
5b59efa4c8
commit
22d927aa25
@@ -1,3 +1,4 @@
|
||||
use log::warn;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use rayhunter::analysis::analyzer::AnalyzerConfig;
|
||||
@@ -10,18 +11,29 @@ pub struct Config {
|
||||
pub qmdl_store_path: String,
|
||||
pub port: u16,
|
||||
pub debug_mode: bool,
|
||||
pub display: Display,
|
||||
pub ui_level: u8,
|
||||
pub colorblind_mode: bool,
|
||||
pub key_input_mode: u8,
|
||||
pub analyzers: AnalyzerConfig,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum Display {
|
||||
Orbic,
|
||||
Tplink,
|
||||
Tmobile,
|
||||
Wingtech,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Config {
|
||||
qmdl_store_path: "/data/rayhunter/qmdl".to_string(),
|
||||
port: 8080,
|
||||
debug_mode: false,
|
||||
display: Display::Orbic,
|
||||
ui_level: 1,
|
||||
colorblind_mode: false,
|
||||
key_input_mode: 0,
|
||||
@@ -37,6 +49,7 @@ where
|
||||
if let Ok(config_file) = tokio::fs::read_to_string(&path).await {
|
||||
Ok(toml::from_str(&config_file).map_err(RayhunterError::ConfigFileParsingError)?)
|
||||
} else {
|
||||
warn!("unable to read config file, using default config");
|
||||
Ok(Config::default())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,11 @@
|
||||
#[cfg(any(feature = "orbic", feature = "tplink", feature = "wingtech"))]
|
||||
mod generic_framebuffer;
|
||||
|
||||
#[cfg(feature = "tmobile")]
|
||||
mod tmobile;
|
||||
#[cfg(feature = "tmobile")]
|
||||
pub use tmobile::update_ui;
|
||||
|
||||
#[cfg(feature = "tplink")]
|
||||
mod tplink;
|
||||
#[cfg(feature = "tplink")]
|
||||
mod tplink_framebuffer;
|
||||
#[cfg(feature = "tplink")]
|
||||
mod tplink_onebit;
|
||||
|
||||
#[cfg(feature = "tplink")]
|
||||
pub use tplink::update_ui;
|
||||
|
||||
#[cfg(feature = "orbic")]
|
||||
mod orbic;
|
||||
#[cfg(feature = "orbic")]
|
||||
pub use orbic::update_ui;
|
||||
|
||||
#[cfg(feature = "wingtech")]
|
||||
mod wingtech;
|
||||
#[cfg(feature = "wingtech")]
|
||||
pub use wingtech::update_ui;
|
||||
pub mod orbic;
|
||||
pub mod tmobile;
|
||||
pub mod tplink;
|
||||
pub mod tplink_framebuffer;
|
||||
pub mod tplink_onebit;
|
||||
pub mod wingtech;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
pub enum DisplayState {
|
||||
|
||||
@@ -13,7 +13,7 @@ use std::net::SocketAddr;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
use crate::config::{parse_args, parse_config};
|
||||
use crate::config::{Display, parse_args, parse_config};
|
||||
use crate::diag::run_diag_read_thread;
|
||||
use crate::error::RayhunterError;
|
||||
use crate::pcap::get_pcap;
|
||||
@@ -215,7 +215,7 @@ async fn run_with_config(
|
||||
if !config.debug_mode {
|
||||
let (ui_shutdown_tx, ui_shutdown_rx) = oneshot::channel();
|
||||
maybe_ui_shutdown_tx = Some(ui_shutdown_tx);
|
||||
let mut dev = DiagDevice::new()
|
||||
let mut dev = DiagDevice::new(config.display == Display::Tplink)
|
||||
.await
|
||||
.map_err(RayhunterError::DiagInitError)?;
|
||||
dev.config_logs()
|
||||
@@ -233,7 +233,16 @@ async fn run_with_config(
|
||||
config.analyzers.clone(),
|
||||
);
|
||||
info!("Starting UI");
|
||||
display::update_ui(&task_tracker, &config, ui_shutdown_rx, ui_update_rx);
|
||||
|
||||
let display = &config.display;
|
||||
info!("Display type {display:?}");
|
||||
let update_ui = match display {
|
||||
Display::Orbic => display::orbic::update_ui,
|
||||
Display::Tplink => display::tplink::update_ui,
|
||||
Display::Tmobile => display::tmobile::update_ui,
|
||||
Display::Wingtech => display::wingtech::update_ui,
|
||||
};
|
||||
update_ui(&task_tracker, &config, ui_shutdown_rx, ui_update_rx);
|
||||
|
||||
info!("Starting Key Input service");
|
||||
let (key_input_shutdown_tx, key_input_shutdown_rx) = oneshot::channel();
|
||||
|
||||
Reference in New Issue
Block a user