mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-05-01 09:59:57 -07:00
the great rename
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::error::WavehunterError;
|
||||
use crate::error::RayhunterError;
|
||||
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -19,18 +19,18 @@ pub struct Config {
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Config {
|
||||
qmdl_store_path: "/data/wavehunter/qmdl".to_string(),
|
||||
qmdl_store_path: "/data/rayhunter/qmdl".to_string(),
|
||||
port: 8080,
|
||||
readonly_mode: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_config<P>(path: P) -> Result<Config, WavehunterError> where P: AsRef<std::path::Path> {
|
||||
pub fn parse_config<P>(path: P) -> Result<Config, RayhunterError> where P: AsRef<std::path::Path> {
|
||||
let mut config = Config::default();
|
||||
if let Ok(config_file) = std::fs::read_to_string(&path) {
|
||||
let parsed_config: ConfigFile = toml::from_str(&config_file)
|
||||
.map_err(WavehunterError::ConfigFileParsingError)?;
|
||||
.map_err(RayhunterError::ConfigFileParsingError)?;
|
||||
if let Some(path) = parsed_config.qmdl_store_path { config.qmdl_store_path = path }
|
||||
if let Some(port) = parsed_config.port { config.port = port }
|
||||
if let Some(readonly_mode) = parsed_config.readonly_mode { config.readonly_mode = readonly_mode }
|
||||
|
||||
@@ -12,7 +12,7 @@ use tokio::sync::mpsc::error::TryRecvError;
|
||||
use tokio::task::JoinHandle;
|
||||
use tokio_util::task::TaskTracker;
|
||||
|
||||
use crate::error::WavehunterError;
|
||||
use crate::error::RayhunterError;
|
||||
use crate::qmdl_store::QmdlStore;
|
||||
use crate::server::ServerState;
|
||||
|
||||
@@ -22,7 +22,7 @@ pub enum DiagDeviceCtrlMessage {
|
||||
Exit,
|
||||
}
|
||||
|
||||
pub fn run_diag_read_thread(task_tracker: &TaskTracker, mut dev: DiagDevice, mut qmdl_file_rx: Receiver<DiagDeviceCtrlMessage>, qmdl_store_lock: Arc<RwLock<QmdlStore>>) -> JoinHandle<Result<(), WavehunterError>> {
|
||||
pub fn run_diag_read_thread(task_tracker: &TaskTracker, mut dev: DiagDevice, mut qmdl_file_rx: Receiver<DiagDeviceCtrlMessage>, qmdl_store_lock: Arc<RwLock<QmdlStore>>) -> JoinHandle<Result<(), RayhunterError>> {
|
||||
// mpsc channel for updating QmdlStore entry filesizes. First usize is the
|
||||
// index, second is the size in bytes
|
||||
let (tx, mut rx) = mpsc::channel::<(usize, usize)>(1);
|
||||
@@ -67,7 +67,7 @@ pub fn run_diag_read_thread(task_tracker: &TaskTracker, mut dev: DiagDevice, mut
|
||||
// returned here. Until then, the DiagDevice has already written those messages
|
||||
// to the QMDL file, so we can just ignore them.
|
||||
debug!("reading response from diag device...");
|
||||
let _messages = dev.read_response().map_err(WavehunterError::DiagReadError)?;
|
||||
let _messages = dev.read_response().map_err(RayhunterError::DiagReadError)?;
|
||||
debug!("got diag response ({} messages)", _messages.len());
|
||||
|
||||
// keep track of how many bytes were written to the QMDL file so we can read
|
||||
|
||||
@@ -4,7 +4,7 @@ use orca::diag_device::DiagDeviceError;
|
||||
use crate::qmdl_store::QmdlStoreError;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum WavehunterError {
|
||||
pub enum RayhunterError{
|
||||
#[error("Config file parsing error: {0}")]
|
||||
ConfigFileParsingError(#[from] toml::de::Error),
|
||||
#[error("Diag intialization error: {0}")]
|
||||
|
||||
@@ -12,7 +12,7 @@ use crate::qmdl_store::QmdlStore;
|
||||
use crate::server::{ServerState, get_qmdl, serve_static};
|
||||
use crate::pcap::get_pcap;
|
||||
use crate::stats::get_system_stats;
|
||||
use crate::error::WavehunterError;
|
||||
use crate::error::RayhunterError;
|
||||
|
||||
use axum::response::Redirect;
|
||||
use diag::{DiagDeviceCtrlMessage, start_recording, stop_recording};
|
||||
@@ -73,11 +73,11 @@ async fn server_shutdown_signal(server_shutdown_rx: oneshot::Receiver<()>) {
|
||||
|
||||
// Loads a QmdlStore if one exists, and if not, only create one if we're not in
|
||||
// readonly mode.
|
||||
async fn init_qmdl_store(config: &config::Config) -> Result<QmdlStore, WavehunterError> {
|
||||
async fn init_qmdl_store(config: &config::Config) -> Result<QmdlStore, RayhunterError> {
|
||||
match (QmdlStore::exists(&config.qmdl_store_path).await?, config.readonly_mode) {
|
||||
(true, _) => Ok(QmdlStore::load(&config.qmdl_store_path).await?),
|
||||
(false, false) => Ok(QmdlStore::create(&config.qmdl_store_path).await?),
|
||||
(false, true) => Err(WavehunterError::NoStoreReadonlyMode(config.qmdl_store_path.clone())),
|
||||
(false, true) => Err(RayhunterError::NoStoreReadonlyMode(config.qmdl_store_path.clone())),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ fn run_ctrl_c_thread(
|
||||
diag_device_sender: Sender<DiagDeviceCtrlMessage>,
|
||||
server_shutdown_tx: oneshot::Sender<()>,
|
||||
qmdl_store_lock: Arc<RwLock<QmdlStore>>
|
||||
) -> JoinHandle<Result<(), WavehunterError>> {
|
||||
) -> JoinHandle<Result<(), RayhunterError>> {
|
||||
task_tracker.spawn(async move {
|
||||
match tokio::signal::ctrl_c().await {
|
||||
Ok(()) => {
|
||||
@@ -114,7 +114,7 @@ fn run_ctrl_c_thread(
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), WavehunterError> {
|
||||
async fn main() -> Result<(), RayhunterError> {
|
||||
env_logger::init();
|
||||
|
||||
let args = parse_args();
|
||||
@@ -130,9 +130,9 @@ async fn main() -> Result<(), WavehunterError> {
|
||||
let qmdl_file = qmdl_store_lock.write().await.new_entry().await?;
|
||||
let qmdl_writer = QmdlWriter::new(qmdl_file.into_std().await);
|
||||
let mut dev = DiagDevice::new(Some(qmdl_writer))
|
||||
.map_err(WavehunterError::DiagInitError)?;
|
||||
.map_err(RayhunterError::DiagInitError)?;
|
||||
dev.config_logs()
|
||||
.map_err(WavehunterError::DiagInitError)?;
|
||||
.map_err(RayhunterError::DiagInitError)?;
|
||||
|
||||
run_diag_read_thread(&task_tracker, dev, rx, qmdl_store_lock.clone());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user