diff --git a/config-example.toml b/config-example.toml index f6fcb2c..69c78d9 100644 --- a/config-example.toml +++ b/config-example.toml @@ -4,6 +4,8 @@ scan_delay = 60 port_range_start = 25565 port_range_end = 25565 ignore_fake_players = true +# Can be one of "OldestFirst", "NewestFirst", "LeastPlayers", "MostPlayers" +rescan_priority = "OldestFirst" [masscan] # Location of masscans config file diff --git a/src/config.rs b/src/config.rs index f9175ad..01d13d3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -4,6 +4,14 @@ use std::fs::File; use std::io::{ErrorKind, Read}; use tracing::error; +#[derive(Deserialize, Clone, Copy, Debug)] +pub enum ServerRescanPriority { + OldestFirst, + NewestFirst, + LeastPlayers, + MostPlayers, +} + #[derive(Deserialize, Clone, Debug)] pub struct Config { pub database: Database, @@ -28,6 +36,8 @@ pub struct ScannerConfig { pub scan_delay: u64, pub port_range_start: u16, pub port_range_end: u16, + pub ignore_fake_players: bool, + pub rescan_priority: ServerRescanPriority, } #[derive(Deserialize, Clone, Debug)] diff --git a/src/main.rs b/src/main.rs index 034c001..30adf0b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,7 @@ mod database; mod protocol; mod scanning; -use chrono::{DateTime, Local, NaiveDate}; +use chrono::{DateTime, Local}; use clap::Parser; use config::load_config; use lazy_static::lazy_static; @@ -17,7 +17,7 @@ use tracing::{error, info}; use crate::config::Config; use crate::database::{Database, country_tracking}; -use crate::scanning::rescanner::{Rescanner, ServerRescanPriority}; +use crate::scanning::rescanner::Rescanner; #[derive(Parser, Debug)] #[clap(about = "Scans the internet for minecraft servers and indexes them")] @@ -131,7 +131,7 @@ async fn main() { let rescanner = Rescanner { is_active: true, database: Database { connection: pool }, - rescan_priority: ServerRescanPriority::OldestFirst, + rescan_priority: CONFIG.scanner.rescan_priority, }; rescanner.rescan_database().await; diff --git a/src/scanning/rescanner.rs b/src/scanning/rescanner.rs index 945b46d..39ae2e9 100644 --- a/src/scanning/rescanner.rs +++ b/src/scanning/rescanner.rs @@ -6,17 +6,9 @@ use indicatif::{ProgressBar, ProgressStyle}; use sqlx::{Row, types::ipnet::IpNet}; use crate::{ - database::{Database, ServerUpdateOperation}, - protocol::{minecraft::simple_ping, response::MinecraftServer}, + config::ServerRescanPriority, database::{Database, ServerUpdateOperation}, protocol::{minecraft::simple_ping, response::MinecraftServer} }; -pub enum ServerRescanPriority { - OldestFirst, - NewestFirst, - LeastPlayers, - MostPlayers, -} - pub struct Rescanner { pub is_active: bool, pub database: Database,