|
1 | | -use std::time::Instant; |
| 1 | +use std::time::{Duration, Instant}; |
2 | 2 | use colored_text::Colorize; |
3 | 3 | use futures::StreamExt; |
4 | 4 | use tokio::fs::File; |
5 | 5 | use tokio::io::{AsyncBufReadExt, BufReader}; |
6 | 6 | use crate::database::{parse_server, ServerHistory, ServerInfo}; |
7 | 7 | use crate::{database, logger}; |
| 8 | +use crate::config::MainConfig; |
8 | 9 | use crate::logger::DefaultColor; |
9 | 10 | use crate::manager::TaskManager; |
10 | 11 | use crate::scanning::scanner::{scan, ScanConfig}; |
@@ -53,8 +54,16 @@ pub async fn scan_file(path: String) { |
53 | 54 | } |
54 | 55 | } |
55 | 56 |
|
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 | + }; |
58 | 67 |
|
59 | 68 | let total_targets = targets.len(); |
60 | 69 | let mut found_batch: Vec<(ServerInfo, ServerHistory)> = Vec::new(); |
@@ -90,7 +99,6 @@ pub async fn scan_file(path: String) { |
90 | 99 |
|
91 | 100 | if found_batch.len() >= 50 { |
92 | 101 | let batch_to_insert = std::mem::take(&mut found_batch); |
93 | | - |
94 | 102 | save_server(&batch_to_insert).await; |
95 | 103 | } |
96 | 104 | } |
@@ -146,6 +154,7 @@ pub async fn save_server(results: &Vec<(ServerInfo, ServerHistory)>) { |
146 | 154 | let use_db = crate::USE_DATABASE.get().map(|a| **a).unwrap_or(true); |
147 | 155 |
|
148 | 156 | if !use_db { |
| 157 | + logger::debug("Skipping database insert...".into()).prefix("Database").send().await; |
149 | 158 | return; |
150 | 159 | } |
151 | 160 |
|
|
0 commit comments