add Makefile with clippy/rustfmt linting, fix all warnings

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Razvan Dimescu
2026-03-10 05:04:31 +02:00
parent 3816cf644d
commit 89e7cbd989
9 changed files with 143 additions and 39 deletions

View File

@@ -34,7 +34,7 @@ impl DnsCache {
self.query_count += 1;
// Periodic eviction every 1000 queries
if self.query_count % 1000 == 0 {
if self.query_count.is_multiple_of(1000) {
self.evict_expired();
}
@@ -72,15 +72,19 @@ impl DnsCache {
.clamp(self.min_ttl, self.max_ttl);
let key = (domain.to_string(), qtype);
self.entries.insert(key, CacheEntry {
packet: packet.clone(),
inserted_at: Instant::now(),
ttl: Duration::from_secs(min_ttl as u64),
});
self.entries.insert(
key,
CacheEntry {
packet: packet.clone(),
inserted_at: Instant::now(),
ttl: Duration::from_secs(min_ttl as u64),
},
);
}
fn evict_expired(&mut self) {
self.entries.retain(|_, entry| entry.inserted_at.elapsed() < entry.ttl);
self.entries
.retain(|_, entry| entry.inserted_at.elapsed() < entry.ttl);
}
}