mirror of
https://github.com/ParrotXray/Mantis.git
synced 2026-08-24 19:00:27 +09:00
* wip * feat: change ebpf build path * feat: change ebpf build path * feat: add SQLCipher account DB, Argon2 password hashing, and JWT auth * feat: add graceful shutdown on SIGINT * feat: adjust code with rustfmt * docs: edit README.md
102 lines
2.7 KiB
Rust
102 lines
2.7 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct ConfigTable {
|
|
#[serde(rename = "Config")]
|
|
pub config: Config,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
pub struct SuricataConfig {
|
|
pub home_net: String,
|
|
pub worker_cpu_set: Option<[u32; 2]>,
|
|
pub management_cpu: Option<u32>,
|
|
#[serde(default = "default_af_threads")]
|
|
pub af_packet_threads: String,
|
|
#[serde(default = "default_af_ring_size")]
|
|
pub af_packet_ring_size: u32,
|
|
#[serde(default = "default_af_block_size")]
|
|
pub af_packet_block_size: u32,
|
|
#[serde(default)]
|
|
pub suppress: Vec<String>,
|
|
}
|
|
|
|
fn default_af_threads() -> String {
|
|
"auto".to_string()
|
|
}
|
|
fn default_af_ring_size() -> u32 {
|
|
2048
|
|
}
|
|
fn default_af_block_size() -> u32 {
|
|
131072
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
pub struct Config {
|
|
pub ingress_ifname: String,
|
|
pub egress_ifname: String,
|
|
pub geoip_db_name: String,
|
|
pub deep_autoencoder_name: String,
|
|
pub models_config_name: String,
|
|
pub combined_queue_count: u32,
|
|
pub channel_size: usize,
|
|
pub fill_queue_size: u32,
|
|
pub comp_queue_size: u32,
|
|
pub tx_queue_size: u32,
|
|
pub rx_queue_size: u32,
|
|
pub frame_size: u32,
|
|
pub frame_count: u32,
|
|
pub refresh_interval: u64,
|
|
pub http_server_bind_port: u16,
|
|
pub max_concurrent_flows: usize,
|
|
pub inference_interval_secs: u64,
|
|
pub aggregator_window_secs: u64,
|
|
pub inference_batch_size: usize,
|
|
pub flow_timeout_us: u64,
|
|
pub traffic_logging_mode: bool,
|
|
pub traffic_log_csv_path: String,
|
|
pub tls_keylog_path: Option<String>,
|
|
pub xsk_cpu_set: Option<[u32; 2]>,
|
|
pub ml_cpu: Option<u32>,
|
|
#[serde(default = "default_fusion_mode")]
|
|
pub fusion_mode: String,
|
|
#[serde(default = "default_fusion_window_secs")]
|
|
pub fusion_window_secs: u64,
|
|
#[serde(default = "default_ae_threshold_method")]
|
|
pub ae_threshold_method: String,
|
|
|
|
/// Suricata rule engine config. If absent, the rule engine is disabled.
|
|
pub suricata: Option<SuricataConfig>,
|
|
/// Auth system config. If absent, auth is disabled and all routes are public.
|
|
pub auth: Option<AuthConfig>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
pub struct AuthConfig {
|
|
pub jwt_secret: String,
|
|
pub db_key: String,
|
|
#[serde(default = "default_token_ttl")]
|
|
pub token_ttl_secs: u64,
|
|
#[serde(default = "default_admin_password")]
|
|
pub default_admin_password: String,
|
|
}
|
|
|
|
fn default_token_ttl() -> u64 {
|
|
86400
|
|
}
|
|
fn default_admin_password() -> String {
|
|
"admin".to_string()
|
|
}
|
|
|
|
fn default_fusion_mode() -> String {
|
|
"or".to_string()
|
|
}
|
|
|
|
fn default_fusion_window_secs() -> u64 {
|
|
10
|
|
}
|
|
|
|
fn default_ae_threshold_method() -> String {
|
|
"95".to_string()
|
|
}
|