v0.42.4_fixes
This commit is contained in:
1 parent
efc6eda4cd
commit
51631810e1
29 files changed
+1192
-394
No files matched your search
+30
-7
@@ -53,7 +53,10 @@ pub(crate) fn statuses(config: &Config) -> Result<Vec<DnsAclStatus>> {
|
||||
let diagnostics = DIAGNOSTICS.load();
|
||||
let cache = CACHE.load();
|
||||
let now = Instant::now();
|
||||
Ok(names.into_iter().map(|name| status_for_name(name, &cache, &diagnostics, now)).collect())
|
||||
Ok(names
|
||||
.into_iter()
|
||||
.map(|name| status_for_name(name, &cache, &diagnostics, now))
|
||||
.collect())
|
||||
}
|
||||
|
||||
fn status_for_name(
|
||||
@@ -184,7 +187,9 @@ fn validate_addresses(mut ips: Vec<IpAddr>) -> std::result::Result<Addresses, St
|
||||
return Err("DNS response contains no A/AAAA addresses".into());
|
||||
}
|
||||
if ips.len() > MAX_ADDRESSES {
|
||||
return Err(format!("DNS response exceeds the limit of {MAX_ADDRESSES} unique addresses"));
|
||||
return Err(format!(
|
||||
"DNS response exceeds the limit of {MAX_ADDRESSES} unique addresses"
|
||||
));
|
||||
}
|
||||
if ips
|
||||
.iter()
|
||||
@@ -206,7 +211,9 @@ async fn resolve(name: String) -> (String, std::result::Result<Addresses, String
|
||||
)
|
||||
.await;
|
||||
let result = match answer {
|
||||
Err(_) => Err(format!("DNS lookup timed out after {LOOKUP_SECONDS} seconds")),
|
||||
Err(_) => Err(format!(
|
||||
"DNS lookup timed out after {LOOKUP_SECONDS} seconds"
|
||||
)),
|
||||
Ok(Err(error)) => Err(format!("system DNS resolver returned: {error}")),
|
||||
Ok(Ok(sockets)) => validate_addresses(sockets.map(|socket| socket.ip()).collect()),
|
||||
};
|
||||
@@ -265,19 +272,35 @@ pub(crate) async fn poll_loop(app: Weak<crate::runtime::App>, shutdown: Cancella
|
||||
let checked_unix_ms = checked_unix_ms();
|
||||
match result {
|
||||
Ok(value) => {
|
||||
if previous.get(&hostname).is_none_or(|old| old.ips != value.ips)
|
||||
|| previous_diagnostics.get(&hostname).is_some_and(|old| old.error.is_some())
|
||||
if previous
|
||||
.get(&hostname)
|
||||
.is_none_or(|old| old.ips != value.ips)
|
||||
|| previous_diagnostics
|
||||
.get(&hostname)
|
||||
.is_some_and(|old| old.error.is_some())
|
||||
{
|
||||
tracing::info!(hostname = %hostname, addresses = ?value.ips,
|
||||
"ACL DDNS resolved; allow rule matches only these client addresses");
|
||||
}
|
||||
addresses.insert(hostname.clone(), value);
|
||||
diagnostics.insert(hostname, DnsDiagnostic { checked_unix_ms, error: None });
|
||||
diagnostics.insert(
|
||||
hostname,
|
||||
DnsDiagnostic {
|
||||
checked_unix_ms,
|
||||
error: None,
|
||||
},
|
||||
);
|
||||
}
|
||||
Err(error) => {
|
||||
tracing::warn!(hostname = %hostname, reason = %error,
|
||||
"ACL DDNS resolution failed; hostname allows no client addresses");
|
||||
diagnostics.insert(hostname, DnsDiagnostic { checked_unix_ms, error: Some(error) });
|
||||
diagnostics.insert(
|
||||
hostname,
|
||||
DnsDiagnostic {
|
||||
checked_unix_ms,
|
||||
error: Some(error),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user