Skip to content

Commit 4b6fdef

Browse files
committed
feat(file scanner): add config values
1 parent 2f4f9d2 commit 4b6fdef

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/scanning/file_scanner.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
use std::time::Instant;
1+
use std::time::{Duration, Instant};
22
use colored_text::Colorize;
33
use futures::StreamExt;
44
use tokio::fs::File;
55
use tokio::io::{AsyncBufReadExt, BufReader};
66
use crate::database::{parse_server, ServerHistory, ServerInfo};
77
use crate::{database, logger};
8+
use crate::config::MainConfig;
89
use crate::logger::DefaultColor;
910
use crate::manager::TaskManager;
1011
use crate::scanning::scanner::{scan, ScanConfig};
@@ -53,8 +54,16 @@ pub async fn scan_file(path: String) {
5354
}
5455
}
5556

56-
// TODO: Add config options
57-
let config = ScanConfig::default();
57+
let main_cfg = MainConfig::get().expect("Config not loaded!");
58+
59+
let config = ScanConfig {
60+
ping_timeout: Duration::from_millis(main_cfg.general.ping_timeout),
61+
query_timeout: Duration::from_millis(main_cfg.general.query_timeout),
62+
join_timeout: Duration::from_millis(main_cfg.general.join_timeout),
63+
with_uuid: main_cfg.general.do_uuid_fetch,
64+
max_tasks: main_cfg.get_scanner_tasks(),
65+
..ScanConfig::default()
66+
};
5867

5968
let total_targets = targets.len();
6069
let mut found_batch: Vec<(ServerInfo, ServerHistory)> = Vec::new();
@@ -90,7 +99,6 @@ pub async fn scan_file(path: String) {
9099

91100
if found_batch.len() >= 50 {
92101
let batch_to_insert = std::mem::take(&mut found_batch);
93-
94102
save_server(&batch_to_insert).await;
95103
}
96104
}
@@ -146,6 +154,7 @@ pub async fn save_server(results: &Vec<(ServerInfo, ServerHistory)>) {
146154
let use_db = crate::USE_DATABASE.get().map(|a| **a).unwrap_or(true);
147155

148156
if !use_db {
157+
logger::debug("Skipping database insert...".into()).prefix("Database").send().await;
149158
return;
150159
}
151160

0 commit comments

Comments
 (0)