Skip to content

Commit

Permalink
chore: disable fake-ip store by default
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat616 committed Jan 18, 2025
1 parent 433ffd7 commit 03df755
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion backend/tauri/src/enhance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,38 @@ pub async fn enhance() -> (Mapping, Vec<String>, PostProcessingOutput) {

fn use_cache(mut config: Mapping) -> Mapping {
if !config.contains_key("profile") {
tracing::debug!("Don't detect profile, set default profile for memorized profile");
let mut profile = Mapping::new();
profile.insert("store-selected".into(), true.into());
profile.insert("store-fake-ip".into(), true.into());
// Disable fake-ip store, due to the slow speed.
// each dns query should indirect to the file io, which is very very slow.
profile.insert("store-fake-ip".into(), false.into());
config.insert("profile".into(), profile.into());
}
config
}


#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_use_cache() {
let config = Mapping::new();
dbg!(&config);
let config = use_cache(config);
dbg!(&config);
assert!(config.contains_key("profile"));

let mut config = Mapping::new();
let mut profile = Mapping::new();
profile.insert("do-not-override".into(), true.into());
config.insert("profile".into(), profile.into());
dbg!(&config);
let config = use_cache(config);
dbg!(&config);
assert!(config.contains_key("profile"));
assert!(config.get("profile").unwrap().as_mapping().unwrap().contains_key("do-not-override"));
}
}

0 comments on commit 03df755

Please sign in to comment.