Fix: Skip invalid entries in log files

This commit is contained in:
Maurus Decimus
2026-04-28 12:00:52 +02:00
parent 3508476521
commit 4111f29c3f
2 changed files with 18 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ If you are upgrading from v0.16.x, replace the binary (or run `docker pull`). If
- DNS Updater:
- BunnyDNS: Use subdomain as name of record instead of FQDN.
- RFC2136: Chunk TXT records.
- Skip invalid entries in log files.
## [0.16.1] - 2026-04-25

View File

@@ -181,6 +181,11 @@ fn read_log_offsets(
for line in rev_lines {
let line = line?;
offset = offset.saturating_sub(line.len() as u64 + 1); // +1 for the newline character
if !is_log_header(&line) {
continue;
}
let id = (file_number << 48) | offset;
if !found_anchor {
@@ -267,6 +272,18 @@ fn read_log_entries(
Ok(entries)
}
fn is_log_header(line: &str) -> bool {
let line = strip_ansi(line);
let bytes = line.as_bytes();
if bytes.is_empty() || !bytes[0].is_ascii_digit() {
return false;
}
let Some((timestamp, _)) = line.split_once(' ') else {
return false;
};
DateTime::parse_from_rfc3339(timestamp).is_ok()
}
fn log_from_line(line: &str) -> Option<Log> {
let line = strip_ansi(line);
let (timestamp, rest) = line.split_once(' ')?;