diff --git a/src/input.rs b/src/input.rs index 26605317..e99f1b35 100644 --- a/src/input.rs +++ b/src/input.rs @@ -293,7 +293,14 @@ impl Config { /// pub fn read(custom_config_path: Option) -> Self { let mut content = String::new(); - let config_path = custom_config_path.unwrap_or_else(default_config_path); + let config_path = custom_config_path.unwrap_or_else(|| { + let path = default_config_path(); + match path.exists() { + true => path, + false => old_default_config_path(), + } + }); + if config_path.exists() { content = match fs::read_to_string(config_path) { Ok(content) => content, @@ -315,6 +322,14 @@ impl Config { /// Constructs default path to config toml pub fn default_config_path() -> PathBuf { + let Some(mut config_path) = dirs::config_dir() else { + panic!("Could not infer config file path."); + }; + config_path.push(".rustscan.toml"); + config_path +} + +pub fn old_default_config_path() -> PathBuf { let Some(mut config_path) = dirs::home_dir() else { panic!("Could not infer config file path."); }; diff --git a/src/main.rs b/src/main.rs index f802987d..d36753b1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -219,6 +219,17 @@ The Modern Day Port Scanner."#; opts.greppable, opts.accessible ); + + if opts.config_path.is_none() { + let old_config_path = input::old_default_config_path(); + detail!( + format!( + "For backwards compatibility, the config file may also be at {old_config_path:?}" + ), + opts.greppable, + opts.accessible + ); + } } #[cfg(unix)]