Skip to content

Commit 9964d22

Browse files
author
Jacob Halsey
committed
exclude docker desktop
1 parent 9831791 commit 9964d22

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "wsl2-dns-agent"
3-
version = "0.1.1"
3+
version = "0.2.0"
44
edition = "2021"
55
license = "GPL-3.0"
66
description = "An agent that automatically patches your WSL2 DNS configuration for users of Cisco AnyConnect (or similar VPNs)"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,5 @@ shutdown = false
4646
[distributions.Ubuntu]
4747
apply_dns = false
4848
```
49+
50+
Note: the default configuration will ignore Docker Desktop, since the changes are unnecessary.

src/config.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ use std::collections::HashMap;
44
use std::fs;
55
use std::path::PathBuf;
66

7+
const EXCLUDE_BY_DEFAULT: &[&str] = &["docker-desktop", "docker-desktop-data"];
8+
79
#[derive(Debug, Deserialize, Serialize)]
810
pub struct Config {
911
/// Show toast notifications when DNS update is applied
@@ -13,10 +15,25 @@ pub struct Config {
1315
#[serde(default)]
1416
defaults: DistributionSetting,
1517
/// Per distribution settings
16-
#[serde(default)]
18+
#[serde(default = "default_distributions")]
1719
distributions: HashMap<String, DistributionSetting>,
1820
}
1921

22+
fn default_distributions() -> HashMap<String, DistributionSetting> {
23+
let mut map = HashMap::new();
24+
for d in EXCLUDE_BY_DEFAULT {
25+
map.insert(
26+
d.to_string(),
27+
DistributionSetting {
28+
apply_dns: false,
29+
shutdown: false,
30+
patch_wsl_conf: false,
31+
},
32+
);
33+
}
34+
map
35+
}
36+
2037
#[derive(Debug, Deserialize, Serialize)]
2138
pub struct DistributionSetting {
2239
/// Whether to update the wsl.conf and resolv.conf files for this distribution

src/runner.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ fn update_dns(config: &Config) -> Result<(), Error> {
8282
if let Err(e) = update_distribution(&d, dist_config, &resolv) {
8383
log::error!("Failed to update DNS for {}, due to: {}", d.name, e);
8484
}
85+
} else {
86+
log::info!("Ignoring: {}", d.name);
8587
}
8688
}
8789
Ok(())

0 commit comments

Comments
 (0)