Skip to content

Commit

Permalink
- check class too, before cache flush
Browse files Browse the repository at this point in the history
  • Loading branch information
lyager committed Apr 29, 2024
1 parent f6c78b6 commit 17eebd5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/dns_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ pub(crate) trait DnsRecordExt: fmt::Debug {
/// Returns whether `other` record is considered the same except TTL.
fn matches(&self, other: &dyn DnsRecordExt) -> bool;

fn get_class(&self) -> u16 {
self.get_record().entry.class
}

fn get_cache_flush(&self) -> bool {
self.get_record().entry.cache_flush
}
Expand Down
3 changes: 1 addition & 2 deletions src/service_daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2363,7 +2363,7 @@ impl DnsCache {
// When cache flush is asked, we set expire date to 1 second in the future
// if created more than 1 second ago
// Ref: RFC 6762 Section 10.2
if now > r.get_created() + 1000 {
if incoming.get_class() == r.get_class() && now > r.get_created() + 1000 {
r.set_expire(now + 1000);
}
});
Expand Down Expand Up @@ -2673,7 +2673,6 @@ mod tests {
FLAGS_QR_RESPONSE, TYPE_PTR, TYPE_TXT,
},
service_daemon::check_hostname,
service_info::IntoTxtProperties,
};
use std::{collections::HashMap, net::SocketAddr, net::SocketAddrV4, time::Duration};

Expand Down

0 comments on commit 17eebd5

Please sign in to comment.