M src/config.rs => src/config.rs +21 -0
@@ 86,6 86,24 @@ pub struct Config {
#[serde(alias = "filter")]
pub filters: HashMap<String, ConfigFilter>,
+ /// Equivalent to `ConfigFilter.overrides` with an empty `ConfigFilter.applies_to`.
+ #[serde(default)]
+ #[serde(alias = "override")]
+ #[serde(deserialize_with = "string_or_seq_string")]
+ pub overrides: Vec<String>,
+
+ /// Equivalent to `ConfigFilter.blocks` with an empty `ConfigFilter.applies_to`.
+ #[serde(default)]
+ #[serde(alias = "block")]
+ #[serde(deserialize_with = "string_or_seq_string")]
+ pub blocks: Vec<String>,
+
+ /// Equivalent to `ConfigFilter.allows` with an empty `ConfigFilter.applies_to`.
+ #[serde(default)]
+ #[serde(alias = "allow")]
+ #[serde(deserialize_with = "string_or_seq_string")]
+ pub allows: Vec<String>,
+
/// One or more DNS server endpoints.
/// These may be provided as hostnames (required for DNS-over-HTTPS), but at least one upstream entry must be provided as an IP to "bootstrap" any hostname entries.
/// Entries are in order of priority, where earlier entries are used before trying later entries. The following protocols are supported:
@@ 122,6 140,9 @@ impl Config {
upstreams: vec![upstream],
filter_refresh_seconds: 3600,
filters: HashMap::new(),
+ overrides: Vec::new(),
+ blocks: Vec::new(),
+ allows: Vec::new(),
redis: "".to_string(),
}
}
M src/runner.rs => src/runner.rs +12 -1
@@ 206,7 206,18 @@ impl Runner {
let filter_copy = filter.clone();
// For now we assume that the list of filters is constant.
// Once we start supporting live updates of the filter list, this will need to be restructured.
- let filters_copy = self.config.filters.clone();
+ let mut filters_copy = self.config.filters.clone();
+ if !self.config.overrides.is_empty() || !self.config.blocks.is_empty() || !self.config.allows.is_empty() {
+ filters_copy.insert(
+ "".to_string(),
+ config::ConfigFilter{
+ overrides: self.config.overrides,
+ blocks: self.config.blocks,
+ allows: self.config.allows,
+ applies_to: "".to_string(),
+ }
+ );
+ }
thread_handles.push(
thread::Builder::new()
.name("filter-reload".to_string())